diff options
| author | Reid Kleckner <rnk@google.com> | 2016-03-02 19:20:59 +0000 |
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2016-03-02 19:20:59 +0000 |
| commit | 65f9d9cd324fc12f8bf90fa67477e2ddd90803d6 (patch) | |
| tree | 59aafeca41a840b088622377df59b63033a5ae15 /llvm/lib/Target/X86 | |
| parent | f290912d2248687e688779d1d89999df56c14a09 (diff) | |
| download | bcm5719-llvm-65f9d9cd324fc12f8bf90fa67477e2ddd90803d6.tar.gz bcm5719-llvm-65f9d9cd324fc12f8bf90fa67477e2ddd90803d6.zip | |
Revert "[X86] Elide references to _chkstk for dynamic allocas"
This reverts commit r262370.
It turns out there is code out there that does sequences of allocas
greater than 4K: http://crbug.com/591404
The goal of this change was to improve the code size of inalloca call
sequences, but we got tangled up in the mess of dynamic allocas.
Instead, we should come back later with a separate MI pass that uses
dominance to optimize the full sequence. This should also be able to
remove the often unneeded stacksave/stackrestore pairs around the call.
llvm-svn: 262505
Diffstat (limited to 'llvm/lib/Target/X86')
| -rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index e86c00bb36a..596f487681c 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -16378,8 +16378,9 @@ SDValue X86TargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const { MachineFunction &MF = DAG.getMachineFunction(); - const Function *F = MF.getFunction(); bool SplitStack = MF.shouldSplitStack(); + bool Lower = (Subtarget.isOSWindows() && !Subtarget.isTargetMachO()) || + SplitStack; SDLoc dl(Op); // Get the inputs. @@ -16393,45 +16394,21 @@ X86TargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op, // pointer when other instructions are using the stack. Chain = DAG.getCALLSEQ_START(Chain, DAG.getIntPtrConstant(0, dl, true), dl); - const X86RegisterInfo *RegInfo = Subtarget.getRegisterInfo(); bool Is64Bit = Subtarget.is64Bit(); MVT SPTy = getPointerTy(DAG.getDataLayout()); - bool CheckStack = SplitStack; - if (!CheckStack && Subtarget.isOSWindows() && !Subtarget.isTargetMachO()) { - // The Windows ABI requires us to probe the stack for allocations beyond - // the probe size. - if (auto *SizeC = dyn_cast<ConstantSDNode>(Size)) { - // Try to elide the probe if we can prove that this dynamic allocation is - // smaller than the probe size. - unsigned StackProbeSize = 4096; - if (F->hasFnAttribute("stack-probe-size")) - F->getFnAttribute("stack-probe-size") - .getValueAsString() - .getAsInteger(0, StackProbeSize); - unsigned AlignedAlloc = SizeC->getZExtValue(); - // Round the dynamic alloca's size up to it's alignment. - if (Align) - AlignedAlloc = alignTo(AlignedAlloc, Align); - - // If the aligned allocation is smaller than the probe size, then we don't - // need to probe the stack. - CheckStack = AlignedAlloc >= StackProbeSize; - } else { - // We cannot tell how big this dynamic alloca will be, probe the stack. - CheckStack = true; - } - } - SDValue Result; - if (!CheckStack) { + if (!Lower) { const TargetLowering &TLI = DAG.getTargetLoweringInfo(); unsigned SPReg = TLI.getStackPointerRegisterToSaveRestore(); assert(SPReg && "Target cannot require DYNAMIC_STACKALLOC expansion and" " not tell us which reg is the stack pointer!"); + EVT VT = Node->getValueType(0); + SDValue Tmp3 = Node->getOperand(2); SDValue SP = DAG.getCopyFromReg(Chain, dl, SPReg, VT); Chain = SP.getValue(1); + unsigned Align = cast<ConstantSDNode>(Tmp3)->getZExtValue(); const TargetFrameLowering &TFI = *Subtarget.getFrameLowering(); unsigned StackAlign = TFI.getStackAlignment(); Result = DAG.getNode(ISD::SUB, dl, VT, SP, Size); // Value @@ -16445,6 +16422,8 @@ X86TargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op, if (Is64Bit) { // The 64 bit implementation of segmented stacks needs to clobber both r10 // r11. This makes it impossible to use it along with nested parameters. + const Function *F = MF.getFunction(); + for (Function::const_arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I) if (I->hasNestAttr()) @@ -16467,6 +16446,7 @@ X86TargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op, Chain = DAG.getNode(X86ISD::WIN_ALLOCA, dl, NodeTys, Chain, Flag); + const X86RegisterInfo *RegInfo = Subtarget.getRegisterInfo(); unsigned SPReg = RegInfo->getStackRegister(); SDValue SP = DAG.getCopyFromReg(Chain, dl, SPReg, SPTy); Chain = SP.getValue(1); |

