re PR tree-optimization/47141 (segfault)

* PR tree-optimization/47141
	* ipa-split.c (split_function): Handle case where we are returning a
	value and the return block has a virtual operand phi.

	* gcc.c-torture/compile/pr47141.c: New test.

Approved by richie in IRC

From-SVN: r168634
This commit is contained in:
Jeff Law 2011-01-10 09:48:42 -07:00 committed by Jeff Law
parent cf9712ccc0
commit 2e5e346da2
4 changed files with 45 additions and 7 deletions

View File

@ -1,3 +1,9 @@
2011-01-10 Jeff Law <law@redhat.com>
* PR tree-optimization/47141
* ipa-split.c (split_function): Handle case where we are
returning a value and the return block has a virtual operand phi.
2011-01-10 Jan Hubicka <jh@suse.cz>
PR tree-optimization/47234

View File

@ -1016,20 +1016,31 @@ split_function (struct split_point *split_point)
e->probability = REG_BR_PROB_BASE;
e->count = new_return_bb->count;
bitmap_set_bit (split_point->split_bbs, new_return_bb->index);
/* We change CFG in a way tree-inline is not able to compensate on while
updating PHIs. There are only virtuals in return_bb, so recompute
them. */
}
/* When we pass around the value, use existing return block. */
else
bitmap_set_bit (split_point->split_bbs, return_bb->index);
/* If RETURN_BB has virtual operand PHIs, they must be removed and the
virtual operand marked for renaming as we change the CFG in a way that
tree-inline is not able to compensate for.
Note this can happen whether or not we have a return value. If we have
a return value, then RETURN_BB may have PHIs for real operands too. */
if (return_bb != EXIT_BLOCK_PTR)
{
for (gsi = gsi_start_phis (return_bb); !gsi_end_p (gsi);)
{
gimple stmt = gsi_stmt (gsi);
gcc_assert (!is_gimple_reg (gimple_phi_result (stmt)));
if (is_gimple_reg (gimple_phi_result (stmt)))
{
gsi_next (&gsi);
continue;
}
mark_virtual_phi_result_for_renaming (stmt);
remove_phi_node (&gsi, true);
}
}
/* When we pass aorund the value, use existing return block. */
else
bitmap_set_bit (split_point->split_bbs, return_bb->index);
/* Now create the actual clone. */
rebuild_cgraph_edges ();

View File

@ -1,3 +1,8 @@
2011-01-10 Jeff Law <law@redhat.com>
* PR tree-optimization/47141
* gcc.c-torture/compile/pr47141.c: New test.
2011-01-10 Eric Botcazou <ebotcazou@adacore.com>
PR testsuite/46230

View File

@ -0,0 +1,16 @@
int
foo (__UINTPTR_TYPE__ x)
{
int a = 6;
int *b = &a;
if (x)
for (a = 0; a; a++)
;
return a;
}
void
bar (void)
{
foo ((__UINTPTR_TYPE__) foo);
}