aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2012-01-03 11:54:53 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2012-01-03 11:54:53 +0000
commitf1749ec1b1a5acad4a279b17f14aac174bf7a679 (patch)
treec7ecc5722ca818dfc6ef3e519e393dabcd83add7 /gcc
parent75291c57b91d9a328fbb19dcc01195fb1ddc8468 (diff)
downloadgcc-f1749ec1b1a5acad4a279b17f14aac174bf7a679.zip
gcc-f1749ec1b1a5acad4a279b17f14aac174bf7a679.tar.gz
gcc-f1749ec1b1a5acad4a279b17f14aac174bf7a679.tar.bz2
re PR tree-optimization/51692 (ICE on several valgrind tests)
2012-01-03 Richard Guenther <rguenther@suse.de> PR tree-optimization/51692 * tree-ssa-dce.c (eliminate_unnecessary_stmts): Do not remove the LHS of allocation stmts. * gcc.dg/torture/pr51692.c: New testcase. From-SVN: r182838
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr51692.c13
-rw-r--r--gcc/tree-ssa-dce.c51
4 files changed, 53 insertions, 22 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index dd3c6d7..77e96a3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2012-01-03 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/51692
+ * tree-ssa-dce.c (eliminate_unnecessary_stmts): Do not remove
+ the LHS of allocation stmts.
+
2012-01-03 Olivier Hainque <hainque@adacore.com>
* system.h: Prior to #define, #undef fopen and freopen unconditionally.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6185d58..195630c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2012-01-03 Richard Guenther <rguenther@suse.de>
+ PR tree-optimization/51692
+ * gcc.dg/torture/pr51692.c: New testcase.
+
+2012-01-03 Richard Guenther <rguenther@suse.de>
+
PR debug/51650
* g++.dg/lto/pr51650-3_0.C: New testcase.
diff --git a/gcc/testsuite/gcc.dg/torture/pr51692.c b/gcc/testsuite/gcc.dg/torture/pr51692.c
new file mode 100644
index 0000000..34a81c2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr51692.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+int
+main ()
+{
+ volatile double d = 0.0;
+ double *p = __builtin_calloc (1, sizeof (double));
+ d += 1.0;
+ *p += 2.0;
+ __builtin_free (p);
+ return 0;
+}
+
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index a710de6..ccdf14a 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -1329,31 +1329,38 @@ eliminate_unnecessary_stmts (void)
}
else if (is_gimple_call (stmt))
{
- call = gimple_call_fndecl (stmt);
- if (call)
+ tree name = gimple_call_lhs (stmt);
+
+ notice_special_calls (stmt);
+
+ /* When LHS of var = call (); is dead, simplify it into
+ call (); saving one operand. */
+ if (name
+ && TREE_CODE (name) == SSA_NAME
+ && !TEST_BIT (processed, SSA_NAME_VERSION (name))
+ /* Avoid doing so for allocation calls which we
+ did not mark as necessary, it will confuse the
+ special logic we apply to malloc/free pair removal. */
+ && (!(call = gimple_call_fndecl (stmt))
+ || DECL_BUILT_IN_CLASS (call) != BUILT_IN_NORMAL
+ || (DECL_FUNCTION_CODE (call) != BUILT_IN_MALLOC
+ && DECL_FUNCTION_CODE (call) != BUILT_IN_CALLOC
+ && DECL_FUNCTION_CODE (call) != BUILT_IN_ALLOCA
+ && (DECL_FUNCTION_CODE (call)
+ != BUILT_IN_ALLOCA_WITH_ALIGN))))
{
- tree name;
-
- /* When LHS of var = call (); is dead, simplify it into
- call (); saving one operand. */
- name = gimple_call_lhs (stmt);
- if (name && TREE_CODE (name) == SSA_NAME
- && !TEST_BIT (processed, SSA_NAME_VERSION (name)))
+ something_changed = true;
+ if (dump_file && (dump_flags & TDF_DETAILS))
{
- something_changed = true;
- if (dump_file && (dump_flags & TDF_DETAILS))
- {
- fprintf (dump_file, "Deleting LHS of call: ");
- print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
- fprintf (dump_file, "\n");
- }
-
- gimple_call_set_lhs (stmt, NULL_TREE);
- maybe_clean_or_replace_eh_stmt (stmt, stmt);
- update_stmt (stmt);
- release_ssa_name (name);
+ fprintf (dump_file, "Deleting LHS of call: ");
+ print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
+ fprintf (dump_file, "\n");
}
- notice_special_calls (stmt);
+
+ gimple_call_set_lhs (stmt, NULL_TREE);
+ maybe_clean_or_replace_eh_stmt (stmt, stmt);
+ update_stmt (stmt);
+ release_ssa_name (name);
}
}
}