public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5001] Fix spurious valgrind errors in irred loop verification
@ 2021-11-08 15:19 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-11-08 15:19 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d626fe77cdc40de0ae1651c8b94090eea73a719f

commit r12-5001-gd626fe77cdc40de0ae1651c8b94090eea73a719f
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Nov 8 15:21:08 2021 +0100

    Fix spurious valgrind errors in irred loop verification
    
    The sbitmap bitmap_{set,clear}_bit changes trigger spurious
    uninit value use reportings from valgrind since we now
    read the old value before setting/clearing a bit so
    verify_loop_structures optimization to not clear the sbitmap is reported.
    
    Fixed by using a temporary BB flag which should also be more
    efficient in terms of cache re-use.
    
    2021-11-08  Richard Biener  <rguenther@suse.de>
    
            * cfgloop.c (verify_loop_structure): Use a temporary BB flag
            instead of an sbitmap to cache irreducible state.

Diff:
---
 gcc/cfgloop.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c
index 2ba9918bfa2..20c24c13c36 100644
--- a/gcc/cfgloop.c
+++ b/gcc/cfgloop.c
@@ -1567,19 +1567,17 @@ verify_loop_structure (void)
   /* Check irreducible loops.  */
   if (loops_state_satisfies_p (LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS))
     {
-      auto_edge_flag saved_irr_mask (cfun);
-      /* Record old info.  */
-      auto_sbitmap irreds (last_basic_block_for_fn (cfun));
+      auto_edge_flag saved_edge_irr (cfun);
+      auto_bb_flag saved_bb_irr (cfun);
+      /* Save old info.  */
       FOR_EACH_BB_FN (bb, cfun)
 	{
 	  edge_iterator ei;
 	  if (bb->flags & BB_IRREDUCIBLE_LOOP)
-	    bitmap_set_bit (irreds, bb->index);
-	  else
-	    bitmap_clear_bit (irreds, bb->index);
+	    bb->flags |= saved_bb_irr;
 	  FOR_EACH_EDGE (e, ei, bb->succs)
 	    if (e->flags & EDGE_IRREDUCIBLE_LOOP)
-	      e->flags |= saved_irr_mask;
+	      e->flags |= saved_edge_irr;
 	}
 
       /* Recount it.  */
@@ -1591,34 +1589,35 @@ verify_loop_structure (void)
 	  edge_iterator ei;
 
 	  if ((bb->flags & BB_IRREDUCIBLE_LOOP)
-	      && !bitmap_bit_p (irreds, bb->index))
+	      && !(bb->flags & saved_bb_irr))
 	    {
 	      error ("basic block %d should be marked irreducible", bb->index);
 	      err = 1;
 	    }
 	  else if (!(bb->flags & BB_IRREDUCIBLE_LOOP)
-	      && bitmap_bit_p (irreds, bb->index))
+		   && (bb->flags & saved_bb_irr))
 	    {
 	      error ("basic block %d should not be marked irreducible", bb->index);
 	      err = 1;
 	    }
+	  bb->flags &= ~saved_bb_irr;
 	  FOR_EACH_EDGE (e, ei, bb->succs)
 	    {
 	      if ((e->flags & EDGE_IRREDUCIBLE_LOOP)
-		  && !(e->flags & saved_irr_mask))
+		  && !(e->flags & saved_edge_irr))
 		{
 		  error ("edge from %d to %d should be marked irreducible",
 			 e->src->index, e->dest->index);
 		  err = 1;
 		}
 	      else if (!(e->flags & EDGE_IRREDUCIBLE_LOOP)
-		       && (e->flags & saved_irr_mask))
+		       && (e->flags & saved_edge_irr))
 		{
 		  error ("edge from %d to %d should not be marked irreducible",
 			 e->src->index, e->dest->index);
 		  err = 1;
 		}
-	      e->flags &= ~saved_irr_mask;
+	      e->flags &= ~saved_edge_irr;
 	    }
 	}
     }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-08 15:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-08 15:19 [gcc r12-5001] Fix spurious valgrind errors in irred loop verification Richard Biener

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).