diff options
| author | 2019-06-23 22:05:08 +0000 | |
|---|---|---|
| committer | 2019-06-23 22:05:08 +0000 | |
| commit | f27a781c9811da94fe68b2cf34237c2a61b48c96 (patch) | |
| tree | 820064216b8f115ba79122ebd03c5451b59fd690 /gnu/llvm/lib/Target/X86/X86FrameLowering.cpp | |
| parent | Import LLVM 8.0.0 release including clang, lld and lldb. (diff) | |
| download | wireguard-openbsd-f27a781c9811da94fe68b2cf34237c2a61b48c96.tar.xz wireguard-openbsd-f27a781c9811da94fe68b2cf34237c2a61b48c96.zip | |
Merge LLVM 8.0.0 release.
Prepared with help from jsg@ and mortimer@
Tested on amd64 by bcallah@, krw@, naddy@
Tested on arm64 by patrick@
Tested on macppc by kettenis@
Tested on octeon by visa@
Tested on sparc64 by claudio@
Diffstat (limited to 'gnu/llvm/lib/Target/X86/X86FrameLowering.cpp')
| -rw-r--r-- | gnu/llvm/lib/Target/X86/X86FrameLowering.cpp | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/gnu/llvm/lib/Target/X86/X86FrameLowering.cpp b/gnu/llvm/lib/Target/X86/X86FrameLowering.cpp index 01448023f2a..3d1333667e6 100644 --- a/gnu/llvm/lib/Target/X86/X86FrameLowering.cpp +++ b/gnu/llvm/lib/Target/X86/X86FrameLowering.cpp @@ -188,7 +188,8 @@ static unsigned findDeadCallerSavedReg(MachineBasicBlock &MBB, } for (auto CS : AvailableRegs) - if (!Uses.count(CS) && CS != X86::RIP) + if (!Uses.count(CS) && CS != X86::RIP && CS != X86::RSP && + CS != X86::ESP) return CS; } } @@ -768,7 +769,7 @@ void X86FrameLowering::emitStackProbeCall(MachineFunction &MF, bool IsLargeCodeModel = MF.getTarget().getCodeModel() == CodeModel::Large; // FIXME: Add retpoline support and remove this. - if (Is64Bit && IsLargeCodeModel && STI.useRetpoline()) + if (Is64Bit && IsLargeCodeModel && STI.useRetpolineIndirectCalls()) report_fatal_error("Emitting stack probe calls on 64-bit with the large " "code model and retpoline not yet implemented."); @@ -1124,15 +1125,6 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF, if (TRI->needsStackRealignment(MF) && !IsWin64Prologue) NumBytes = alignTo(NumBytes, MaxAlign); - // Get the offset of the stack slot for the EBP register, which is - // guaranteed to be the last slot by processFunctionBeforeFrameFinalized. - // Update the frame offset adjustment. - if (!IsFunclet) - MFI.setOffsetAdjustment(-NumBytes); - else - assert(MFI.getOffsetAdjustment() == -(int)NumBytes && - "should calculate same local variable offset for funclets"); - // Save EBP/RBP into the appropriate stack slot. BuildMI(MBB, MBBI, DL, TII.get(Is64Bit ? X86::PUSH64r : X86::PUSH32r)) .addReg(MachineFramePtr, RegState::Kill) @@ -1225,6 +1217,15 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF, NumBytes = StackSize - X86FI->getCalleeSavedFrameSize(); } + // Update the offset adjustment, which is mainly used by codeview to translate + // from ESP to VFRAME relative local variable offsets. + if (!IsFunclet) { + if (HasFP && TRI->needsStackRealignment(MF)) + MFI.setOffsetAdjustment(-NumBytes); + else + MFI.setOffsetAdjustment(-StackSize); + } + // For EH funclets, only allocate enough space for outgoing calls. Save the // NumBytes value that we would've used for the parent frame. unsigned ParentFrameNumBytes = NumBytes; @@ -1266,6 +1267,13 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF, if (!IsWin64Prologue && !IsFunclet && TRI->needsStackRealignment(MF)) { assert(HasFP && "There should be a frame pointer if stack is realigned."); BuildStackAlignAND(MBB, MBBI, DL, StackPtr, MaxAlign); + + if (NeedsWinCFI) { + HasWinCFI = true; + BuildMI(MBB, MBBI, DL, TII.get(X86::SEH_StackAlign)) + .addImm(MaxAlign) + .setMIFlag(MachineInstr::FrameSetup); + } } // If there is an SUB32ri of ESP immediately before this instruction, merge @@ -2051,6 +2059,7 @@ bool X86FrameLowering::assignCalleeSavedSpillSlots( } X86FI->setCalleeSavedFrameSize(CalleeSavedFrameSize); + MFI.setCVBytesOfCalleeSavedRegisters(CalleeSavedFrameSize); // Assign slots for XMMs. for (unsigned i = CSI.size(); i != 0; --i) { @@ -2330,9 +2339,15 @@ void X86FrameLowering::adjustForSegmentedStacks( // Do not generate a prologue for leaf functions with a stack of size zero. // For non-leaf functions we have to allow for the possibility that the - // call is to a non-split function, as in PR37807. - if (StackSize == 0 && !MFI.hasTailCall()) + // callis to a non-split function, as in PR37807. This function could also + // take the address of a non-split function. When the linker tries to adjust + // its non-existent prologue, it would fail with an error. Mark the object + // file so that such failures are not errors. See this Go language bug-report + // https://go-review.googlesource.com/c/go/+/148819/ + if (StackSize == 0 && !MFI.hasTailCall()) { + MF.getMMI().setHasNosplitStack(true); return; + } MachineBasicBlock *allocMBB = MF.CreateMachineBasicBlock(); MachineBasicBlock *checkMBB = MF.CreateMachineBasicBlock(); @@ -2505,7 +2520,7 @@ void X86FrameLowering::adjustForSegmentedStacks( // is laid out within 2^31 bytes of each function body, but this seems // to be sufficient for JIT. // FIXME: Add retpoline support and remove the error here.. - if (STI.useRetpoline()) + if (STI.useRetpolineIndirectCalls()) report_fatal_error("Emitting morestack calls on 64-bit with the large " "code model and retpoline not yet implemented."); BuildMI(allocMBB, DL, TII.get(X86::CALL64m)) @@ -2531,8 +2546,8 @@ void X86FrameLowering::adjustForSegmentedStacks( allocMBB->addSuccessor(&PrologueMBB); - checkMBB->addSuccessor(allocMBB); - checkMBB->addSuccessor(&PrologueMBB); + checkMBB->addSuccessor(allocMBB, BranchProbability::getZero()); + checkMBB->addSuccessor(&PrologueMBB, BranchProbability::getOne()); #ifdef EXPENSIVE_CHECKS MF.verify(); |
