diff options
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/WinException.cpp | 21 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/WinException.h | 2 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp | 8 |
3 files changed, 17 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/WinException.cpp b/llvm/lib/CodeGen/AsmPrinter/WinException.cpp index 3999268b407..33eb3906fce 100644 --- a/llvm/lib/CodeGen/AsmPrinter/WinException.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/WinException.cpp @@ -299,12 +299,17 @@ const MCExpr *WinException::getOffsetPlusOne(const MCSymbol *OffsetOf, Asm->OutContext); } -int WinException::getFrameIndexOffset(int FrameIndex) { +int WinException::getFrameIndexOffset(int FrameIndex, WinEHFuncInfo &FuncInfo) { const TargetFrameLowering &TFI = *Asm->MF->getSubtarget().getFrameLowering(); unsigned UnusedReg; if (Asm->MAI->usesWindowsCFI()) return TFI.getFrameIndexReferenceFromSP(*Asm->MF, FrameIndex, UnusedReg); - return TFI.getFrameIndexReference(*Asm->MF, FrameIndex, UnusedReg); + // For 32-bit, offsets should be relative to the end of the EH registration + // node. For 64-bit, it's relative to SP at the end of the prologue. + assert(FuncInfo.EHRegNodeEndOffset != INT_MAX); + int Offset = TFI.getFrameIndexReference(*Asm->MF, FrameIndex, UnusedReg); + Offset += FuncInfo.EHRegNodeEndOffset; + return Offset; } namespace { @@ -613,7 +618,8 @@ void WinException::emitCXXFrameHandler3Table(const MachineFunction *MF) { int UnwindHelpOffset = 0; if (Asm->MAI->usesWindowsCFI()) - UnwindHelpOffset = getFrameIndexOffset(FuncInfo.UnwindHelpFrameIdx); + UnwindHelpOffset = + getFrameIndexOffset(FuncInfo.UnwindHelpFrameIdx, FuncInfo); MCSymbol *UnwindMapXData = nullptr; MCSymbol *TryBlockMapXData = nullptr; @@ -733,14 +739,7 @@ void WinException::emitCXXFrameHandler3Table(const MachineFunction *MF) { // emit an offset of zero, indicating that no copy will occur. const MCExpr *FrameAllocOffsetRef = nullptr; if (HT.CatchObj.FrameIndex != INT_MAX) { - int Offset = getFrameIndexOffset(HT.CatchObj.FrameIndex); - // For 32-bit, the catch object offset is relative to the end of the - // EH registration node. For 64-bit, it's relative to SP at the end of - // the prologue. - if (!shouldEmitPersonality) { - assert(FuncInfo.EHRegNodeEndOffset != INT_MAX); - Offset += FuncInfo.EHRegNodeEndOffset; - } + int Offset = getFrameIndexOffset(HT.CatchObj.FrameIndex, FuncInfo); FrameAllocOffsetRef = MCConstantExpr::create(Offset, Asm->OutContext); } else { FrameAllocOffsetRef = MCConstantExpr::create(0, Asm->OutContext); diff --git a/llvm/lib/CodeGen/AsmPrinter/WinException.h b/llvm/lib/CodeGen/AsmPrinter/WinException.h index 02134d6aa98..54c5f3a9a0e 100644 --- a/llvm/lib/CodeGen/AsmPrinter/WinException.h +++ b/llvm/lib/CodeGen/AsmPrinter/WinException.h @@ -77,7 +77,7 @@ class LLVM_LIBRARY_VISIBILITY WinException : public EHStreamer { /// given index. For targets using CFI (Win64, etc), this is relative to the /// established SP at the end of the prologue. For targets without CFI (Win32 /// only), it is relative to the frame pointer. - int getFrameIndexOffset(int FrameIndex); + int getFrameIndexOffset(int FrameIndex, WinEHFuncInfo &FuncInfo); public: //===--------------------------------------------------------------------===// diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp index c3744f7494f..52216c2c1e8 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp @@ -215,10 +215,14 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf, // are really data, and no instructions can live here. if (BB->isEHPad()) { const Instruction *I = BB->getFirstNonPHI(); - // FIXME: Don't mark SEH functions without __finally blocks as having + // If this is a non-landingpad EH pad, mark this function as using // funclets. - if (!isa<LandingPadInst>(I)) + // FIXME: SEH catchpads do not create funclets, so we could avoid setting + // this in such cases in order to improve frame layout. + if (!isa<LandingPadInst>(I)) { MMI.setHasEHFunclets(true); + MF->getFrameInfo()->setHasOpaqueSPAdjustment(true); + } if (isa<CatchEndPadInst>(I) || isa<CleanupEndPadInst>(I)) { assert(&*BB->begin() == I && "WinEHPrepare failed to remove PHIs from imaginary BBs"); |

