Message ID | 4F2820C9.7020009@gmail.com |
---|---|
State | New |
Headers | show |
On Tue, Jan 31, 2012 at 6:11 PM, Patrick Marlier <patrick.marlier@gmail.com> wrote: > In the PR testcase, a call to __builtin_prefetch is done. When this function > call comes into expand_call_tm, there is no cgraph_node associated for this > builtin and thus node->local fails. > > trans-mem.c (expand_call_tm): > ... > node = cgraph_get_node (fn_decl); > if (node->local.tm_may_enter_irr) > transaction_subcode_ior (region, GTMA_MAY_ENTER_IRREVOCABLE); > ... > > The attached patch adds a check for non-NULL node. I have added the testcase > but I don't know if it is relevant. > > Currently bootstrapping on i686-pc-linux-gnu. Tested on i686-pc-linux-gnu. > > OK? The patch looks ok, but I'm not sure why you do not get a cgraph node here - cgraph doesn't really care for builtins as far as I can see. Honza? Don't you maybe want to handle builtins in a special way here? At least those that are const/pure? Richard. > (I am almost sure I already proposed this modification few time ago but it > have been lost somewhere.) > -- > Patrick. > > 2012-01-31 Patrick Marlier <patrick.marlier@gmail.com> > > PR middle-end/52047 > * trans-mem.c (expand_call_tm): Dereference node only if > non-NULL.
Index: trans-mem.c =================================================================== --- trans-mem.c (revision 183736) +++ trans-mem.c (working copy) @@ -1,5 +1,5 @@ /* Passes for transactional memory support. - Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This file is part of GCC. @@ -2267,7 +2267,7 @@ expand_call_tm (struct tm_region *region, } node = cgraph_get_node (fn_decl); - if (node->local.tm_may_enter_irr) + if (node && node->local.tm_may_enter_irr) transaction_subcode_ior (region, GTMA_MAY_ENTER_IRREVOCABLE); if (is_tm_abort (fn_decl)) Index: testsuite/gcc.dg/tm/pr52047.c =================================================================== --- testsuite/gcc.dg/tm/pr52047.c (revision 0) +++ testsuite/gcc.dg/tm/pr52047.c (revision 0) @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fgnu-tm -fprefetch-loop-arrays -w" } */ + +int test2 (int x[]) +{ + return x[12]; +} + +int test1 (void) +{ + int x[1000], i; + for (i = 0; i < 1000; i++) + x[i] = i; + return test2 (x); +} + +int +main () +{ + __transaction_atomic + { + if (test1 ()) + __transaction_cancel; + } + return 0; +}