mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-02 05:40:26 +08:00
re PR middle-end/37356 (ICE in gsi_insert_seq_nodes_after, at gimple-iterator.c:222)
PR middle-end/37356 * tree-inline.c (copy_bb): Insert stmt into copy_basic_block before calling gimple_regimplify_operands on it. Iterate over all newly added statements, not just the last one. (insert_init_stmt): Insert stmt into seq first, then call gimple_regimplify_operands on it. Don't create new gimplification context, nor find referenced vars. * g++.dg/tree-ssa/pr37356.C: New test. Co-Authored-By: Jan Hubicka <jh@suse.cz> From-SVN: r140177
This commit is contained in:
parent
18802917af
commit
c2a4718a14
@ -1,3 +1,14 @@
|
||||
2008-09-09 Jakub Jelinek <jakub@redhat.com>
|
||||
Jan Hubicka <jh@suse.cz>
|
||||
|
||||
PR middle-end/37356
|
||||
* tree-inline.c (copy_bb): Insert stmt into copy_basic_block before
|
||||
calling gimple_regimplify_operands on it. Iterate over all newly
|
||||
added statements, not just the last one.
|
||||
(insert_init_stmt): Insert stmt into seq first, then call
|
||||
gimple_regimplify_operands on it. Don't create new gimplification
|
||||
context, nor find referenced vars.
|
||||
|
||||
2008-09-09 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR other/37419
|
||||
|
@ -1,5 +1,8 @@
|
||||
2008-09-09 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR middle-end/37356
|
||||
* g++.dg/tree-ssa/pr37356.C: New test.
|
||||
|
||||
PR target/37438
|
||||
* gcc.dg/pr37438.c: New test.
|
||||
|
||||
|
34
gcc/testsuite/g++.dg/tree-ssa/pr37356.C
Normal file
34
gcc/testsuite/g++.dg/tree-ssa/pr37356.C
Normal file
@ -0,0 +1,34 @@
|
||||
// PR middle-end/37356 */
|
||||
// { dg-do compile }
|
||||
// { dg-options "-O" }
|
||||
|
||||
bool foo ();
|
||||
int bar ();
|
||||
|
||||
bool
|
||||
baz (int v)
|
||||
{
|
||||
return v == bar ();
|
||||
}
|
||||
|
||||
struct A
|
||||
{
|
||||
A () { baz (1) || foo (); }
|
||||
};
|
||||
|
||||
struct B
|
||||
{
|
||||
static A get () { return A (); }
|
||||
B (const int &x) { }
|
||||
B () : b (get ()) { }
|
||||
A b;
|
||||
};
|
||||
|
||||
B c;
|
||||
|
||||
void
|
||||
test ()
|
||||
{
|
||||
int d;
|
||||
c = d;
|
||||
}
|
@ -1232,7 +1232,7 @@ static basic_block
|
||||
copy_bb (copy_body_data *id, basic_block bb, int frequency_scale,
|
||||
gcov_type count_scale)
|
||||
{
|
||||
gimple_stmt_iterator gsi, copy_gsi;
|
||||
gimple_stmt_iterator gsi, copy_gsi, seq_gsi;
|
||||
basic_block copy_basic_block;
|
||||
tree decl;
|
||||
|
||||
@ -1263,6 +1263,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale,
|
||||
continue;
|
||||
|
||||
gimple_duplicate_stmt_histograms (cfun, stmt, id->src_cfun, orig_stmt);
|
||||
seq_gsi = copy_gsi;
|
||||
|
||||
/* With return slot optimization we can end up with
|
||||
non-gimple (foo *)&this->m, fix that here. */
|
||||
@ -1271,21 +1272,31 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale,
|
||||
&& !is_gimple_val (gimple_assign_rhs1 (stmt)))
|
||||
{
|
||||
tree new_rhs;
|
||||
new_rhs = force_gimple_operand_gsi (©_gsi,
|
||||
new_rhs = force_gimple_operand_gsi (&seq_gsi,
|
||||
gimple_assign_rhs1 (stmt),
|
||||
true, NULL, true, GSI_SAME_STMT);
|
||||
gimple_assign_set_rhs1 (stmt, new_rhs);
|
||||
id->regimplify = false;
|
||||
}
|
||||
else if (id->regimplify)
|
||||
gimple_regimplify_operands (stmt, ©_gsi);
|
||||
|
||||
gsi_insert_after (©_gsi, stmt, GSI_NEW_STMT);
|
||||
gsi_insert_after (&seq_gsi, stmt, GSI_NEW_STMT);
|
||||
|
||||
if (id->regimplify)
|
||||
gimple_regimplify_operands (stmt, &seq_gsi);
|
||||
|
||||
/* If copy_basic_block has been empty at the start of this iteration,
|
||||
call gsi_start_bb again to get at the newly added statements. */
|
||||
if (gsi_end_p (copy_gsi))
|
||||
copy_gsi = gsi_start_bb (copy_basic_block);
|
||||
else
|
||||
gsi_next (©_gsi);
|
||||
|
||||
/* Process the new statement. The call to gimple_regimplify_operands
|
||||
possibly turned the statement into multiple statements, we
|
||||
need to process all of them. */
|
||||
while (!gsi_end_p (copy_gsi))
|
||||
do
|
||||
{
|
||||
stmt = gsi_stmt (copy_gsi);
|
||||
if (is_gimple_call (stmt)
|
||||
&& gimple_call_va_arg_pack_p (stmt)
|
||||
&& id->gimple_call)
|
||||
@ -1459,6 +1470,7 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale,
|
||||
|
||||
gsi_next (©_gsi);
|
||||
}
|
||||
while (!gsi_end_p (copy_gsi));
|
||||
|
||||
copy_gsi = gsi_last_bb (copy_basic_block);
|
||||
}
|
||||
@ -1889,40 +1901,16 @@ self_inlining_addr_expr (tree value, tree fn)
|
||||
static void
|
||||
insert_init_stmt (basic_block bb, gimple init_stmt)
|
||||
{
|
||||
gimple_stmt_iterator si = gsi_last_bb (bb);
|
||||
gimple_stmt_iterator i;
|
||||
gimple_seq seq = gimple_seq_alloc ();
|
||||
struct gimplify_ctx gctx;
|
||||
|
||||
push_gimplify_context (&gctx);
|
||||
|
||||
i = gsi_start (seq);
|
||||
gimple_regimplify_operands (init_stmt, &i);
|
||||
|
||||
if (init_stmt
|
||||
&& !gimple_seq_empty_p (seq))
|
||||
{
|
||||
/* The replacement can expose previously unreferenced
|
||||
variables. */
|
||||
if (gimple_in_ssa_p (cfun))
|
||||
for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
|
||||
find_new_referenced_vars (gsi_stmt (i));
|
||||
|
||||
/* Insert the gimplified sequence needed for INIT_STMT
|
||||
after SI. INIT_STMT will be inserted after SEQ. */
|
||||
gsi_insert_seq_after (&si, seq, GSI_NEW_STMT);
|
||||
}
|
||||
|
||||
pop_gimplify_context (NULL);
|
||||
|
||||
/* If VAR represents a zero-sized variable, it's possible that the
|
||||
assignment statement may result in no gimple statements. */
|
||||
if (init_stmt)
|
||||
gsi_insert_after (&si, init_stmt, GSI_NEW_STMT);
|
||||
{
|
||||
gimple_stmt_iterator si = gsi_last_bb (bb);
|
||||
|
||||
if (gimple_in_ssa_p (cfun))
|
||||
for (;!gsi_end_p (si); gsi_next (&si))
|
||||
mark_symbols_for_renaming (gsi_stmt (si));
|
||||
gsi_insert_after (&si, init_stmt, GSI_NEW_STMT);
|
||||
gimple_regimplify_operands (init_stmt, &si);
|
||||
mark_symbols_for_renaming (init_stmt);
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize parameter P with VALUE. If needed, produce init statement
|
||||
|
Loading…
x
Reference in New Issue
Block a user