From ee5c0d8af979891b6b215587979b96d7b12b5880 Mon Sep 17 00:00:00 2001 From: Segher Boessenkool Date: Sat, 31 Oct 2015 20:50:09 +0100 Subject: [PATCH] rs6000: Rewrite rs6000_reg_live_or_pic_offset_p This function is quite a puzzle; untangle it. No functional change. 2015-10-31 Segher Boessenkool * config/rs6000/rs6000.c (rs6000_reg_live_or_pic_offset_p): Rewrite. From-SVN: r229634 --- gcc/ChangeLog | 4 ++++ gcc/config/rs6000/rs6000.c | 35 ++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c4ad5e4ee8d..ff4a7ff7ee4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2015-10-31 Segher Boessenkool + + * config/rs6000/rs6000.c (rs6000_reg_live_or_pic_offset_p): Rewrite. + 2015-10-31 Segher Boessenkool * config/rs6000/rs6000.c (rs6000_reg_live_or_pic_offset_p): Use the diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 75ddaa2d3fc..271c3f91b4a 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -22021,22 +22021,27 @@ save_reg_p (int r) static bool rs6000_reg_live_or_pic_offset_p (int reg) { + /* We need to mark the PIC offset register live for the same conditions + as it is set up, or otherwise it won't be saved before we clobber it. */ + + if (reg == RS6000_PIC_OFFSET_TABLE_REGNUM && !TARGET_SINGLE_PIC_BASE) + { + if (TARGET_TOC && TARGET_MINIMAL_TOC + && (crtl->calls_eh_return + || df_regs_ever_live_p (reg) + || get_pool_size ())) + return true; + + if ((DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_DARWIN) + && flag_pic) + return true; + } + /* If the function calls eh_return, claim used all the registers that would - be checked for liveness otherwise. This is required for the PIC offset - register with -mminimal-toc on AIX, as it is advertised as "fixed" for - register allocation purposes in this case. */ - - return (((crtl->calls_eh_return || df_regs_ever_live_p (reg)) - && (!call_used_regs[reg] - || (reg == RS6000_PIC_OFFSET_TABLE_REGNUM - && !TARGET_SINGLE_PIC_BASE - && TARGET_TOC && TARGET_MINIMAL_TOC))) - || (reg == RS6000_PIC_OFFSET_TABLE_REGNUM - && !TARGET_SINGLE_PIC_BASE - && ((DEFAULT_ABI == ABI_V4 && flag_pic != 0) - || (DEFAULT_ABI == ABI_DARWIN && flag_pic) - || (TARGET_TOC && TARGET_MINIMAL_TOC - && get_pool_size () != 0)))); + be checked for liveness otherwise. */ + + return ((crtl->calls_eh_return || df_regs_ever_live_p (reg)) + && !call_used_regs[reg]); } /* Return the first fixed-point register that is required to be -- 2.30.2