diff --git a/gcc/config/sparc/sparc.cc b/gcc/config/sparc/sparc.cc index bb4ce886785..467a9f171d2 100644 --- a/gcc/config/sparc/sparc.cc +++ b/gcc/config/sparc/sparc.cc @@ -8884,8 +8884,20 @@ epilogue_renumber (rtx *where, int test) if (REGNO (*where) >= 8 && REGNO (*where) < 24) /* oX or lX */ return 1; if (! test && REGNO (*where) >= 24 && REGNO (*where) < 32) - *where = gen_rtx_REG (GET_MODE (*where), OUTGOING_REGNO (REGNO(*where))); - /* fallthrough */ + { + if (ORIGINAL_REGNO (*where)) + { + rtx n = gen_raw_REG (GET_MODE (*where), + OUTGOING_REGNO (REGNO (*where))); + ORIGINAL_REGNO (n) = ORIGINAL_REGNO (*where); + *where = n; + } + else + *where = gen_rtx_REG (GET_MODE (*where), + OUTGOING_REGNO (REGNO (*where))); + } + return 0; + case SCRATCH: case PC: case CONST_INT: diff --git a/gcc/testsuite/gcc.dg/pr105257.c b/gcc/testsuite/gcc.dg/pr105257.c new file mode 100644 index 00000000000..4232942d791 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr105257.c @@ -0,0 +1,16 @@ +/* PR target/105257 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-fpic" { target fpic } } */ + +extern int sigsetjmp (void **, int); +void *buf[32]; +void (*fn) (void); + +const char * +bar (void) +{ + sigsetjmp (buf, 0); + fn (); + return ""; +}