diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-06-16 18:54:06 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-06-16 18:54:06 +0000 |
commit | 0ebc9616b4045284168a2be5a8162502eecc8e5e (patch) | |
tree | 093c2c3fa6e52dfd46a312e01db5592f1a94c3d1 /llvm/lib/Target/X86/X86FrameLowering.cpp | |
parent | b9d28fbeb36e1d20dfb4523757de51256751b75d (diff) | |
download | bcm5719-llvm-0ebc9616b4045284168a2be5a8162502eecc8e5e.tar.gz bcm5719-llvm-0ebc9616b4045284168a2be5a8162502eecc8e5e.zip |
NFC; refactor getFrameIndexReferenceFromSP
Summary:
... into getFrameIndexReferencePreferSP. This change folds the
fail-then-retry logic into getFrameIndexReferencePreferSP.
There is a non-functional but behaviorial change in WinException --
earlier if `getFrameIndexReferenceFromSP` failed we'd trip an assert,
but now we'll silently use the (wrong) offset from the base pointer. I
could not write the assert I'd like to write ("FrameReg ==
StackRegister", like I've done in X86FrameLowering) since there is no
easy way to get to the stack register from WinException (happy to be
proven wrong here). One solution to this is to add a `bool
OnlyStackPointer` parameter to `getFrameIndexReferenceFromSP` that
asserts if it could not satisfy its promise of returning an offset from
a stack pointer, but that seems overkill.
Reviewers: rnk
Subscribers: sanjoy, mcrosier, llvm-commits
Differential Revision: http://reviews.llvm.org/D21427
llvm-svn: 272938
Diffstat (limited to 'llvm/lib/Target/X86/X86FrameLowering.cpp')
-rw-r--r-- | llvm/lib/Target/X86/X86FrameLowering.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/llvm/lib/Target/X86/X86FrameLowering.cpp b/llvm/lib/Target/X86/X86FrameLowering.cpp index 2be00ca1707..83446336fd7 100644 --- a/llvm/lib/Target/X86/X86FrameLowering.cpp +++ b/llvm/lib/Target/X86/X86FrameLowering.cpp @@ -1433,12 +1433,10 @@ static bool isFuncletReturnInstr(MachineInstr *MI) { unsigned X86FrameLowering::getPSPSlotOffsetFromSP(const MachineFunction &MF) const { const WinEHFuncInfo &Info = *MF.getWinEHFuncInfo(); - // getFrameIndexReferenceFromSP has an out ref parameter for the stack - // pointer register; pass a dummy that we ignore unsigned SPReg; - int Offset = *getFrameIndexReferenceFromSP(MF, Info.PSPSymFrameIdx, SPReg, - /*AllowSPAdjustment*/ true); - assert(Offset >= 0); + int Offset = getFrameIndexReferencePreferSP(MF, Info.PSPSymFrameIdx, SPReg, + /*IgnoreSPUpdates*/ true); + assert(Offset >= 0 && SPReg == TRI->getStackRegister()); return static_cast<unsigned>(Offset); } @@ -1722,11 +1720,11 @@ int X86FrameLowering::getFrameIndexReference(const MachineFunction &MF, int FI, return Offset + FPDelta; } -// Simplified from getFrameIndexReference keeping only StackPointer cases -Optional<int> -X86FrameLowering::getFrameIndexReferenceFromSP(const MachineFunction &MF, - int FI, unsigned &FrameReg, - bool AllowSPAdjustment) const { +int +X86FrameLowering::getFrameIndexReferencePreferSP(const MachineFunction &MF, + int FI, unsigned &FrameReg, + bool IgnoreSPUpdates) const { + const MachineFrameInfo *MFI = MF.getFrameInfo(); // Does not include any dynamic realign. const uint64_t StackSize = MFI->getStackSize(); @@ -1765,14 +1763,14 @@ X86FrameLowering::getFrameIndexReferenceFromSP(const MachineFunction &MF, if (MFI->isFixedObjectIndex(FI) && TRI->needsStackRealignment(MF) && !STI.isTargetWin64()) - return None; + return getFrameIndexReference(MF, FI, FrameReg); // If !hasReservedCallFrame the function might have SP adjustement in the // body. So, even though the offset is statically known, it depends on where // we are in the function. const TargetFrameLowering *TFI = MF.getSubtarget().getFrameLowering(); - if (!AllowSPAdjustment && !TFI->hasReservedCallFrame(MF)) - return None; + if (!IgnoreSPUpdates && !TFI->hasReservedCallFrame(MF)) + return getFrameIndexReference(MF, FI, FrameReg); // We don't handle tail calls, and shouldn't be seeing them either. assert(MF.getInfo<X86MachineFunctionInfo>()->getTCReturnAddrDelta() >= 0 && |