This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Avoid IA-64 prologue insns being deleted (was Re: Bug? flow_find_cross_jump deletes USE insns ...)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 16 Jan 2002 20:36:58 +0100
- Subject: [PATCH] Avoid IA-64 prologue insns being deleted (was Re: Bug? flow_find_cross_jump deletes USE insns ...)
- References: <OF9C1CFAC0.05127CCD-ONC1256B41.005644DA@de.ibm.com> <20020114125622.C9448@redhat.com> <20020116114103.L11237@sunsite.ms.mff.cuni.cz> <20020116103032.B11464@redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Jan 16, 2002 at 10:30:32AM -0800, Richard Henderson wrote:
> On Wed, Jan 16, 2002 at 11:41:03AM +0100, Jakub Jelinek wrote:
> > What is the preferred way here?
> > Use some dummy unspec insn which will contain all the USEs, or use some
> > unspec insn in the sets (like
> > (set (reg:DI 33 r35) (unspec:DI[(reg:DI 320 b0)] FOO))
> > ), or something else?
>
> Another way is to leave the existing insn as-is and have
>
> (unspec:DI [(reg:DI r35)] FOO)
>
> and make it type ignore. That creates a generic "use"
> for the two or three places in the prologue that need this.
Like this?
2002-01-16 Jakub Jelinek <jakub@redhat.com>
* config/ia64/ia64.md (prologue_use): New.
* config/ia64/ia64.c (ia64_expand_prologue): Use
gen_prologue_use instead of gen_rtx_USE.
(group_barrier_needed_p): Handle CODE_FOR_prologue_use the same way
as CODE_FOR_pred_rel_mutex.
(ia64_sched_reorder2): Likewise.
* gcc.c-torture/compile/20020116-1.c: New test.
--- gcc/config/ia64/ia64.md.jj Mon Dec 10 19:13:48 2001
+++ gcc/config/ia64/ia64.md Wed Jan 16 21:36:57 2002
@@ -67,6 +67,7 @@
;; 22 bundle selector
;; 23 cycle display
;; 24 addp4
+;; 25 prologue_use
;;
;; unspec_volatile:
;; 0 alloc
@@ -5302,3 +5303,12 @@
"addp4 %0 = 0,%1"
[(set_attr "itanium_class" "ialu")])
+;;
+;; As USE insns aren't meaningful after reload, this is used instead
+;; to prevent deleting instructions setting registers for EH handling
+(define_insn "prologue_use"
+ [(unspec:DI [(match_operand:DI 0 "register_operand" "")] 25)]
+ ""
+ "// %0 needed for EH"
+ [(set_attr "itanium_class" "ignore")
+ (set_attr "predicable" "no")])
--- gcc/config/ia64/ia64.c.jj Fri Jan 4 13:41:06 2002
+++ gcc/config/ia64/ia64.c Wed Jan 16 21:39:26 2002
@@ -2137,7 +2137,7 @@ ia64_expand_prologue ()
/* Even if we're not going to generate an epilogue, we still
need to save the register so that EH works. */
if (! epilogue_p && current_frame_info.reg_save_ar_unat)
- emit_insn (gen_rtx_USE (VOIDmode, ar_unat_save_reg));
+ emit_insn (gen_prologue_use (ar_unat_save_reg));
}
else
ar_unat_save_reg = NULL_RTX;
@@ -2178,7 +2178,7 @@ ia64_expand_prologue ()
/* Even if we're not going to generate an epilogue, we still
need to save the register so that EH works. */
if (! epilogue_p)
- emit_insn (gen_rtx_USE (VOIDmode, alt_reg));
+ emit_insn (gen_prologue_use (alt_reg));
}
else
{
@@ -2222,7 +2222,7 @@ ia64_expand_prologue ()
/* Even if we're not going to generate an epilogue, we still
need to save the register so that EH works. */
if (! epilogue_p)
- emit_insn (gen_rtx_USE (VOIDmode, alt_reg));
+ emit_insn (gen_prologue_use (alt_reg));
}
else
{
@@ -2262,7 +2262,7 @@ ia64_expand_prologue ()
/* Even if we're not going to generate an epilogue, we still
need to save the register so that EH works. */
if (! epilogue_p)
- emit_insn (gen_rtx_USE (VOIDmode, alt_reg));
+ emit_insn (gen_prologue_use (alt_reg));
}
else
{
@@ -4776,6 +4776,7 @@ group_barrier_needed_p (insn)
/* Doesn't generate code. */
case CODE_FOR_pred_rel_mutex:
+ case CODE_FOR_prologue_use:
return 0;
default:
@@ -6393,7 +6394,8 @@ ia64_sched_reorder2 (dump, sched_verbose
/* Ignore cycle displays and .pred.rel.mutex. */
if (insn_code == CODE_FOR_cycle_display
- || insn_code == CODE_FOR_pred_rel_mutex)
+ || insn_code == CODE_FOR_pred_rel_mutex
+ || insn_code == CODE_FOR_prologue_use)
continue;
if (insn_code == CODE_FOR_insn_group_barrier)
--- gcc/testsuite/gcc.c-torture/compile/20020116-1.c.jj Wed Jan 16 21:46:21 2002
+++ gcc/testsuite/gcc.c-torture/compile/20020116-1.c Wed Jan 16 21:47:04 2002
@@ -0,0 +1,28 @@
+void noret (void) __attribute__ ((noreturn));
+int foo (int, char **);
+char *a, *b;
+int d;
+
+int
+main (int argc, char **argv)
+{
+ register int c;
+
+ d = 1;
+ while ((c = foo (argc, argv)) != -1)
+ switch (c) {
+ case 's':
+ case 'c':
+ case 'f':
+ a = b;
+ break;
+ case 'v':
+ d = 1;
+ break;
+ case 'V':
+ d = 0;
+ break;
+ }
+ noret ();
+ return 0;
+}
Jakub