PR tree-optimization/93683 - ICE on calloc with unused return value in ao_ref_init_fr...
authorMartin Sebor <msebor@redhat.com>
Tue, 11 Feb 2020 23:53:13 +0000 (16:53 -0700)
committerMartin Sebor <msebor@redhat.com>
Tue, 11 Feb 2020 23:53:13 +0000 (16:53 -0700)
gcc/testsuite/ChangeLog:

PR tree-optimization/93683
* gcc.dg/tree-ssa/ssa-dse-39.c: New test.

gcc/ChangeLog:

PR tree-optimization/93683
* tree-ssa-alias.c (stmt_kills_ref_p): Avoid using LHS when not set.

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-39.c [new file with mode: 0644]
gcc/tree-ssa-alias.c

index a124ed5de358c4ecaaa41df6961b4f66cd9507aa..2f6dbdc13bafcbb43385377f55a20989b4a562d3 100644 (file)
@@ -1,3 +1,8 @@
+2020-02-11  Martin Sebor  <msebor@redhat.com>
+
+       PR tree-optimization/93683
+       * tree-ssa-alias.c (stmt_kills_ref_p): Avoid using LHS when not set.
+
 2020-02-11  Michael Meissner  <meissner@linux.ibm.com>
 
        * config/rs6000/predicates.md (cint34_operand): Rename the
index 8120020e315b4e52e23d18be0be5a659238d5bcf..d2a005b4af6bc06cdc3e390bd83756e4ed334d0f 100644 (file)
@@ -1,3 +1,8 @@
+2020-02-11  Martin Sebor  <msebor@redhat.com>
+
+       PR tree-optimization/93683
+       * gcc.dg/tree-ssa/ssa-dse-39.c: New test.
+
 2020-02-11  Will Schmidt  <will_schmidt@vnet.ibm.com>
 
        * lib/target-supports.exp (check_effective_target_ppc_ieee128_ok): New.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-39.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-39.c
new file mode 100644 (file)
index 0000000..bd663f1
--- /dev/null
@@ -0,0 +1,18 @@
+/* PR tree-optimization/93683 - ICE on calloc with unused return value
+   in ao_ref_init_from_ptr_and_size
+   { dg-do compile }
+   { dg-options "-O2 -Wall -Wno-unused-result -fdump-tree-cddce1" } */
+
+void f0 (int *a)
+{
+  *a = 0;
+  __builtin_calloc (1, 1);
+}
+
+void f1 (int *a, unsigned n)
+{
+  *a = n;
+  __builtin_calloc (n, n);
+}
+
+/* { dg-final { scan-tree-dump-not "calloc" "cddce1" } } */
index c7e6679f990d172dff36ceea6a7e4a4dd7e9b0c8..fd7810506685c27d5c0f6e7c7ef0cfe895f8a179 100644 (file)
@@ -3265,6 +3265,8 @@ stmt_kills_ref_p (gimple *stmt, ao_ref *ref)
                    return false;
 
                  dest = gimple_call_lhs (stmt);
+                 if (!dest)
+                   return false;
                  len = fold_build2 (MULT_EXPR, TREE_TYPE (arg0), arg0, arg1);
                }
              else