From: Alan Modra Date: Fri, 4 Jun 2010 04:58:05 +0000 (+0930) Subject: re PR target/44075 (__builtin_eh_return miscompiled) X-Git-Tag: releases/gcc-4.3.6~465 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b84db5f2ba65a2b3073188ce33c979e8ed31cb6;p=thirdparty%2Fgcc.git re PR target/44075 (__builtin_eh_return miscompiled) PR target/44075 * gcc/config/rs6000/rs6000.c (struct machine_function): Reorder fields for better packing. Add lr_save_state. (rs6000_ra_ever_killed): Return lr_save_state if set. (rs6000_emit_eh_reg_restore): Set lr_save_state. From-SVN: r160248 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d062536754f1..c979c9917a02 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2010-06-04 Alan Modra + + PR target/44075 + * gcc/config/rs6000/rs6000.c (struct machine_function): Reorder + fields for better packing. Add lr_save_state. + (rs6000_ra_ever_killed): Return lr_save_state if set. + (rs6000_emit_eh_reg_restore): Set lr_save_state. + 2010-05-24 Uros Bizjak Backport from mainline: diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index b39c456720d2..228477fce80b 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -115,14 +115,16 @@ typedef struct rs6000_stack { This is added to the cfun structure. */ typedef struct machine_function GTY(()) { - /* Flags if __builtin_return_address (n) with n >= 1 was used. */ - int ra_needs_full_frame; /* Some local-dynamic symbol. */ const char *some_ld_name; /* Whether the instruction chain has been scanned already. */ int insn_chain_scanned_p; + /* Flags if __builtin_return_address (n) with n >= 1 was used. */ + int ra_needs_full_frame; /* Flags if __builtin_return_address (0) was used. */ int ra_need_lr; + /* Cache lr_save_p after expansion of builtin_eh_return. */ + int lr_save_state; /* Offset from virtual_stack_vars_rtx to the start of the ABI_V4 varargs save area. */ HOST_WIDE_INT varargs_save_offset; @@ -14914,6 +14916,9 @@ rs6000_ra_ever_killed (void) if (current_function_is_thunk) return 0; + if (cfun->machine->lr_save_state) + return cfun->machine->lr_save_state - 1; + /* regs_ever_live has LR marked as used if any sibcalls are present, but this should not force saving and restoring in the pro/epilogue. Likewise, reg_set_between_p thinks a sibcall @@ -15083,6 +15088,12 @@ rs6000_emit_eh_reg_restore (rtx source, rtx scratch) } else emit_move_insn (gen_rtx_REG (Pmode, LR_REGNO), operands[0]); + + /* Freeze lr_save_p. We've just emitted rtl that depends on the + state of lr_save_p so any change from here on would be a bug. In + particular, stop rs6000_ra_ever_killed from considering the SET + of lr we may have added just above. */ + cfun->machine->lr_save_state = info->lr_save_p + 1; } static GTY(()) alias_set_type set = -1;