EAX can turn out to be alive here, when shrink wrapping is done (which is allowed when using dwarf exceptions, contrary to the normal case with WinCFI).
This fixes PR36487.
Differential D43968
[X86] Handle EAX being live when calling chkstk for x86_64 mstorsjo on Mar 1 2018, 1:47 PM. Authored by
Details EAX can turn out to be alive here, when shrink wrapping is done (which is allowed when using dwarf exceptions, contrary to the normal case with WinCFI). This fixes PR36487.
Diff Detail
Event TimelineComment Actions This is just a first draft - do you have any suggestions on a testcase for it? Just including the reduced IR from the bug report, or something more synthetic? Comment Actions Yes you should at least include that, if you can try to reduce it further - what is the coverage like for the 32-bit path? Comment Actions I see, shrink-wrapping makes it so that EAX may be live into the prologue. I don't like that the CFI becomes imprecise, though. The user won't be able to break on __chkstk and take a backtrace. Does that work today when shrink wrapping isn't in use? If not, then let's just do this. If it does work, we should consider emitting an 8 byte .seh_stackalloc for the push or RAX and a smaller update after __chkstk. This needs a test case. I think this might be a good time to use an MIR test case. Comment Actions It doesn't seem so; both with dwarf and SEH, and GCC with SEH, I get an incorrect backtrace in gdb when breaking on ___chkstk_ms in this case. (Breakpoints in other places give proper backtraces though.)
Well, this case isn't too relevant for SEH at all, since shrink wrapping is disabled altogether when SEH is enabled - in lib/CodeGen/ShrinkWrap.cpp, ShrinkWrap::isShrinkWrapEnabled: bool ShrinkWrap::isShrinkWrapEnabled(const MachineFunction &MF) { const TargetFrameLowering *TFI = MF.getSubtarget().getFrameLowering(); switch (EnableShrinkWrapOpt) { case cl::BOU_UNSET: return TFI->enableShrinkWrapping(MF) && // Windows with CFI has some limitations that make it impossible // to use shrink-wrapping. !MF.getTarget().getMCAsmInfo()->usesWindowsCFI() && |