* [trans-mem] fix gettmclone buglet
@ 2009-10-13 21:39 Aldy Hernandez
2009-10-13 21:51 ` Richard Henderson
0 siblings, 1 reply; 2+ messages in thread
From: Aldy Hernandez @ 2009-10-13 21:39 UTC (permalink / raw)
To: rth, gcc-patches; +Cc: dnovillo
Hi folks.
As discussed on off-list.
tm_gettmclone*() returns a void *, but we use the result as a function
pointer. This causes PRE to ice. Fixed by inserting the appropriate
cast before dereferencing as a function pointer.
OK for branch?
p.s. Thanks guys.
* trans-mem.c (ipa_tm_insert_gettmclone_call): Cast return value
from gettmclone.
Index: testsuite/gcc.dg/tm/20091013.c
===================================================================
--- testsuite/gcc.dg/tm/20091013.c (revision 0)
+++ testsuite/gcc.dg/tm/20091013.c (revision 0)
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm -O2" } */
+
+extern long ringo(long int);
+int g,i;
+
+f()
+{
+ __tm_atomic {
+ for (i=0; i < 10; ++i)
+ ringo(g);
+ }
+}
Index: trans-mem.c
===================================================================
--- trans-mem.c (revision 152675)
+++ trans-mem.c (working copy)
@@ -2803,8 +2803,8 @@ ipa_tm_insert_gettmclone_call (struct cg
struct tm_region *region,
gimple_stmt_iterator *gsi, gimple stmt)
{
- tree gettm_fn, ret, old_fn;
- gimple g;
+ tree gettm_fn, ret, old_fn, callfn;
+ gimple g, g2;
bool safe;
old_fn = gimple_call_fn (stmt);
@@ -2812,7 +2812,7 @@ ipa_tm_insert_gettmclone_call (struct cg
safe = is_tm_safe (TREE_TYPE (old_fn));
gettm_fn = built_in_decls[safe ? BUILT_IN_TM_GETTMCLONE_SAFE
: BUILT_IN_TM_GETTMCLONE_IRR];
- ret = create_tmp_var (TREE_TYPE (old_fn), NULL);
+ ret = create_tmp_var (ptr_type_node, NULL);
add_referenced_var (ret);
if (!safe)
@@ -2842,6 +2842,16 @@ ipa_tm_insert_gettmclone_call (struct cg
cgraph_create_edge (node, cgraph_node (gettm_fn), g, 0, 0, 0);
+ /* Cast return value from tm_gettmclone* into appropriate function
+ pointer. */
+ callfn = create_tmp_var (TREE_TYPE (old_fn), NULL);
+ add_referenced_var (callfn);
+ g2 = gimple_build_assign (callfn,
+ fold_build1 (NOP_EXPR, TREE_TYPE (callfn), ret));
+ callfn = make_ssa_name (callfn, g2);
+ gimple_assign_set_lhs (g2, callfn);
+ gsi_insert_before (gsi, g2, GSI_SAME_STMT);
+
/* ??? This is a hack to preserve the NOTHROW bit on the call,
which we would have derived from the decl. Failure to save
this bit means we might have to split the basic block. */
@@ -2854,7 +2864,7 @@ ipa_tm_insert_gettmclone_call (struct cg
and thus requiring extra EH edges. */
gimple_call_set_noinline_p (stmt);
- gimple_call_set_fn (stmt, ret);
+ gimple_call_set_fn (stmt, callfn);
update_stmt (stmt);
return safe;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [trans-mem] fix gettmclone buglet
2009-10-13 21:39 [trans-mem] fix gettmclone buglet Aldy Hernandez
@ 2009-10-13 21:51 ` Richard Henderson
0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2009-10-13 21:51 UTC (permalink / raw)
To: Aldy Hernandez; +Cc: gcc-patches, dnovillo
On 10/13/2009 02:27 PM, Aldy Hernandez wrote:
> * trans-mem.c (ipa_tm_insert_gettmclone_call): Cast return value
> from gettmclone.
Ok.
r~
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-10-13 21:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-13 21:39 [trans-mem] fix gettmclone buglet Aldy Hernandez
2009-10-13 21:51 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).