On Tue, Sep 29, 2015 at 5:02 PM, H.J. Lu <hjl.to...@gmail.com> wrote: > On Tue, Sep 29, 2015 at 4:53 PM, Mike Stump <mikest...@comcast.net> wrote: >> On Sep 29, 2015, at 3:10 PM, H.J. Lu <hjl.to...@gmail.com> wrote: >>> On Tue, Sep 29, 2015 at 2:23 PM, Mike Stump <mikest...@comcast.net> wrote: >>>> On Sep 29, 2015, at 1:59 PM, H.J. Lu <hjl.to...@gmail.com> wrote: >>>>> commit f3a6675a8d69d810d2cad0c090a762094a0a8622 >>>>> Author: H.J. Lu <hjl.to...@gmail.com> >>>>> Date: Tue Sep 29 13:47:18 2015 -0700 >>>>> >>>>> Define EPILOGUE_USES in i386 so that all preserved registers are used >>>>> by the epilogue of interrupt handler. Don't explicitly mark BP and SP >>>>> registers as used since they are always used in epilogue. >>>>> >>>>> Please take a look. >>>> >>>> Oh, too bad you didn’t copy it here. The easiest thing to blow is the >>>> addition of reload_completed && on the condition >> >> >>> static bool >>> ix86_save_reg (unsigned int regno, bool maybe_eh_return) >>> { >>> /* In interrupt handler, we don't preserve MMX and x87 registers >>> which aren't supported when saving and restoring registers. No >>> need to preserve callee-saved registers unless they are modified. >>> We also preserve all caller-saved registers if a function call >>> is made in interrupt handler since the called function may change >>> them. Don't explicitly save BP and SP registers since they are >>> always preserved. */ >>> if (cfun->machine->is_interrupt) >>> return ((df_regs_ever_live_p (regno) >>> || (call_used_regs[regno] && cfun->machine->make_calls)) >>> && !fixed_regs[regno] >>> && !STACK_REGNO_P (regno) >>> && !MMX_REGNO_P (regno) >>> && regno != BP_REG >>> && regno != SP_REG >>> && (regno <= ST7_REG || regno >= XMM0_REG)); >>> >>> Is this sufficient? >> >> I see no string "reload_completed &&”. Either, you need it here, or, you >> need it in the caller. > > Do you have a testcase to show its impact?
I checked this patch into hjl/interrupt/master branch. Thanks. -- H.J. -- commit 8c75718a0f590cb02e7cb88e36fe12e90db62bc1 Author: H.J. Lu <hjl.to...@gmail.com> Date: Tue Sep 29 19:42:16 2015 -0700 Preserve registers in interrupt handler after reload * config/i386/i386.c (ix86_save_reg): Preserve callee-saved and caller-saved registers in interrupt handler only after reload. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 6b14471..d5c7e07 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -11119,7 +11119,7 @@ ix86_save_reg (unsigned int regno, bool maybe_eh_return) is made in interrupt handler since the called function may change them. Don't explicitly save BP and SP registers since they are always preserved. */ - if (cfun->machine->is_interrupt) + if (cfun->machine->is_interrupt && reload_completed) return ((df_regs_ever_live_p (regno) || (call_used_regs[regno] && cfun->machine->call_with_caller_saved_registers))