From: Hans-Peter Nilsson Date: Fri, 17 Jun 2011 11:20:01 +0000 (+0000) Subject: re PR rtl-optimization/48542 (unchanged variables in code which calls setjmp may... X-Git-Tag: releases/gcc-4.4.7~359 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45898b407dd08b62e67681d9e7e7049c6bac4893;p=thirdparty%2Fgcc.git re PR rtl-optimization/48542 (unchanged variables in code which calls setjmp may be clobbered (including the return-address)) PR rtl-optimization/48542 * reload.c (find_equiv_reg): Stop looking when finding a setjmp-type call. * reload1.c (reload_as_needed): Invalidate all reload registers when crossing a setjmp-type call. From-SVN: r175144 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8d79502068b0..09164bed7a37 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2011-06-17 Hans-Peter Nilsson + + Backport from mainline + 2011-06-17 Hans-Peter Nilsson + + PR rtl-optimization/48542 + * reload.c (find_equiv_reg): Stop looking when finding a + setjmp-type call. + * reload1.c (reload_as_needed): Invalidate all reload + registers when crossing a setjmp-type call. + 2011-06-09 Eric Botcazou * config/sparc/sparc.md (return_internal): Adjust 'length' attribute. diff --git a/gcc/reload.c b/gcc/reload.c index d188233e5049..eadaa50b335d 100644 --- a/gcc/reload.c +++ b/gcc/reload.c @@ -6731,6 +6731,15 @@ find_equiv_reg (rtx goal, rtx insn, enum reg_class rclass, int other, || num > PARAM_VALUE (PARAM_MAX_RELOAD_SEARCH_INSNS)) return 0; + /* Don't reuse register contents from before a setjmp-type + function call; on the second return (from the longjmp) it + might have been clobbered by a later reuse. It doesn't + seem worthwhile to actually go and see if it is actually + reused even if that information would be readily available; + just don't reuse it across the setjmp call. */ + if (CALL_P (p) && find_reg_note (p, REG_SETJMP, NULL_RTX)) + return 0; + if (NONJUMP_INSN_P (p) /* If we don't want spill regs ... */ && (! (reload_reg_p != 0 diff --git a/gcc/reload1.c b/gcc/reload1.c index d579dc51885d..070ffeee209d 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -4428,6 +4428,13 @@ reload_as_needed (int live_known) { AND_COMPL_HARD_REG_SET (reg_reloaded_valid, call_used_reg_set); AND_COMPL_HARD_REG_SET (reg_reloaded_valid, reg_reloaded_call_part_clobbered); + + /* If this is a call to a setjmp-type function, we must not + reuse any reload reg contents across the call; that will + just be clobbered by other uses of the register in later + code, before the longjmp. */ + if (find_reg_note (insn, REG_SETJMP, NULL_RTX)) + CLEAR_HARD_REG_SET (reg_reloaded_valid); } }