diff options
author | Reid Kleckner <reid@kleckner.net> | 2015-01-29 22:33:00 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2015-01-29 22:33:00 +0000 |
commit | dafc2ae1ade22e6463e5dbc87ec220b669d15fe5 (patch) | |
tree | d9662b61269b7540cd23091bb164767d66e0dbf4 /llvm/lib/Target/X86/X86FrameLowering.cpp | |
parent | 2a2235087ff4fa50849180154f1d88aad11e476d (diff) | |
download | bcm5719-llvm-dafc2ae1ade22e6463e5dbc87ec220b669d15fe5.tar.gz bcm5719-llvm-dafc2ae1ade22e6463e5dbc87ec220b669d15fe5.zip |
Update comments to use unreachable instead of llvm.trap, as implemented now
win64: Call __chkstk through a register with the large code model
Fixes half of PR18582. True dynamic allocas will still have a
CALL64pcrel32 which will fail.
Reviewers: majnemer
Differential Revision: http://reviews.llvm.org/D7267
llvm-svn: 227503
Diffstat (limited to 'llvm/lib/Target/X86/X86FrameLowering.cpp')
-rw-r--r-- | llvm/lib/Target/X86/X86FrameLowering.cpp | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/llvm/lib/Target/X86/X86FrameLowering.cpp b/llvm/lib/Target/X86/X86FrameLowering.cpp index bb2007dd682..4cccfa26be4 100644 --- a/llvm/lib/Target/X86/X86FrameLowering.cpp +++ b/llvm/lib/Target/X86/X86FrameLowering.cpp @@ -408,10 +408,16 @@ static bool usesTheStack(const MachineFunction &MF) { return false; } -void X86FrameLowering::getStackProbeFunction(const X86Subtarget &STI, +void X86FrameLowering::getStackProbeFunction(const MachineFunction &MF, + const X86Subtarget &STI, unsigned &CallOp, const char *&Symbol) { - CallOp = STI.is64Bit() ? X86::W64ALLOCA : X86::CALLpcrel32; + if (STI.is64Bit()) + CallOp = MF.getTarget().getCodeModel() == CodeModel::Large + ? X86::CALL64r + : X86::W64ALLOCA; + else + CallOp = X86::CALLpcrel32; if (STI.is64Bit()) { if (STI.isTargetCygMing()) { @@ -758,7 +764,7 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF) const { const char *StackProbeSymbol; unsigned CallOp; - getStackProbeFunction(STI, CallOp, StackProbeSymbol); + getStackProbeFunction(MF, STI, CallOp, StackProbeSymbol); // Check whether EAX is livein for this function. bool isEAXAlive = isEAXLiveIn(MF); @@ -788,12 +794,23 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF) const { .setMIFlag(MachineInstr::FrameSetup); } - BuildMI(MBB, MBBI, DL, - TII.get(CallOp)) - .addExternalSymbol(StackProbeSymbol) - .addReg(StackPtr, RegState::Define | RegState::Implicit) - .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit) - .setMIFlag(MachineInstr::FrameSetup); + if (Is64Bit && MF.getTarget().getCodeModel() == CodeModel::Large) { + // For the large code model, we have to call through a register. Use R11, + // as it is unused and clobbered by all probe functions. + BuildMI(MBB, MBBI, DL, TII.get(X86::MOV64ri), X86::R11) + .addExternalSymbol(StackProbeSymbol); + BuildMI(MBB, MBBI, DL, TII.get(CallOp)) + .addReg(X86::R11) + .addReg(StackPtr, RegState::Define | RegState::Implicit) + .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit) + .setMIFlag(MachineInstr::FrameSetup); + } else { + BuildMI(MBB, MBBI, DL, TII.get(CallOp)) + .addExternalSymbol(StackProbeSymbol) + .addReg(StackPtr, RegState::Define | RegState::Implicit) + .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit) + .setMIFlag(MachineInstr::FrameSetup); + } if (Is64Bit) { // MSVC x64's __chkstk and cygwin/mingw's ___chkstk_ms do not adjust %rsp |