Message ID | d0fcad5e-4f20-2237-3022-bc3ce932fe25@pobox.com |
---|---|
State | New |
Headers | show |
Ian, would you mind looking at this please? A combination of my -mcall-ms2sysv-xlogues patch with Bernd's patch is causing problems when ix86_expand_split_stack_prologue() calls ix86_expand_call(). On 05/15/2017 06:46 PM, Daniel Santos wrote: > Rather or not m->call_ms2sysv is set determines which stack layout is > used when ix86_compute_frame_layout() runs. But if we can run > expand_call after the final time ix86_compute_frame_layout() then we > have a problem. It looks like ix86_expand_split_stack_prologue is the > only function that manually calls ix86_expand_call, but maybe it would > be better to modify the test to something like this: > > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c > index a78819d6b3f..c36383f6962 100644 > --- a/gcc/config/i386/i386.c > +++ b/gcc/config/i386/i386.c > @@ -29325,7 +29325,7 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx > callarg1, > } > > /* Set here, but it may get cleared later. */ > - if (TARGET_CALL_MS2SYSV_XLOGUES) > + if (TARGET_CALL_MS2SYSV_XLOGUES && !reload_completed) > cfun->machine->call_ms2sysv = true; > } > > Actually, I think this is wrong. I happened to recall looking at the morestack code last year and remembered that it was all assembly. I looked at it again and I don't see that it calls anything outside of it's implementation file (libgcc/config/i386/morestack.S) except for _Unwind_Resume and the calling function its self (I think it calls its caller). It saves and restores rsi and rdi and doesn't use any sse registers, so it doesn't need to clobber all of the regs in the x86_64_ms_sysv_extra_clobbered_registers array. I'm guessing that this should have it's own pattern instead of calling ix86_expand_call in the first place. Of course, I'm the new guy here, so please enlighten me if I'm wrong. Thanks, Daniel
On Mon, May 15, 2017 at 10:00 PM, Daniel Santos <daniel.santos@pobox.com> wrote: > > Ian, would you mind looking at this please? A combination of my > -mcall-ms2sysv-xlogues patch with Bernd's patch is causing problems when > ix86_expand_split_stack_prologue() calls ix86_expand_call(). I don't have a lot of context here. I assume that ms2sysv is going to be used on Windows systems, where -fsplit-stack isn't really going to work anyhow, so I think it would probably be OK that reject that combination if it causes trouble. Also, it's overkill for ix86_expand_split_stack_prologue to call ix86_expand_call. The call is always to __morestack, and __morestack is written in assembler, so we could use a simpler version of ix86_expand_call if that helps. In particular we can decide that __morestack doesn't clobber any unusual registers, if that is what is causing the problem. Ian
On 05/16/2017 12:19 PM, Ian Lance Taylor wrote: > On Mon, May 15, 2017 at 10:00 PM, Daniel Santos <daniel.santos@pobox.com> wrote: >> Ian, would you mind looking at this please? A combination of my >> -mcall-ms2sysv-xlogues patch with Bernd's patch is causing problems when >> ix86_expand_split_stack_prologue() calls ix86_expand_call(). > I don't have a lot of context here. I assume that ms2sysv is going to > be used on Windows systems, where -fsplit-stack isn't really going to > work anyhow, so I think it would probably be OK that reject that > combination if it causes trouble. Sorry I wasn't more specific. This -mcall-ms2sysv-xlogues actually targets Wine, although they don't use -fsplit-stack. My patch set as-is is disabled when fsplit-stack is used, but during ix86_compute_frame_layout, which is too late in the case of -fsplit-stack. I think I should just change this to a sorry() in ix86_option_override_internal. > Also, it's overkill for ix86_expand_split_stack_prologue to call > ix86_expand_call. The call is always to __morestack, and __morestack > is written in assembler, so we could use a simpler version of > ix86_expand_call if that helps. In particular we can decide that > __morestack doesn't clobber any unusual registers, if that is what is > causing the problem. > > Ian Well aside from the conflict of the two patches, it just looks like it has the potential to generate clobbers where none are needed, but I'm having trouble actually *proving* that, so maybe I'm just wrong. Daniel
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index a78819d6b3f..c36383f6962 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -29325,7 +29325,7 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx callarg1, } /* Set here, but it may get cleared later. */ - if (TARGET_CALL_MS2SYSV_XLOGUES) + if (TARGET_CALL_MS2SYSV_XLOGUES && !reload_completed) cfun->machine->call_ms2sysv = true; }