diff options
| author | Reid Kleckner <rnk@google.com> | 2015-09-09 21:10:03 +0000 |
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2015-09-09 21:10:03 +0000 |
| commit | 94b704c4691a8b10eff156277976702475bdfd3e (patch) | |
| tree | e1a2622631516e9ea1177e4bc60ef8c45dfcaa7f /llvm/lib/CodeGen/SelectionDAG | |
| parent | 81f3ccb505f8a594703bfc574442bb5c8bb841e3 (diff) | |
| download | bcm5719-llvm-94b704c4691a8b10eff156277976702475bdfd3e.tar.gz bcm5719-llvm-94b704c4691a8b10eff156277976702475bdfd3e.zip | |
[SEH] Emit 32-bit SEH tables for the new EH IR
The 32-bit tables don't actually contain PC range data, so emitting them
is incredibly simple.
The 64-bit tables, on the other hand, use the same table for state
numbering as well as label ranges. This makes things more difficult, so
it will be implemented later.
llvm-svn: 247192
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp | 26 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 23 |
2 files changed, 33 insertions, 16 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp index 7bbb194ac19..15793f666ea 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp @@ -287,21 +287,31 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf, addSEHHandlersForLPads(LPads); } + // Calculate state numbers if we haven't already. WinEHFuncInfo &EHInfo = MMI.getWinEHFuncInfo(&fn); if (Personality == EHPersonality::MSVC_CXX) { - // Calculate state numbers and then map from funclet BBs to MBBs. const Function *WinEHParentFn = MMI.getWinEHParent(&fn); calculateWinCXXEHStateNumbers(WinEHParentFn, EHInfo); + } else { + const Function *WinEHParentFn = MMI.getWinEHParent(&fn); + calculateSEHStateNumbers(WinEHParentFn, EHInfo); + } + + // Map all BB references in the EH data to MBBs. for (WinEHTryBlockMapEntry &TBME : EHInfo.TryBlockMap) for (WinEHHandlerType &H : TBME.HandlerArray) - if (const auto *BB = dyn_cast<BasicBlock>(H.Handler)) - H.HandlerMBB = MBBMap[BB]; - // If there's an explicit EH registration node on the stack, record its - // frame index. - if (EHInfo.EHRegNode && EHInfo.EHRegNode->getParent()->getParent() == Fn) { - assert(StaticAllocaMap.count(EHInfo.EHRegNode)); - EHInfo.EHRegNodeFrameIndex = StaticAllocaMap[EHInfo.EHRegNode]; + if (const auto *BB = + dyn_cast<BasicBlock>(H.Handler.get<const Value *>())) + H.Handler = MBBMap[BB]; + for (SEHUnwindMapEntry &UME : EHInfo.SEHUnwindMap) { + const BasicBlock *BB = UME.Handler.get<const BasicBlock *>(); + UME.Handler = MBBMap[BB]; } + // If there's an explicit EH registration node on the stack, record its + // frame index. + if (EHInfo.EHRegNode && EHInfo.EHRegNode->getParent()->getParent() == Fn) { + assert(StaticAllocaMap.count(EHInfo.EHRegNode)); + EHInfo.EHRegNodeFrameIndex = StaticAllocaMap[EHInfo.EHRegNode]; } // Copy the state numbers to LandingPadInfo for the current function, which diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 1df4245bf0b..6fba18d60b2 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1989,7 +1989,6 @@ void SelectionDAGBuilder::visitInvoke(const InvokeInst &I) { // and catchendpads for successors. MachineBasicBlock *Return = FuncInfo.MBBMap[I.getSuccessor(0)]; const BasicBlock *EHPadBB = I.getSuccessor(1); - bool IsLandingPad = EHPadBB->isLandingPad(); const Value *Callee(I.getCalledValue()); const Function *Fn = dyn_cast<Function>(Callee); @@ -2025,16 +2024,26 @@ void SelectionDAGBuilder::visitInvoke(const InvokeInst &I) { // Catchpads are conditional branches that add real MBB destinations and // continue the loop. EH "end" pads are not real BBs and simply continue. SmallVector<MachineBasicBlock *, 1> UnwindDests; + bool IsMSVCCXX = classifyEHPersonality(FuncInfo.Fn->getPersonalityFn()) == + EHPersonality::MSVC_CXX; while (EHPadBB) { const Instruction *Pad = EHPadBB->getFirstNonPHI(); - if (isa<CleanupPadInst>(Pad) || isa<LandingPadInst>(Pad)) { - assert(FuncInfo.MBBMap[EHPadBB]); - // Stop on cleanup pads and landingpads. + if (isa<LandingPadInst>(Pad)) { + // Stop on landingpads. They are not funclets. UnwindDests.push_back(FuncInfo.MBBMap[EHPadBB]); break; + } else if (isa<CleanupPadInst>(Pad) || isa<LandingPadInst>(Pad)) { + // Stop on cleanup pads. Cleanups are always funclet entries for all known + // personalities. + UnwindDests.push_back(FuncInfo.MBBMap[EHPadBB]); + UnwindDests.back()->setIsEHFuncletEntry(); + break; } else if (const auto *CPI = dyn_cast<CatchPadInst>(Pad)) { // Add the catchpad handler to the possible destinations. UnwindDests.push_back(FuncInfo.MBBMap[CPI->getNormalDest()]); + // In MSVC C++, catchblocks are funclets and need prologues. + if (IsMSVCCXX) + UnwindDests.back()->setIsEHFuncletEntry(); EHPadBB = CPI->getUnwindDest(); } else if (const auto *CEPI = dyn_cast<CatchEndPadInst>(Pad)) { EHPadBB = CEPI->getUnwindDest(); @@ -2043,13 +2052,11 @@ void SelectionDAGBuilder::visitInvoke(const InvokeInst &I) { } } - // Update successor info + // Update successor info. // FIXME: The weights for catchpads will be wrong. addSuccessorWithWeight(InvokeMBB, Return); - for (auto *UnwindDest : UnwindDests) { + for (MachineBasicBlock *UnwindDest : UnwindDests) { UnwindDest->setIsEHPad(); - if (!IsLandingPad) - UnwindDest->setIsEHFuncletEntry(); addSuccessorWithWeight(InvokeMBB, UnwindDest); } |

