* gimple-fold.c (gimple_fold_call): Call
maybe_clean_or_replace_eh_stmt. Avoid optimization if stmt has EH
edges, but gimple_fold_builtin result can't throw.
* gcc.dg/pr51481.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182264
138bc75d-0d04-0410-961f-
82ee72b054a4
+2011-12-12 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/51481
+ * gimple-fold.c (gimple_fold_call): Call
+ maybe_clean_or_replace_eh_stmt. Avoid optimization if stmt has EH
+ edges, but gimple_fold_builtin result can't throw.
+
2011-12-12 Vladimir Makarov <vmakarov@redhat.com>
PR rtl-optimization/21617
if (callee && DECL_BUILT_IN (callee))
{
tree result = gimple_fold_builtin (stmt);
- if (result)
+ if (result
+ /* Disallow EH edge removal here. We can't call
+ gimple_purge_dead_eh_edges here. */
+ && (lookup_stmt_eh_lp (stmt) == 0
+ || tree_could_throw_p (result)))
{
if (!update_call_from_tree (gsi, result))
gimplify_and_update_call_from_tree (gsi, result);
+ if (!gsi_end_p (*gsi))
+ {
+ gimple new_stmt = gsi_stmt (*gsi);
+ bool update_eh ATTRIBUTE_UNUSED
+ = maybe_clean_or_replace_eh_stmt (stmt, new_stmt);
+ gcc_assert (!update_eh);
+ }
changed = true;
}
}
+2011-12-12 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/51481
+ * gcc.dg/pr51481.c: New test.
+
2011-12-12 Georg-Johann Lay <avr@gjlay.de>
PR tree-optimization/45830
--- /dev/null
+/* PR tree-optimization/51481 */
+/* { dg-do compile } */
+/* { dg-options "-O -fexceptions -fipa-cp -fipa-cp-clone" } */
+
+extern const unsigned short int **foo (void)
+ __attribute__ ((__nothrow__, __const__));
+struct S { unsigned short s1; int s2; };
+extern struct S *s[26];
+
+void
+bar (int x, struct S *y, ...)
+{
+ static struct S *t;
+ __builtin_va_list ap;
+ __builtin_va_start (ap, y);
+ if (t != s[7])
+ {
+ const char *p = "aAbBc";
+ t = s[7];
+ while ((*foo ())[(unsigned char) *p])
+ p++;
+ }
+ __builtin_printf (x == 0 ? "abc\n" : "def\n");
+ if (y != 0)
+ __builtin_printf ("ghi %d %d", y->s2, y->s1);
+ __builtin_va_end (ap);
+}
+
+void
+baz (char *x)
+{
+ bar (1, 0, x);
+}