[PATCH] Fix PR target/6542
Jakub Jelinek
jakub@redhat.com
Fri May 3 07:25:00 GMT 2002
Hi!
We were ICEing on the attached testcase when dwarf2 did LEAF_REG_REMAP
on %o0 and it returned -1. The problem is that
current_function_uses_only_leaf_regs is 1 even in -mflat (because
the function in question after optimizing doesn't use any, so it
doesn't care if no registers are actually permitted for leaf).
Rather than slowing down the generic code to see if there are any
registers permitted for leaf at all or introducing new macros, following
seems to work well (basically making LEAF_REG_REMAP(REGNO) return REGNO
if -mflat). I've commited this to trunk.
Mark, is this ok for branch? Don't have 2.95.x compiled for SPARC,
but this definitely doesn't crash even with -gdwarf-2 with egcs 1.1.2
(but ICEs with gcc 2.96-RH and above).
2002-05-03 Jakub Jelinek <jakub@redhat.com>
PR target/6542
* config/sparc/sparc.h (leaf_reg_remap): Remove const.
(CONDITIONAL_REGISTER_USAGE): For TARGET_FLAT make
fill leaf_reg_remap with identity.
* config/sparc/sparc.c (leaf_reg_remap): Remove const.
* gcc.dg/20020503-1.c: New test.
--- gcc/config/sparc/sparc.h.jj Tue Apr 30 22:28:46 2002
+++ gcc/config/sparc/sparc.h Fri May 3 16:24:11 2002
@@ -1017,12 +1017,16 @@ do \
fixed_regs[4] = 0; \
if (TARGET_FLAT) \
{ \
+ int regno; \
/* Let the compiler believe the frame pointer is still \
%fp, but output it as %i7. */ \
fixed_regs[31] = 1; \
reg_names[HARD_FRAME_POINTER_REGNUM] = "%i7"; \
/* Disable leaf functions */ \
memset (sparc_leaf_regs, 0, FIRST_PSEUDO_REGISTER); \
+ /* Make LEAF_REG_REMAP a noop. */ \
+ for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) \
+ leaf_reg_remap [regno] = regno; \
} \
} \
while (0)
@@ -1319,7 +1323,7 @@ extern enum reg_class sparc_regno_reg_cl
extern char sparc_leaf_regs[];
#define LEAF_REGISTERS sparc_leaf_regs
-extern const char leaf_reg_remap[];
+extern char leaf_reg_remap[];
#define LEAF_REG_REMAP(REGNO) (leaf_reg_remap[REGNO])
/* The class value for index registers, and the one for base regs. */
--- gcc/config/sparc/sparc.c.jj Thu May 2 11:59:21 2002
+++ gcc/config/sparc/sparc.c Fri May 3 16:24:26 2002
@@ -85,7 +85,7 @@ bool sparc_emitting_epilogue;
/* Vector to say how input registers are mapped to output registers.
HARD_FRAME_POINTER_REGNUM cannot be remapped by this function to
eliminate it. You must use -fomit-frame-pointer to get that. */
-const char leaf_reg_remap[] =
+char leaf_reg_remap[] =
{ 0, 1, 2, 3, 4, 5, 6, 7,
-1, -1, -1, -1, -1, -1, 14, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
--- gcc/testsuite/gcc.dg/20020503-1.c.jj Fri May 3 16:16:45 2002
+++ gcc/testsuite/gcc.dg/20020503-1.c Fri May 3 16:20:48 2002
@@ -0,0 +1,12 @@
+/* PR target/6542
+ This testcase caused ICE on SPARC because the function uses no registers
+ after optimizing, so even if -mflat make all registers not permitted
+ for leaf functions, the function was still leaf, but LEAF_REG_REMAP
+ returned -1 for some registers (like %o0). */
+/* { dg-do compile } */
+/* { do-options "-O2 -g" } */
+/* { do-options "-O2 -g -mflat" { target sparc*-*-* } } */
+
+void foo (char *a, char *b, char *c, char *d)
+{
+}
Jakub
More information about the Gcc-patches
mailing list