re PR tree-optimization/51481 (ice: dead STMT in EH table)

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.

	* gcc.dg/pr51481.c: New test.

From-SVN: r182264
This commit is contained in:
Jakub Jelinek 2011-12-12 21:59:28 +01:00 committed by Jakub Jelinek
parent 9c3b03463a
commit c88388e674
4 changed files with 57 additions and 1 deletions

View File

@ -1,3 +1,10 @@
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

View File

@ -1117,10 +1117,21 @@ gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace)
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;
}
}

View File

@ -1,3 +1,8 @@
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

View File

@ -0,0 +1,33 @@
/* 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);
}