diff options
author | Reid Kleckner <rnk@google.com> | 2015-08-27 23:27:47 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2015-08-27 23:27:47 +0000 |
commit | 0e2882345daead6cd9368eda4107e860d9141e35 (patch) | |
tree | be2bbccebdc6d0f2648fe9612ff4338b1f8b4f2f /llvm/lib/Target/X86/X86WinEHState.cpp | |
parent | 67bc8d6b3f69f83e6f2688d960b8a273cee57a20 (diff) | |
download | bcm5719-llvm-0e2882345daead6cd9368eda4107e860d9141e35.tar.gz bcm5719-llvm-0e2882345daead6cd9368eda4107e860d9141e35.zip |
[WinEH] Add some support for code generating catchpad
We can now run 32-bit programs with empty catch bodies. The next step
is to change PEI so that we get funclet prologues and epilogues.
llvm-svn: 246235
Diffstat (limited to 'llvm/lib/Target/X86/X86WinEHState.cpp')
-rw-r--r-- | llvm/lib/Target/X86/X86WinEHState.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86WinEHState.cpp b/llvm/lib/Target/X86/X86WinEHState.cpp index d039a0d4ca6..19f574ad746 100644 --- a/llvm/lib/Target/X86/X86WinEHState.cpp +++ b/llvm/lib/Target/X86/X86WinEHState.cpp @@ -471,6 +471,8 @@ int WinEHStatePass::escapeRegNode(Function &F) { void WinEHStatePass::addCXXStateStoresToFunclet(Value *ParentRegNode, WinEHFuncInfo &FuncInfo, Function &F, int BaseState) { + Function *RestoreFrame = + Intrinsic::getDeclaration(TheModule, Intrinsic::x86_seh_restoreframe); // Iterate all the instructions and emit state number stores. for (BasicBlock &BB : F) { for (Instruction &I : BB) { @@ -489,6 +491,14 @@ void WinEHStatePass::addCXXStateStoresToFunclet(Value *ParentRegNode, insertStateNumberStore(ParentRegNode, II, State); } } + + // Insert calls to llvm.x86.seh.restoreframe at catchret destinations. + if (auto *CR = dyn_cast<CatchReturnInst>(BB.getTerminator())) { + //llvm::errs() << "BB: " << BB << '\n'; + //llvm::errs() << "CR->getSuccessor(): " << *CR->getSuccessor() << '\n'; + IRBuilder<> Builder(CR->getSuccessor()->begin()); + Builder.CreateCall(RestoreFrame, {}); + } } } |