summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2017-06-29 13:58:24 +0000
committerDaniel Jasper <djasper@google.com>2017-06-29 13:58:24 +0000
commit559aa75382e941a1c0c2fc5724d5274c20f2adf8 (patch)
treec8f215d8add480f68484fcc2ef8043b94f967598 /llvm/lib/Target
parent8a44b7be76f35f26d56327952bd133a48c07f301 (diff)
downloadbcm5719-llvm-559aa75382e941a1c0c2fc5724d5274c20f2adf8.tar.gz
bcm5719-llvm-559aa75382e941a1c0c2fc5724d5274c20f2adf8.zip
Revert "r306529 - [X86] Correct dwarf unwind information in function epilogue"
I am 99% sure that this breaks the PPC ASAN build bot: http://lab.llvm.org:8011/builders/sanitizer-ppc64be-linux/builds/3112/steps/64-bit%20check-asan/logs/stdio If it doesn't go back to green, we can recommit (and fix the original commit message at the same time :) ). llvm-svn: 306676
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/X86/X86CallFrameOptimization.cpp18
-rw-r--r--llvm/lib/Target/X86/X86FrameLowering.cpp119
-rw-r--r--llvm/lib/Target/X86/X86FrameLowering.h2
3 files changed, 8 insertions, 131 deletions
diff --git a/llvm/lib/Target/X86/X86CallFrameOptimization.cpp b/llvm/lib/Target/X86/X86CallFrameOptimization.cpp
index a7d157b0dad..765af67de16 100644
--- a/llvm/lib/Target/X86/X86CallFrameOptimization.cpp
+++ b/llvm/lib/Target/X86/X86CallFrameOptimization.cpp
@@ -234,12 +234,6 @@ bool X86CallFrameOptimization::runOnMachineFunction(MachineFunction &MF) {
assert(isPowerOf2_32(SlotSize) && "Expect power of 2 stack slot size");
Log2SlotSize = Log2_32(SlotSize);
- // Set initial incoming and outgoing cfa offset and register values for basic
- // blocks. This is done here because this pass runs before PEI and can insert
- // CFI instructions.
- // TODO: Find a better solution to this problem.
- TFL->initializeCFIInfo(MF);
-
if (skipFunction(*MF.getFunction()) || !isLegal(MF))
return false;
@@ -542,13 +536,11 @@ void X86CallFrameOptimization::adjustCallSequence(MachineFunction &MF,
// For debugging, when using SP-based CFA, we need to adjust the CFA
// offset after each push.
// TODO: This is needed only if we require precise CFA.
- if (!TFL->hasFP(MF)) {
- TFL->BuildCFI(MBB, std::next(Push), DL,
- MCCFIInstruction::createAdjustCfaOffset(nullptr, SlotSize));
- // Update the CFI information for MBB and it's successors.
- MBB.updateCFIInfo(std::next(Push));
- MBB.updateCFIInfoSucc();
- }
+ if (!TFL->hasFP(MF))
+ TFL->BuildCFI(
+ MBB, std::next(Push), DL,
+ MCCFIInstruction::createAdjustCfaOffset(nullptr, SlotSize));
+
MBB.erase(MOV);
}
diff --git a/llvm/lib/Target/X86/X86FrameLowering.cpp b/llvm/lib/Target/X86/X86FrameLowering.cpp
index feac493aa90..e3aa227702b 100644
--- a/llvm/lib/Target/X86/X86FrameLowering.cpp
+++ b/llvm/lib/Target/X86/X86FrameLowering.cpp
@@ -958,8 +958,7 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF,
? getX86SubSuperRegister(FramePtr, 64) : FramePtr;
unsigned BasePtr = TRI->getBaseRegister();
bool HasWinCFI = false;
- bool InsertedCFI = false;
-
+
// Debug location must be unknown since the first debug location is used
// to determine the end of the prologue.
DebugLoc DL;
@@ -1094,9 +1093,6 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF,
assert(StackSize);
BuildCFI(MBB, MBBI, DL,
MCCFIInstruction::createDefCfaOffset(nullptr, 2 * stackGrowth));
- MBB.setDefOffset(true);
- MBB.updateCFIInfo(std::prev(MBBI));
- InsertedCFI = true;
// Change the rule for the FramePtr to be an "offset" rule.
unsigned DwarfFramePtr = TRI->getDwarfRegNum(MachineFramePtr, true);
@@ -1125,9 +1121,6 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF,
unsigned DwarfFramePtr = TRI->getDwarfRegNum(MachineFramePtr, true);
BuildCFI(MBB, MBBI, DL, MCCFIInstruction::createDefCfaRegister(
nullptr, DwarfFramePtr));
- MBB.setDefRegister(true);
- MBB.updateCFIInfo(std::prev(MBBI));
- InsertedCFI = true;
}
}
} else {
@@ -1159,9 +1152,6 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF,
assert(StackSize);
BuildCFI(MBB, MBBI, DL,
MCCFIInstruction::createDefCfaOffset(nullptr, StackOffset));
- MBB.setDefOffset(true);
- MBB.updateCFIInfo(std::prev(MBBI));
- InsertedCFI = true;
StackOffset += stackGrowth;
}
@@ -1427,9 +1417,6 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF,
assert(StackSize);
BuildCFI(MBB, MBBI, DL, MCCFIInstruction::createDefCfaOffset(
nullptr, -StackSize + stackGrowth));
- MBB.setDefOffset(true);
- MBB.updateCFIInfo(std::prev(MBBI));
- InsertedCFI = true;
}
// Emit DWARF info specifying the offsets of the callee-saved registers.
@@ -1451,9 +1438,6 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF,
// At this point we know if the function has WinCFI or not.
MF.setHasWinCFI(HasWinCFI);
-
- if (InsertedCFI)
- MBB.updateCFIInfoSucc();
}
bool X86FrameLowering::canUseLEAForSPInEpilogue(
@@ -1564,12 +1548,6 @@ void X86FrameLowering::emitEpilogue(MachineFunction &MF,
unsigned CSSize = X86FI->getCalleeSavedFrameSize();
uint64_t NumBytes = 0;
- bool NeedsDwarfCFI = (MF.getMMI().hasDebugInfo() ||
- MF.getFunction()->needsUnwindTableEntry()) &&
- (!MF.getSubtarget<X86Subtarget>().isTargetDarwin() &&
- !MF.getSubtarget<X86Subtarget>().isOSWindows());
- bool InsertedCFI = false;
-
if (RetOpcode && *RetOpcode == X86::CATCHRET) {
// SEH shouldn't use catchret.
assert(!isAsynchronousEHPersonality(
@@ -1604,17 +1582,6 @@ void X86FrameLowering::emitEpilogue(MachineFunction &MF,
BuildMI(MBB, MBBI, DL,
TII.get(Is64Bit ? X86::POP64r : X86::POP32r), MachineFramePtr)
.setMIFlag(MachineInstr::FrameDestroy);
- if (NeedsDwarfCFI) {
- unsigned DwarfStackPtr =
- TRI->getDwarfRegNum(Is64Bit ? X86::RSP : X86::ESP, true);
- BuildCFI(MBB, MBBI, DL, MCCFIInstruction::createDefCfa(
- nullptr, DwarfStackPtr, -SlotSize));
- --MBBI;
- MBB.setDefOffset(true);
- MBB.setDefRegister(true);
- MBB.updateCFIInfo(MBBI);
- InsertedCFI = true;
- }
} else {
NumBytes = StackSize - CSSize;
}
@@ -1699,14 +1666,6 @@ void X86FrameLowering::emitEpilogue(MachineFunction &MF,
} else if (NumBytes) {
// Adjust stack pointer back: ESP += numbytes.
emitSPUpdate(MBB, MBBI, NumBytes, /*InEpilogue=*/true);
- if (!hasFP(MF) && NeedsDwarfCFI) {
- // Define the current CFA rule to use the provided offset.
- BuildCFI(MBB, MBBI, DL, MCCFIInstruction::createDefCfaOffset(
- nullptr, -CSSize - SlotSize));
- MBB.setDefOffset(true);
- MBB.updateCFIInfo(std::prev(MBBI));
- InsertedCFI = true;
- }
--MBBI;
}
@@ -1719,26 +1678,6 @@ void X86FrameLowering::emitEpilogue(MachineFunction &MF,
if (NeedsWinCFI && MF.hasWinCFI())
BuildMI(MBB, MBBI, DL, TII.get(X86::SEH_Epilogue));
- if (!hasFP(MF) && NeedsDwarfCFI) {
- MBBI = FirstCSPop;
- int64_t Offset = -CSSize - SlotSize;
- // Mark callee-saved pop instruction.
- // Define the current CFA rule to use the provided offset.
- while (MBBI != MBB.end()) {
- MachineBasicBlock::iterator PI = MBBI;
- unsigned Opc = PI->getOpcode();
- ++MBBI;
- if (Opc == X86::POP32r || Opc == X86::POP64r) {
- Offset += SlotSize;
- BuildCFI(MBB, MBBI, DL,
- MCCFIInstruction::createDefCfaOffset(nullptr, Offset));
- MBB.setDefOffset(true);
- MBB.updateCFIInfo(std::prev(MBBI));
- InsertedCFI = true;
- }
- }
- }
-
if (!RetOpcode || !isTailCallOpcode(*RetOpcode)) {
// Add the return addr area delta back since we are not tail calling.
int Offset = -1 * X86FI->getTCReturnAddrDelta();
@@ -1751,9 +1690,6 @@ void X86FrameLowering::emitEpilogue(MachineFunction &MF,
emitSPUpdate(MBB, MBBI, Offset, /*InEpilogue=*/true);
}
}
-
- if (InsertedCFI)
- MBB.updateCFIInfoSucc();
}
int X86FrameLowering::getFrameIndexReference(const MachineFunction &MF, int FI,
@@ -2428,19 +2364,6 @@ void X86FrameLowering::adjustForSegmentedStacks(
checkMBB->addSuccessor(allocMBB);
checkMBB->addSuccessor(&PrologueMBB);
- int InitialOffset = TRI->getSlotSize();
- unsigned InitialRegister = TRI->getDwarfRegNum(StackPtr, true);
- // Set CFI info for checkMBB.
- checkMBB->setIncomingCFAOffset(InitialOffset);
- checkMBB->setIncomingCFARegister(InitialRegister);
- checkMBB->setOutgoingCFAOffset(InitialOffset);
- checkMBB->setOutgoingCFARegister(InitialRegister);
- // Set CFI info for allocMBB.
- allocMBB->setIncomingCFAOffset(InitialOffset);
- allocMBB->setIncomingCFARegister(InitialRegister);
- allocMBB->setOutgoingCFAOffset(InitialOffset);
- allocMBB->setOutgoingCFARegister(InitialRegister);
-
#ifdef EXPENSIVE_CHECKS
MF.verify();
#endif
@@ -2612,19 +2535,6 @@ void X86FrameLowering::adjustForHiPEPrologue(
stackCheckMBB->addSuccessor(incStackMBB, {1, 100});
incStackMBB->addSuccessor(&PrologueMBB, {99, 100});
incStackMBB->addSuccessor(incStackMBB, {1, 100});
-
- int InitialOffset = TRI->getSlotSize();
- unsigned InitialRegister = TRI->getDwarfRegNum(StackPtr, true);
- // Set CFI info to stackCheckMBB.
- stackCheckMBB->setIncomingCFAOffset(InitialOffset);
- stackCheckMBB->setIncomingCFARegister(InitialRegister);
- stackCheckMBB->setOutgoingCFAOffset(InitialOffset);
- stackCheckMBB->setOutgoingCFARegister(InitialRegister);
- // Set CFI info to incStackMBB.
- incStackMBB->setIncomingCFAOffset(InitialOffset);
- incStackMBB->setIncomingCFARegister(InitialRegister);
- incStackMBB->setOutgoingCFAOffset(InitialOffset);
- incStackMBB->setOutgoingCFARegister(InitialRegister);
}
#ifdef EXPENSIVE_CHECKS
MF.verify();
@@ -2730,7 +2640,6 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
bool WindowsCFI = MF.getTarget().getMCAsmInfo()->usesWindowsCFI();
bool DwarfCFI = !WindowsCFI &&
(MMI.hasDebugInfo() || Fn->needsUnwindTableEntry());
- bool InsertedCFI = false;
// If we have any exception handlers in this function, and we adjust
// the SP before calls, we may need to indicate this to the unwinder
@@ -2756,12 +2665,10 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
// TODO: This is needed only if we require precise CFA.
// If this is a callee-pop calling convention, emit a CFA adjust for
// the amount the callee popped.
- if (isDestroy && InternalAmt && DwarfCFI && !hasFP(MF)) {
+ if (isDestroy && InternalAmt && DwarfCFI && !hasFP(MF))
BuildCFI(MBB, InsertPos, DL,
MCCFIInstruction::createAdjustCfaOffset(nullptr, -InternalAmt));
- MBB.updateCFIInfo(std::prev(InsertPos));
- InsertedCFI = true;
- }
+
// Add Amount to SP to destroy a frame, or subtract to setup.
int64_t StackAdjustment = isDestroy ? Amount : -Amount;
int64_t CfaAdjustment = -StackAdjustment;
@@ -2795,13 +2702,9 @@ eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
BuildCFI(MBB, InsertPos, DL,
MCCFIInstruction::createAdjustCfaOffset(nullptr,
CfaAdjustment));
- MBB.updateCFIInfo(std::prev(InsertPos));
- InsertedCFI = true;
}
}
- if (InsertedCFI) MBB.updateCFIInfoSucc();
-
return I;
}
@@ -2923,22 +2826,6 @@ MachineBasicBlock::iterator X86FrameLowering::restoreWin32EHStackPointers(
return MBBI;
}
-void X86FrameLowering::initializeCFIInfo(MachineFunction &MF) const {
- int InitialOffset = TRI->getSlotSize();
- unsigned InitialRegister = TRI->getDwarfRegNum(StackPtr, true);
- // Initialize CFI info if it hasn't already been initialized.
- for (auto &MBB : MF) {
- if (MBB.getIncomingCFAOffset() == -1)
- MBB.setIncomingCFAOffset(InitialOffset);
- if (MBB.getOutgoingCFAOffset() == -1)
- MBB.setOutgoingCFAOffset(InitialOffset);
- if (MBB.getIncomingCFARegister() == 0)
- MBB.setIncomingCFARegister(InitialRegister);
- if (MBB.getOutgoingCFARegister() == 0)
- MBB.setOutgoingCFARegister(InitialRegister);
- }
-}
-
namespace {
// Struct used by orderFrameObjects to help sort the stack objects.
struct X86FrameSortingObject {
diff --git a/llvm/lib/Target/X86/X86FrameLowering.h b/llvm/lib/Target/X86/X86FrameLowering.h
index 60edf842980..7d214cabad5 100644
--- a/llvm/lib/Target/X86/X86FrameLowering.h
+++ b/llvm/lib/Target/X86/X86FrameLowering.h
@@ -177,8 +177,6 @@ public:
MachineBasicBlock::iterator MBBI,
const DebugLoc &DL, bool RestoreSP = false) const;
- void initializeCFIInfo(MachineFunction &MF) const override;
-
private:
uint64_t calculateMaxStackAlign(const MachineFunction &MF) const;
OpenPOWER on IntegriCloud