Fix tree-optimization/78886.
authorMartin Liska <mliska@suse.cz>
Thu, 22 Dec 2016 13:09:11 +0000 (14:09 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Thu, 22 Dec 2016 13:09:11 +0000 (13:09 +0000)
PR tree-optimization/78886
* gcc.dg/tree-ssa/pr78886.c: New test.
PR tree-optimization/78886
* tree-ssa-strlen.c (handle_builtin_malloc): Return when LHS
is equal to NULL.

From-SVN: r243886

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr78886.c [new file with mode: 0644]
gcc/tree-ssa-strlen.c

index 0b3c84f814df9352b654794924509a03129030dc..b09d8fb7f1f816ab487ccda2bbab62adfd84b0ca 100644 (file)
@@ -1,3 +1,9 @@
+2016-12-22  Martin Liska  <mliska@suse.cz>
+
+       PR tree-optimization/78886
+       * tree-ssa-strlen.c (handle_builtin_malloc): Return when LHS
+       is equal to NULL.
+
 2016-12-22  Jakub Jelinek  <jakub@redhat.com>
 
        PR bootstrap/78817
index c63fd5e6e383d4fa23a18c3c21434ec9dd565227..c9ab9dec6a6ae0d27aa5d453200a7390d96598b1 100644 (file)
@@ -1,3 +1,8 @@
+2016-12-22  Martin Liska  <mliska@suse.cz>
+
+       PR tree-optimization/78886
+       * gcc.dg/tree-ssa/pr78886.c: New test.
+
 2016-12-22  Georg-Johann Lay  <avr@gjlay.de>
 
        PR testsuite/52641
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr78886.c b/gcc/testsuite/gcc.dg/tree-ssa/pr78886.c
new file mode 100644 (file)
index 0000000..9779930
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+void *malloc(unsigned long x);
+
+void foo(void)
+{
+ volatile int i;
+ malloc(1);
+ i;
+}
index 67075f07e2962726c5585431ffe8f4aabf8efa7f..4a05725ca7c4508ab60a7f3f99587da9b8cc2bd0 100644 (file)
@@ -1869,6 +1869,9 @@ handle_builtin_malloc (enum built_in_function bcode, gimple_stmt_iterator *gsi)
 {
   gimple *stmt = gsi_stmt (*gsi);
   tree lhs = gimple_call_lhs (stmt);
+  if (lhs == NULL_TREE)
+    return;
+
   gcc_assert (get_stridx (lhs) == 0);
   int idx = new_stridx (lhs);
   tree length = NULL_TREE;