]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix tree-optimization/78886.
authorMartin Liska <mliska@suse.cz>
Tue, 3 Jan 2017 12:08:10 +0000 (13:08 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Tue, 3 Jan 2017 12:08:10 +0000 (12:08 +0000)
2017-01-03  Martin Liska  <mliska@suse.cz>

Backport from mainline
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.
2017-01-03  Martin Liska  <mliska@suse.cz>

Backport from mainline
2016-12-22  Martin Liska  <mliska@suse.cz>

PR tree-optimization/78886
* gcc.dg/tree-ssa/pr78886.c: New test.

From-SVN: r244019

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

index e918175c46b2ab8865b265959db3ed7aefbd4d80..5d5ff83669de8b53fb72d742e3ed8640517cdf97 100644 (file)
@@ -1,3 +1,12 @@
+2017-01-03  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       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.
+
 2017-01-03  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
index 89bd178d98784f536b581517e8efbc07344c42b2..a2d2c68bda3c14a9cfde8d4614c864d8f8042a18 100644 (file)
@@ -1,3 +1,11 @@
+2017-01-03  Martin Liska  <mliska@suse.cz>
+
+       Backport from mainline
+       2016-12-22  Martin Liska  <mliska@suse.cz>
+
+       PR tree-optimization/78886
+       * gcc.dg/tree-ssa/pr78886.c: New test.
+
 2017-01-03  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
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 e6eaad43a95d5a22be3803eb6d9b868cecb0cebf..732f3b4d671fa920c8b241ee3e25c6e6526a6d7c 100644 (file)
@@ -1891,6 +1891,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;