http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48272

Andrey Belevantsev <abel at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.04.07 08:48:57
                 CC|                            |abel at gcc dot gnu.org,
                   |                            |vmakarov at redhat dot com
     Ever Confirmed|0                           |1

--- Comment #2 from Andrey Belevantsev <abel at gcc dot gnu.org> 2011-04-07 
08:48:57 UTC ---
Confirmed (nice non-sensical set of options, btw.)

The problem is that register pressure code is not prepared for new insns
created during scheduling (for ia64, this is speculation checks and recovery
code).  The ICE happens because we do not initialize register pressure
structures.  The below patch seems to fix it, but I am not sure it is correct.  

The patch calls setup_insn_reg_pressure_info (renamed to
init_insn_reg_pressure_info because there is the function with the same name in
haifa-sched.c) from within haifa_init_insn, where new instructions created
during scheduling are initialized.  The patch does not call setup_insn_reg_uses
as sched_analyze_insn does, because there is no deps context at that point.  If
some processing of this kind is desired, I guess we need to amend the functions
that copy/init dependencies for recovery code (that is, create_check_block_twin
and add_to_speculative_block).  Finally, better name for
init_insn_reg_pressure_info should be devised.

Vlad, it would be great if you can advise me on how to improve the patch.


diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index 30f55be..6908a11 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -5611,6 +5611,8 @@ haifa_init_insn (rtx insn)
       /* Extend dependency caches by one element.  */
       extend_dependency_caches (1, false);
     }
+  if (sched_pressure_p)
+    init_insn_reg_pressure_info (insn);
 }

 /* Init data for the new basic block BB which comes after AFTER.  */
diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c
index dcee019..393e651 100644
--- a/gcc/sched-deps.c
+++ b/gcc/sched-deps.c
@@ -1991,8 +1991,8 @@ mark_insn_reg_clobber (rtx reg, const_rtx setter, void
*data)
 }

 /* Set up reg pressure info related to INSN.  */
-static void
-setup_insn_reg_pressure_info (rtx insn)
+void
+init_insn_reg_pressure_info (rtx insn)
 {
   int i, len;
   enum reg_class cl;
@@ -2774,7 +2774,7 @@ sched_analyze_insn (struct deps_desc *deps, rtx x, rtx
insn)
   if (sched_pressure_p)
     {
       setup_insn_reg_uses (deps, insn);
-      setup_insn_reg_pressure_info (insn);
+      init_insn_reg_pressure_info (insn);
     }

   /* Add register dependencies for insn.  */
diff --git a/gcc/sched-int.h b/gcc/sched-int.h
index d5add3b..d5c9509 100644
--- a/gcc/sched-int.h
+++ b/gcc/sched-int.h
@@ -1194,6 +1194,7 @@ extern void init_deps_global (void);
 extern void finish_deps_global (void);
 extern void deps_analyze_insn (struct deps_desc *, rtx);
 extern void remove_from_deps (struct deps_desc *, rtx);
+extern void init_insn_reg_pressure_info (rtx);

 extern dw_t get_dep_weak_1 (ds_t, ds_t);
 extern dw_t get_dep_weak (ds_t, ds_t);

Reply via email to