This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH m32c] PR target/32335 mismatched prologue/epilogue ICEs cselib
- From: Rask Ingemann Lambertsen <rask at sygehus dot dk>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 20 Jun 2007 21:34:19 +0200
- Subject: [PATCH m32c] PR target/32335 mismatched prologue/epilogue ICEs cselib
As noted in the PR, with default subtarget options, there is a mismatch
between between using HImode registers in the prologue and using PSImode
registers in the epilogue, causing a crash:
$ ./xgcc -B./ /n/08/rask/src/gcc/gcc/testsuite/gcc.dg/pr32069.c -S -dp \
-o /dev/null -O1
/n/08/rask/src/gcc/gcc/testsuite/gcc.dg/pr32069.c: In function 'segfault':
/n/08/rask/src/gcc/gcc/testsuite/gcc.dg/pr32069.c:7: internal compiler error: in cselib_record_set, at cselib.c:1508
With the patch below, cselib is happy again:
$ ./xgcc -B./ /n/08/rask/src/gcc/gcc/testsuite/gcc.dg/pr32069.c -S -dp \
-o /dev/stdout -O1 | grep -F -e _24 -e _16
enter #0 ; 59 prologue_enter_16
exitd ; 62 epilogue_exitd_16
$ ./xgcc -B./ /n/08/rask/src/gcc/gcc/testsuite/gcc.dg/pr32069.c -S -dp \
-o /dev/stdout -O1 -mcpu=m32cm | grep -F -e _24 -e _16
enter #0 ; 59 prologue_enter_24
exitd ; 66 epilogue_exitd_24
Ok?
:ADDPATCH m32c:
2007-06-20 Rask Ingemann Lambertsen <rask@sygehus.dk>
PR target/32335
* config/m32c/m32c.c (m32c_emit_epilogue): Use new HImode epilogue
for TARGET_A16.
* config/m32c/prologue.md (epilogue_exitd_16): New.
(epilogue_reit_16): New.
(epilogue_exitd): Rename to epilogue_exitd_24.
(epilogue_reit): Rename to epilogue_reit_24.
Index: config/m32c/m32c.c
===================================================================
--- config/m32c/m32c.c (revision 125860)
+++ config/m32c/m32c.c (working copy)
@@ -4026,12 +4026,17 @@ m32c_emit_epilogue (void)
else
emit_insn (gen_poppsi (gen_rtx_REG (PSImode, FP_REGNO)));
emit_insn (gen_popm (GEN_INT (cfun->machine->intr_pushm)));
- emit_jump_insn (gen_epilogue_reit (GEN_INT (TARGET_A16 ? 4 : 6)));
+ if (TARGET_A16)
+ emit_jump_insn (gen_epilogue_reit_16 ());
+ else
+ emit_jump_insn (gen_epilogue_reit_24 ());
}
else if (cfun->machine->use_rts)
emit_jump_insn (gen_epilogue_rts ());
+ else if (TARGET_A16)
+ emit_jump_insn (gen_epilogue_exitd_16 ());
else
- emit_jump_insn (gen_epilogue_exitd (GEN_INT (TARGET_A16 ? 2 : 4)));
+ emit_jump_insn (gen_epilogue_exitd_24 ());
emit_barrier ();
}
Index: config/m32c/prologue.md
===================================================================
--- config/m32c/prologue.md (revision 125860)
+++ config/m32c/prologue.md (working copy)
@@ -102,26 +102,50 @@
[(set_attr "flags" "x")]
)
-(define_insn "epilogue_exitd"
+(define_insn "epilogue_exitd_16"
+ [(set (reg:HI SP_REGNO)
+ (plus:HI (reg:HI FB_REGNO)
+ (const_int 2)))
+ (set (reg:HI FB_REGNO)
+ (mem:HI (reg:HI FB_REGNO)))
+ (return)
+ ]
+ "TARGET_A16"
+ "exitd"
+ [(set_attr "flags" "x")]
+ )
+
+(define_insn "epilogue_reit_16"
+ [(set (reg:HI SP_REGNO)
+ (plus:HI (reg:HI SP_REGNO)
+ (const_int 4)))
+ (return)
+ ]
+ "TARGET_A16"
+ "reit"
+ [(set_attr "flags" "x")]
+ )
+
+(define_insn "epilogue_exitd_24"
[(set (reg:PSI SP_REGNO)
(plus:PSI (reg:PSI FB_REGNO)
- (match_operand 0 "const_int_operand" "i")))
+ (const_int 4)))
(set (reg:PSI FB_REGNO)
(mem:PSI (reg:PSI FB_REGNO)))
(return)
]
- ""
+ "TARGET_A24"
"exitd"
[(set_attr "flags" "x")]
)
-(define_insn "epilogue_reit"
+(define_insn "epilogue_reit_24"
[(set (reg:PSI SP_REGNO)
(plus:PSI (reg:PSI SP_REGNO)
- (match_operand 0 "const_int_operand" "i")))
+ (const_int 6)))
(return)
]
- ""
+ "TARGET_A24"
"reit"
[(set_attr "flags" "x")]
)