diff options
Diffstat (limited to 'llvm/lib/Target/X86/X86CallFrameOptimization.cpp')
-rw-r--r-- | llvm/lib/Target/X86/X86CallFrameOptimization.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/llvm/lib/Target/X86/X86CallFrameOptimization.cpp b/llvm/lib/Target/X86/X86CallFrameOptimization.cpp index 765af67de16..a7d157b0dad 100644 --- a/llvm/lib/Target/X86/X86CallFrameOptimization.cpp +++ b/llvm/lib/Target/X86/X86CallFrameOptimization.cpp @@ -234,6 +234,12 @@ 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; @@ -536,11 +542,13 @@ 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)); - + 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(); + } MBB.erase(MOV); } |