As discussed on the "RFC: questions on store data race" thread. This patch increases the granularity of transactionness from the gimple statement to the basic block containing it.

Pre-approved and committed.

Tested on x86-64 Linux.

Thanks.
        * gimple.h (gimple_set_in_transaction): Remove.
        (gimple_in_transaction): Look in BB instead.
        (gimple_statement_base): Remove in_transaction field.
        * basic-block.h (enum bb_flags): Add BB_IN_TRANSACTION.
        * trans-mem.c (compute_transaction_bits): Place transaction bit
        information into basic blocks.

Index: gimple.h
===================================================================
--- gimple.h    (revision 187728)
+++ gimple.h    (working copy)
@@ -179,11 +179,6 @@ struct GTY(()) gimple_statement_base {
   /* Nonzero if this statement contains volatile operands.  */
   unsigned has_volatile_ops    : 1;
 
-  /* Nonzero if this statement appears inside a transaction.  This bit
-     is calculated on de-mand and has relevant information only after
-     it has been calculated with compute_transaction_bits.  */
-  unsigned in_transaction      : 1;
-
   /* The SUBCODE field can be used for tuple-specific flags for tuples
      that do not require subcodes.  Note that SUBCODE should be at
      least as wide as tree codes, as several tuples store tree codes
@@ -1598,15 +1593,7 @@ gimple_set_has_volatile_ops (gimple stmt
 static inline bool
 gimple_in_transaction (gimple stmt)
 {
-  return stmt->gsbase.in_transaction;
-}
-
-/* Set the IN_TRANSACTION flag to TRANSACTIONP.  */
-
-static inline void
-gimple_set_in_transaction (gimple stmt, bool transactionp)
-{
-  stmt->gsbase.in_transaction = (unsigned) transactionp;
+  return gimple_bb (stmt)->flags & BB_IN_TRANSACTION;
 }
 
 /* Return true if statement STMT may access memory.  */
Index: trans-mem.c
===================================================================
--- trans-mem.c (revision 187728)
+++ trans-mem.c (working copy)
@@ -2451,13 +2451,15 @@ compute_transaction_bits (void)
   struct tm_region *region;
   VEC (basic_block, heap) *queue;
   unsigned int i;
-  gimple_stmt_iterator gsi;
   basic_block bb;
 
   /* ?? Perhaps we need to abstract gate_tm_init further, because we
      certainly don't need it to calculate CDI_DOMINATOR info.  */
   gate_tm_init ();
 
+  FOR_EACH_BB (bb)
+    bb->flags &= ~BB_IN_TRANSACTION;
+
   for (region = all_tm_regions; region; region = region->next)
     {
       queue = get_tm_region_blocks (region->entry_block,
@@ -2466,11 +2468,7 @@ compute_transaction_bits (void)
                                    NULL,
                                    /*stop_at_irr_p=*/true);
       for (i = 0; VEC_iterate (basic_block, queue, i, bb); ++i)
-       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
-         {
-           gimple stmt = gsi_stmt (gsi);
-           gimple_set_in_transaction (stmt, true);
-         }
+       bb->flags |= BB_IN_TRANSACTION;
       VEC_free (basic_block, heap, queue);
     }
 
Index: basic-block.h
===================================================================
--- basic-block.h       (revision 187728)
+++ basic-block.h       (working copy)
@@ -263,7 +263,12 @@ enum bb_flags
   BB_MODIFIED = 1 << 12,
 
   /* A general visited flag for passes to use.  */
-  BB_VISITED = 1 << 13
+  BB_VISITED = 1 << 13,
+
+  /* Set on blocks that are in a transaction.  This is calculated on
+     demand, and is available after calling
+     compute_transaction_bits().  */
+  BB_IN_TRANSACTION = 1 << 14
 };
 
 /* Dummy flag for convenience in the hot/cold partitioning code.  */

Reply via email to