re PR middle-end/53850 (ICE: in expand_call_tm, at trans-mem.c:2289 with -fgnu-tm -O3)

PR middle-end/53850
	* trans-mem.c (expand_call_tm): Handle late built built-ins.

From-SVN: r191742
This commit is contained in:
Aldy Hernandez 2012-09-25 18:47:35 +00:00 committed by Aldy Hernandez
parent 5139232eef
commit 91cad09b08
3 changed files with 45 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2012-09-25 Aldy Hernandez <aldyh@redhat.com>
PR middle-end/53850
* trans-mem.c (expand_call_tm): Handle late built built-ins.
2012-09-25 Georg-Johann Lay <avr@gjlay.de>
PR other/54701

View File

@ -0,0 +1,15 @@
/* { dg-do compile } */
/* { dg-options "-fgnu-tm -O3" } */
unsigned char pp[100];
void
foo (void)
{
int i;
__transaction_atomic
{
for (i = 0; i < 100; ++i)
pp[i] = 0x33;
}
}

View File

@ -2296,8 +2296,31 @@ expand_call_tm (struct tm_region *region,
}
node = cgraph_get_node (fn_decl);
/* All calls should have cgraph here. */
gcc_assert (node);
/* All calls should have cgraph here. */
if (!node)
{
/* We can have a nodeless call here if some pass after IPA-tm
added uninstrumented calls. For example, loop distribution
can transform certain loop constructs into __builtin_mem*
calls. In this case, see if we have a suitable TM
replacement and fill in the gaps. */
gcc_assert (DECL_BUILT_IN_CLASS (fn_decl) == BUILT_IN_NORMAL);
enum built_in_function code = DECL_FUNCTION_CODE (fn_decl);
gcc_assert (code == BUILT_IN_MEMCPY
|| code == BUILT_IN_MEMMOVE
|| code == BUILT_IN_MEMSET);
tree repl = find_tm_replacement_function (fn_decl);
if (repl)
{
gimple_call_set_fndecl (stmt, repl);
update_stmt (stmt);
node = cgraph_create_node (repl);
node->local.tm_may_enter_irr = false;
return expand_call_tm (region, gsi);
}
gcc_unreachable ();
}
if (node->local.tm_may_enter_irr)
transaction_subcode_ior (region, GTMA_MAY_ENTER_IRREVOCABLE);