Fix ICE when __builtin_calloc has no LHS (PR tree-optimization/91014).
authorMartin Liska <mliska@suse.cz>
Thu, 27 Jun 2019 09:41:34 +0000 (11:41 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Thu, 27 Jun 2019 09:41:34 +0000 (09:41 +0000)
2019-06-27  Martin Liska  <mliska@suse.cz>

PR tree-optimization/91014
* tree-ssa-dse.c (initialize_ao_ref_for_dse): Bail out
when LHS is NULL_TREE.
2019-06-27  Martin Liska  <mliska@suse.cz>

PR tree-optimization/91014
* gcc.target/s390/pr91014.c: New test.

From-SVN: r272738

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/s390/pr91014.c [new file with mode: 0644]
gcc/tree-ssa-dse.c

index 16d26bd8db2171bec0d6291c2a524e55b9aa6fc8..a1bd7985efa21a6209a8f55262096a491c583755 100644 (file)
@@ -1,3 +1,9 @@
+2019-06-27  Martin Liska  <mliska@suse.cz>
+
+       PR tree-optimization/91014
+       * tree-ssa-dse.c (initialize_ao_ref_for_dse): Bail out
+       when LHS is NULL_TREE.
+
 2019-06-27  Martin Liska  <mliska@suse.cz>
 
        * symbol-summary.h (traverse): Pass
index f7b774af2399b19238e7345fdd15f70592aa2e61..c48ceefebe414e8c508b4ab2393ec921525e9f4a 100644 (file)
@@ -1,3 +1,8 @@
+2019-06-27  Martin Liska  <mliska@suse.cz>
+
+       PR tree-optimization/91014
+       * gcc.target/s390/pr91014.c: New test.
+
 2019-06-27  Richard Biener  <rguenther@suse.de>
 
        PR testsuite/91004
diff --git a/gcc/testsuite/gcc.target/s390/pr91014.c b/gcc/testsuite/gcc.target/s390/pr91014.c
new file mode 100644 (file)
index 0000000..eb37b33
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+/* { dg-require-effective-target alloca } */
+
+void foo(void)
+{
+ __builtin_calloc (1, 1); /* { dg-warning "ignoring return value of '__builtin_calloc' declared with attribute 'warn_unused_result'" } */
+}
index 1b1a9f34230d0a6ce23725f14d951ceca6567f83..df05a55ce78d40430f891b275505e5a85a6eefb5 100644 (file)
@@ -129,10 +129,11 @@ initialize_ao_ref_for_dse (gimple *stmt, ao_ref *write)
            {
              tree nelem = gimple_call_arg (stmt, 0);
              tree selem = gimple_call_arg (stmt, 1);
+             tree lhs;
              if (TREE_CODE (nelem) == INTEGER_CST
-                 && TREE_CODE (selem) == INTEGER_CST)
+                 && TREE_CODE (selem) == INTEGER_CST
+                 && (lhs = gimple_call_lhs (stmt)) != NULL_TREE)
                {
-                 tree lhs = gimple_call_lhs (stmt);
                  tree size = fold_build2 (MULT_EXPR, TREE_TYPE (nelem),
                                           nelem, selem);
                  ao_ref_init_from_ptr_and_size (write, lhs, size);