The following patch adds checking to calculate_dominance_info that
if we re-use existing dominance info it is correct (unsurprisingly
this wasn't always the case, noticed when using verify_loop_structure
in random places ...).

Bootstrap and regtest pending on x86_64-unknown-linux-gnu.

Do people think the extra checking is worth its time?  We might
want to drop other explicit calls to verify_dominators (we currently
do not assert we drop post-dom info and nowhere verify post-dom
info for example).

I've been unconditionally checking loop structure and dominator info
if they are available after each pass, from the pass manager
(I think the TODO_verify_* bits are odd, I mean, that passes can
opt-out from being verified ... OTOH between IRA and reload we
have loop info but it breaks (sometimes at least))

Thanks,
Richard.

2012-03-05  Richard Guenther  <rguent...@suse.de>

        * cfgexpand.c (gimple_expand_cfg): Free dominator info.
        * cfgloop.c (verify_loop_structure): Compute dominator info.
        * dominance.c (calculate_dominance_info): If we re-use existing
        computed dominance info, verify if it is correct.
        * tree-if-conv.c (combine_blocks): Free post-dominator info
        after breaking it.
        * tree-parloops.c (create_parallel_loop): Free and re-compute
        dominator info after breaking it.

Index: gcc/cfgexpand.c
===================================================================
*** gcc/cfgexpand.c.orig        2012-02-23 13:24:54.000000000 +0100
--- gcc/cfgexpand.c     2012-02-23 14:16:43.000000000 +0100
*************** gimple_expand_cfg (void)
*** 4362,4367 ****
--- 4369,4376 ----
  
    /* Some backends want to know that we are expanding to RTL.  */
    currently_expanding_to_rtl = 1;
+   /* Dominators are not kept up-to-date as we may create new basic-blocks.  */
+   free_dominance_info (CDI_DOMINATORS);
  
    rtl_profile_for_bb (ENTRY_BLOCK_PTR);
  
Index: gcc/cfgloop.c
===================================================================
*** gcc/cfgloop.c.orig  2012-02-23 13:24:54.000000000 +0100
--- gcc/cfgloop.c       2012-02-23 14:06:15.000000000 +0100
*************** verify_loop_structure (void)
*** 1317,1322 ****
--- 1317,1326 ----
    unsigned num = number_of_loops ();
    loop_iterator li;
    struct loop_exit *exit, *mexit;
+   bool dom_available = dom_info_available_p (CDI_DOMINATORS);
+ 
+   /* Ensure that the dominators are computed.  */
+   calculate_dominance_info (CDI_DOMINATORS);
  
    /* Check sizes.  */
    sizes = XCNEWVEC (unsigned, num);
*************** verify_loop_structure (void)
*** 1560,1565 ****
--- 1572,1579 ----
    gcc_assert (!err);
  
    free (sizes);
+   if (!dom_available)
+     free_dominance_info (CDI_DOMINATORS);
  }
  
  /* Returns latch edge of LOOP.  */
Index: gcc/dominance.c
===================================================================
*** gcc/dominance.c.orig        2012-02-23 13:24:54.000000000 +0100
--- gcc/dominance.c     2012-02-23 14:06:15.000000000 +0100
*************** calculate_dominance_info (enum cdi_direc
*** 639,645 ****
    bool reverse = (dir == CDI_POST_DOMINATORS) ? true : false;
  
    if (dom_computed[dir_index] == DOM_OK)
!     return;
  
    timevar_push (TV_DOMINANCE);
    if (!dom_info_available_p (dir))
--- 639,650 ----
    bool reverse = (dir == CDI_POST_DOMINATORS) ? true : false;
  
    if (dom_computed[dir_index] == DOM_OK)
!     {
! #ifdef ENABLE_CHECKING
!       verify_dominators (dir);
! #endif
!       return;
!     }
  
    timevar_push (TV_DOMINANCE);
    if (!dom_info_available_p (dir))
*************** calculate_dominance_info (enum cdi_direc
*** 667,672 ****
--- 672,681 ----
        free_dom_info (&di);
        dom_computed[dir_index] = DOM_NO_FAST_QUERY;
      }
+ #ifdef ENABLE_CHECKING
+   else
+     verify_dominators (dir);
+ #endif
  
    compute_dom_fast_query (dir);
  
Index: gcc/tree-if-conv.c
===================================================================
*** gcc/tree-if-conv.c.orig     2012-02-23 13:24:54.000000000 +0100
--- gcc/tree-if-conv.c  2012-02-23 14:06:15.000000000 +0100
*************** combine_blocks (struct loop *loop)
*** 1712,1717 ****
--- 1712,1720 ----
  
    free (ifc_bbs);
    ifc_bbs = NULL;
+ 
+   /* Post-dominators are corrupt now.  */
+   free_dominance_info (CDI_POST_DOMINATORS);
  }
  
  /* If-convert LOOP when it is legal.  For the moment this pass has no
Index: gcc/tree-parloops.c
===================================================================
*** gcc/tree-parloops.c.orig    2012-02-23 13:24:54.000000000 +0100
--- gcc/tree-parloops.c 2012-02-23 14:06:15.000000000 +0100
*************** create_parallel_loop (struct loop *loop,
*** 1740,1745 ****
--- 1740,1749 ----
    gimple_set_location (stmt, loc);
    gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
  
+   /* After the above dom info is hosed.  Re-compute it.  */
+   free_dominance_info (CDI_DOMINATORS);
+   calculate_dominance_info (CDI_DOMINATORS);
+ 
    return paral_bb;
  }
  

Reply via email to