This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] x86 interrupt attribute
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Mike Stump <mikestump at comcast dot net>
- Cc: Yulia Koval <vaalfreja at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Uros Bizjak <ubizjak at gmail dot com>
- Date: Tue, 29 Sep 2015 19:50:09 -0700
- Subject: Re: [PATCH] x86 interrupt attribute
- Authentication-results: sourceware.org; auth=none
- References: <CAE0nxxi-T8da1=dXkHem2m6d_2RramotAU3HY=UqFkmT0kW=RQ at mail dot gmail dot com> <2AB9494F-91EC-4CF6-945B-0CB03A583513 at comcast dot net> <CAMe9rOpMB9fnj_ZS7h122BuODsf9TZNOUvWVzrYvLN8VxGiFkg at mail dot gmail dot com> <CAMe9rOoeorsg06XxtNr1-iNX_m-Fe8gtsW2uXs_M2+EOw+gLqg at mail dot gmail dot com> <F096FB33-4A00-4D7B-8C9B-3FE8ACE7FEF9 at comcast dot net> <CAMe9rOoDBMKGeUBJjCrGQQNnFE559gxZwhvWOXT8gn9Zo68nsQ at mail dot gmail dot com> <1D91C2C8-833D-4F6D-9C57-C22D61662A83 at comcast dot net> <CAMe9rOoig1gcjaQLqCAE4o3OehBBgkCwN2wHDatqB=QhykEp6A at mail dot gmail dot com>
On Tue, Sep 29, 2015 at 5:02 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Sep 29, 2015 at 4:53 PM, Mike Stump <mikestump@comcast.net> wrote:
>> On Sep 29, 2015, at 3:10 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> On Tue, Sep 29, 2015 at 2:23 PM, Mike Stump <mikestump@comcast.net> wrote:
>>>> On Sep 29, 2015, at 1:59 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>>> commit f3a6675a8d69d810d2cad0c090a762094a0a8622
>>>>> Author: H.J. Lu <hjl.tools@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.tools@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))