This is PR 49801.

The problem is that liveness data is not updated by split2, so when
cmp-elim runs next and *does* update it, we get verify failures.

As I note in the PR, I clearly have no idea how the interface to df
is supposed to work.  All of the examples say df_analyze is supposed
to be run first, and they also say that DF_LIVE is always present
with -O2.  Which together would seem to me to require DF_LIVE to be
updated when processing (deferred) insns, or by TODO_df_finish.

All that said, this patch does fix the ICE.

Is this really the way things are supposed to work?  Does the real
fix belong elsewhere, e.g. the beginning of the cmp-elim pass?


r~
diff --git a/gcc/recog.c b/gcc/recog.c
index d3ecb73..e0557c5 100644
--- a/gcc/recog.c
+++ b/gcc/recog.c
@@ -3769,20 +3769,33 @@ struct rtl_opt_pass pass_split_all_insns =
 static unsigned int
 rest_of_handle_split_after_reload (void)
 {
-  /* If optimizing, then go ahead and split insns now.  */
-#ifndef STACK_REGS
-  if (optimize > 0)
-#endif
-    split_all_insns ();
+  df_live_add_problem ();
+  df_set_flags (DF_DEFER_INSN_RESCAN);
+
+  split_all_insns ();
+  df_analyze ();
+
   return 0;
 }
 
+static bool
+gate_split_after_reload (void)
+{
+  /* The regstack pass requires post-reload splitting to occur.  */
+#ifdef STACK_REGS
+  return true;
+#endif
+
+  /* Otherwise, only split now for optimization.  */
+  return optimize != 0;
+}
+
 struct rtl_opt_pass pass_split_after_reload =
 {
  {
   RTL_PASS,
   "split2",                             /* name */
-  NULL,                                 /* gate */
+  gate_split_after_reload,             /* gate */
   rest_of_handle_split_after_reload,    /* execute */
   NULL,                                 /* sub */
   NULL,                                 /* next */
@@ -3792,7 +3805,7 @@ struct rtl_opt_pass pass_split_after_reload =
   0,                                    /* properties_provided */
   0,                                    /* properties_destroyed */
   0,                                    /* todo_flags_start */
-  0                                     /* todo_flags_finish */
+  TODO_df_finish | TODO_df_verify      /* todo_flags_finish */
  }
 };
 

Reply via email to