diff mbox

[trans-mem] COMMITTED: propagate irrevocability in the presence of EXIT_BLOCKs correctly

Message ID 4D46F16D.7040703@redhat.com
State New
Headers show

Commit Message

Aldy Hernandez Jan. 31, 2011, 5:29 p.m. UTC
Currently we are getting confused when examining an EXIT_BLOCK in 
ipa_tm_propagate_irr(), because we assume for any given BB that all 
children are irrevocable unless we can prove otherwise.  However, if we 
have no successors (e.g. an EXIT_BLOCK), we end up assuming all children 
are irrevocable, so the EXIT_BLOCK must be irrevocable as well.

I believe this is an obvious patch and am committing as such.  Please 
feel free to contradict me, if I am wrong.

This patch fixes the ICE in PR/47340.
* trans-mem.c (ipa_tm_propagate_irr): Handle exit blocks.

Comments

Richard Henderson Feb. 1, 2011, 4:34 p.m. UTC | #1
On 01/31/2011 09:29 AM, Aldy Hernandez wrote:
> Currently we are getting confused when examining an EXIT_BLOCK in
> ipa_tm_propagate_irr(), because we assume for any given BB that all
> children are irrevocable unless we can prove otherwise.  However, if
> we have no successors (e.g. an EXIT_BLOCK), we end up assuming all
> children are irrevocable, so the EXIT_BLOCK must be irrevocable as
> well.

Gah, thanks.


r~
diff mbox

Patch

Index: testsuite/gcc.dg/tm/pr47520.c
===================================================================
--- testsuite/gcc.dg/tm/pr47520.c	(revision 0)
+++ testsuite/gcc.dg/tm/pr47520.c	(revision 0)
@@ -0,0 +1,29 @@ 
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm -O" } */
+
+struct ReadSeqVars
+{
+        int format;
+        char *ss;
+};
+
+void rms_feof(struct ReadSeqVars *);
+
+__attribute__((transaction_callable)) int ReadSeq(struct ReadSeqVars *V)
+{
+        if (V->format > 1)
+        {
+                if ((V->format != 2) && (V->ss != (void*)0) )
+                {
+                        V->format = 3;
+                }
+        }
+        else
+        {
+                int i = 0;
+                for (i = 0; i < 1; i++)
+                {
+                }
+                rms_feof(V);
+        }
+}
Index: trans-mem.c
===================================================================
--- trans-mem.c	(revision 169292)
+++ trans-mem.c	(working copy)
@@ -3656,7 +3656,7 @@  ipa_tm_scan_irr_blocks (VEC (basic_block
 
 /* Propagate the irrevocable property both up and down the dominator tree.
    BB is the current block being scanned; EXIT_BLOCKS are the edges of the
-   TM regions; OLD_IRR is the results of a previous scan of the dominator
+   TM regions; OLD_IRR are the results of a previous scan of the dominator
    tree which has been fully propagated; NEW_IRR is the set of new blocks
    which are gaining the irrevocable property during the current scan.  */
 
@@ -3675,19 +3675,24 @@  ipa_tm_propagate_irr (basic_block entry_
     {
       basic_block bb = VEC_pop (basic_block, bbs);
       bool this_irr = bitmap_bit_p (new_irr, bb->index);
-      bool all_son_irr = true;
+      bool all_son_irr = false;
       edge_iterator ei;
       edge e;
 
-      /* Propagate up.  If my children are, I am too.  */
+      /* Propagate up.  If my children are, I am too, but we must have
+	 at least one child that is.  */
       if (!this_irr)
 	{
 	  FOR_EACH_EDGE (e, ei, bb->succs)
-	    if (!bitmap_bit_p (new_irr, e->dest->index))
-	      {
-		all_son_irr = false;
-		break;
-	      }
+	    {
+	      if (!bitmap_bit_p (new_irr, e->dest->index))
+		{
+		  all_son_irr = false;
+		  break;
+		}
+	      else
+		all_son_irr = true;
+	    }
 	  if (all_son_irr)
 	    {
 	      bitmap_set_bit (new_irr, bb->index);