gcc/fix-ICE-during-GIMPLE-pass-dse.patch
2020-09-11 10:30:42 +08:00

36 lines
1.5 KiB
Diff

This backport contains 1 patch from gcc main stream tree.
The commit id of these patchs list as following in the order of time.
0001-Fix-ICE-when-__builtin_calloc-has-no-LHS-PR-tree-opt.patch
4c4be718fb65f9b8dd06d83c6fa3f697a5369d52
diff -Nurp a/gcc/testsuite/gcc.target/s390/pr91014.c b/gcc/testsuite/gcc.target/s390/pr91014.c
--- a/gcc/testsuite/gcc.target/s390/pr91014.c 1970-01-01 08:00:00.000000000 +0800
+++ b/gcc/testsuite/gcc.target/s390/pr91014.c 2020-09-09 15:47:34.740000000 +0800
@@ -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'" } */
+}
diff -Nurp a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c
--- a/gcc/tree-ssa-dse.c 2020-09-09 15:47:21.084000000 +0800
+++ b/gcc/tree-ssa-dse.c 2020-09-09 15:47:34.740000000 +0800
@@ -119,10 +119,11 @@ initialize_ao_ref_for_dse (gimple *stmt,
{
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);