diff options
author | Reid Kleckner <rnk@google.com> | 2015-10-09 23:34:53 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2015-10-09 23:34:53 +0000 |
commit | 14e773500e036de57ed0ca4af6fddc1f8b6767d8 (patch) | |
tree | c5d52fc4286cc63b981c1dadc86a18688868c6e7 /llvm/lib/Target | |
parent | eb7cd6c88928c617f2395b9e2ec262e4bfb43880 (diff) | |
download | bcm5719-llvm-14e773500e036de57ed0ca4af6fddc1f8b6767d8.tar.gz bcm5719-llvm-14e773500e036de57ed0ca4af6fddc1f8b6767d8.zip |
[WinEH] Delete the old landingpad implementation of Windows EH
The new implementation works at least as well as the old implementation
did.
Also delete the associated preparation tests. They don't exercise
interesting corner cases of the new implementation. All the codegen
tests of the EH tables have already been ported.
llvm-svn: 249918
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r-- | llvm/lib/Target/X86/X86WinEHState.cpp | 105 |
1 files changed, 16 insertions, 89 deletions
diff --git a/llvm/lib/Target/X86/X86WinEHState.cpp b/llvm/lib/Target/X86/X86WinEHState.cpp index 993879e399b..ed909c58e9b 100644 --- a/llvm/lib/Target/X86/X86WinEHState.cpp +++ b/llvm/lib/Target/X86/X86WinEHState.cpp @@ -429,14 +429,27 @@ void WinEHStatePass::unlinkExceptionRegistration(IRBuilder<> &Builder) { } void WinEHStatePass::addCXXStateStores(Function &F, WinEHFuncInfo &FuncInfo) { - calculateWinCXXEHStateNumbers(&F, FuncInfo); + // Set up RegNodeEscapeIndex + int RegNodeEscapeIndex = escapeRegNode(F); + FuncInfo.EHRegNodeEscapeIndex = RegNodeEscapeIndex; - // The base state for the parent is -1. + calculateWinCXXEHStateNumbers(&F, FuncInfo); addStateStoresToFunclet(RegNode, FuncInfo, F, -1); +} - // Set up RegNodeEscapeIndex +/// Assign every distinct landingpad a unique state number for SEH. Unlike C++ +/// EH, we can use this very simple algorithm while C++ EH cannot because catch +/// handlers aren't outlined and the runtime doesn't have to figure out which +/// catch handler frame to unwind to. +void WinEHStatePass::addSEHStateStores(Function &F, WinEHFuncInfo &FuncInfo) { + // Remember and return the index that we used. We save it in WinEHFuncInfo so + // that we can lower llvm.x86.seh.recoverfp later in filter functions without + // too much trouble. int RegNodeEscapeIndex = escapeRegNode(F); FuncInfo.EHRegNodeEscapeIndex = RegNodeEscapeIndex; + + calculateSEHStateNumbers(&F, FuncInfo); + addStateStoresToFunclet(RegNode, FuncInfo, F, -1); } /// Escape RegNode so that we can access it from child handlers. Find the call @@ -503,92 +516,6 @@ void WinEHStatePass::addStateStoresToFunclet(Value *ParentRegNode, } } -/// Assign every distinct landingpad a unique state number for SEH. Unlike C++ -/// EH, we can use this very simple algorithm while C++ EH cannot because catch -/// handlers aren't outlined and the runtime doesn't have to figure out which -/// catch handler frame to unwind to. -/// FIXME: __finally blocks are outlined, so this approach may break down there. -void WinEHStatePass::addSEHStateStores(Function &F, WinEHFuncInfo &FuncInfo) { - // Remember and return the index that we used. We save it in WinEHFuncInfo so - // that we can lower llvm.x86.seh.recoverfp later in filter functions without - // too much trouble. - int RegNodeEscapeIndex = escapeRegNode(F); - FuncInfo.EHRegNodeEscapeIndex = RegNodeEscapeIndex; - - // If this funciton uses the new EH IR, use the explicit state numbering - // algorithm and return early. - bool UsesLPads = false; - for (BasicBlock &BB : F) { - if (BB.isLandingPad()) { - UsesLPads = true; - break; - } - } - if (!UsesLPads) { - calculateSEHStateNumbers(&F, FuncInfo); - addStateStoresToFunclet(RegNode, FuncInfo, F, -1); - return; - } - // FIXME: Delete the rest of this code and clean things up when new EH is - // done. - - // Iterate all the instructions and emit state number stores. - int CurState = 0; - SmallPtrSet<BasicBlock *, 4> ExceptBlocks; - for (BasicBlock &BB : F) { - for (auto I = BB.begin(), E = BB.end(); I != E; ++I) { - if (auto *CI = dyn_cast<CallInst>(I)) { - auto *Intrin = dyn_cast<IntrinsicInst>(CI); - if (Intrin) { - // Calls that "don't throw" are considered to be able to throw asynch - // exceptions, but intrinsics cannot. - continue; - } - insertStateNumberStore(RegNode, CI, -1); - } else if (auto *II = dyn_cast<InvokeInst>(I)) { - // Look up the state number of the landingpad this unwinds to. - LandingPadInst *LPI = II->getUnwindDest()->getLandingPadInst(); - auto InsertionPair = - FuncInfo.EHPadStateMap.insert(std::make_pair(LPI, CurState)); - auto Iter = InsertionPair.first; - int &State = Iter->second; - bool Inserted = InsertionPair.second; - if (Inserted) { - // Each action consumes a state number. - auto *EHActions = cast<IntrinsicInst>(LPI->getNextNode()); - SmallVector<std::unique_ptr<ActionHandler>, 4> ActionList; - parseEHActions(EHActions, ActionList); - assert(!ActionList.empty()); - CurState += ActionList.size(); - State += ActionList.size() - 1; - - // Remember all the __except block targets. - for (auto &Handler : ActionList) { - if (auto *CH = dyn_cast<CatchHandler>(Handler.get())) { - auto *BA = cast<BlockAddress>(CH->getHandlerBlockOrFunc()); -#ifndef NDEBUG - for (BasicBlock *Pred : predecessors(BA->getBasicBlock())) - assert(Pred->isLandingPad() && - "WinEHPrepare failed to split block"); -#endif - ExceptBlocks.insert(BA->getBasicBlock()); - } - } - } - insertStateNumberStore(RegNode, II, State); - } - } - } - - // Insert llvm.x86.seh.restoreframe() into each __except block. - Function *RestoreFrame = - Intrinsic::getDeclaration(TheModule, Intrinsic::x86_seh_restoreframe); - for (BasicBlock *ExceptBB : ExceptBlocks) { - IRBuilder<> Builder(ExceptBB->begin()); - Builder.CreateCall(RestoreFrame, {}); - } -} - void WinEHStatePass::insertStateNumberStore(Value *ParentRegNode, Instruction *IP, int State) { IRBuilder<> Builder(IP); |