This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [trans-mem] fix irrevocable CFG problems


Richard Henderson <rth@redhat.com> writes:

> On 07/22/2009 11:37 AM, Aldy Hernandez wrote:
>> The test below causes a CFG inconsistensy ("control flow in the middle
>> of basic block") which this patch fixes.
>>
>> Calls to TM_IRREVOKABLE are considered control altering, so they cannot
>> exist in the middle of a basic block.  I have fixed this by putting
>> TM_IRREVOKABLE in a separate basic block.
>>
>> Regtested for C on x86-64 Linux.
>>
>> OK for branch?
>
> Ok.
>
>> p.s. Yes, irrevocable is spelled wrong everywhere.  Let's see who gets
>> frustrated first and fixes it :)
>
> That'll probably be you; I didn't notice.  =)
>
>
> r~

I forgot to CC gcc-patches.  Here is my original post.  The patch has
been committed.

-----------------

The test below causes a CFG inconsistensy ("control flow in the middle
of basic block") which this patch fixes.

Calls to TM_IRREVOKABLE are considered control altering, so they cannot
exist in the middle of a basic block.  I have fixed this by putting
TM_IRREVOKABLE in a separate basic block.

Regtested for C on x86-64 Linux.

OK for branch?

p.s. Yes, irrevocable is spelled wrong everywhere.  Let's see who gets
frustrated first and fixes it :)

	* trans-mem.c (ipa_tm_insert_irr_call): Make a new block for
	TM_IRREVOKABLE calls.
	(pass_ipa_tm): Enable dump.

Index: testsuite/gcc.dg/tm/irrevocable-1.c
===================================================================
--- testsuite/gcc.dg/tm/irrevocable-1.c	(revision 0)
+++ testsuite/gcc.dg/tm/irrevocable-1.c	(revision 0)
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm -O" } */
+
+int global;
+int george;
+
+extern crap() __attribute__((tm_irrevokable));
+
+foo()
+{
+	__tm_atomic {
+		global++;
+		crap();
+		george++;
+	}
+}
Index: trans-mem.c
===================================================================
--- trans-mem.c	(revision 149754)
+++ trans-mem.c	(working copy)
@@ -2009,12 +2009,14 @@ ipa_tm_insert_irr_call (struct cgraph_no
 {
   gimple_stmt_iterator gsi;
   gimple g;
+  edge e;
 
   tm_atomic_subcode_ior (region, GTMA_HAVE_CALL_IRREVOKABLE);
 
   g = gimple_build_call (built_in_decls[BUILT_IN_TM_IRREVOKABLE], 0);
   add_stmt_to_tm_region (region, g);
 
+  e = split_block_after_labels (bb);
   gsi = gsi_after_labels (bb);
   gsi_insert_before (&gsi, g, GSI_SAME_STMT);
 
@@ -2396,6 +2398,6 @@ struct simple_ipa_opt_pass pass_ipa_tm =
   0,			                /* properties_provided */
   0,					/* properties_destroyed */
   0,					/* todo_flags_start */
-  0,					/* todo_flags_finish */
+  TODO_dump_func,			/* todo_flags_finish */
  },
 };


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]