https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116850

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unknown                     |15.0
                 CC|                            |matz at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org
   Target Milestone|---                         |12.5

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
It's basically a checking issue - we're computing post-dominators on demand
but with checking each time we do this we verify them.  But our CFG
manipulations do not update post-dominators which is what it trips on.

I've tried the following but post-dom updating isn't easy if the new
block is the successor.  We should pretend the old block was new and
re-associate existing post-dom info with the new block.

diff --git a/gcc/gimple-ssa-isolate-paths.cc b/gcc/gimple-ssa-isolate-paths.cc
index fae18db0c1d..c0d4451384a 100644
--- a/gcc/gimple-ssa-isolate-paths.cc
+++ b/gcc/gimple-ssa-isolate-paths.cc
@@ -104,14 +104,27 @@ insert_trap (gimple_stmt_iterator *si_p, tree op)
       gsi_insert_after (si_p, seq, GSI_NEW_STMT);
       if (stmt_ends_bb_p (stmt))
        {
-         split_block (gimple_bb (stmt), stmt);
+         edge e = split_block (gimple_bb (stmt), stmt);
+         if (dom_info_available_p (CDI_POST_DOMINATORS))
+           /* FIXME */;
          return;
        }
     }
   else
     gsi_insert_before (si_p, seq, GSI_NEW_STMT);

-  split_block (gimple_bb (new_stmt), new_stmt);
+  edge e = split_block (gimple_bb (new_stmt), new_stmt);
+  if (dom_info_available_p (CDI_POST_DOMINATORS))
+    {
+      e->dest->dom[1]
+       = e->src->dom[1];
+      e->src->dom[1] = NULL;
+      add_to_dominance_info (CDI_POST_DOMINATORS, e->src);
+      set_immediate_dominator (CDI_POST_DOMINATORS, e->src,
+                              e->dest);
+      redirect_immediate_dominators (CDI_POST_DOMINATORS, e->dest,
+                                    e->src);
+    }
   *si_p = gsi_for_stmt (stmt);
 }



That said, it would be best to remove the requirement on post-dominators.
I think we can end up running into the broken post-dom info and we
don't want to re-compute it all the time.

diff --git a/gcc/gimple-ssa-isolate-paths.cc b/gcc/gimple-ssa-isolate-paths.cc
index fae18db0c1d..401f99789f3 100644
--- a/gcc/gimple-ssa-isolate-paths.cc
+++ b/gcc/gimple-ssa-isolate-paths.cc
@@ -803,7 +818,8 @@ warn_return_addr_local (basic_block bb, greturn
*return_stmt)
     return;

   /* We only need it for this particular case.  */
-  calculate_dominance_info (CDI_POST_DOMINATORS);
+  if (!dom_info_available_p (CDI_POST_DOMINATORS))
+    calculate_dominance_info (CDI_POST_DOMINATORS);

   const args_loc_t *argsloc = locmap.get (return_stmt);
   gcc_assert (argsloc);

fixes the ICE but as said above leaves us to possibly refer to broken /
non-existent DOM info and crash.

Reply via email to