summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGException.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2015-09-10 18:39:41 +0000
committerReid Kleckner <rnk@google.com>2015-09-10 18:39:41 +0000
commitbb34b60359ec45607b1cd4e875377cacbe5564ab (patch)
treedc2f9823699eccf9a9299158cd165c7d8fb3402d /clang/lib/CodeGen/CGException.cpp
parent7cb25c9b69c9095ea268b13c4b75d92e3f2ac3e9 (diff)
downloadbcm5719-llvm-bb34b60359ec45607b1cd4e875377cacbe5564ab.tar.gz
bcm5719-llvm-bb34b60359ec45607b1cd4e875377cacbe5564ab.zip
[SEH] Use catchret in the new EH IR like we do for C++
Also add tests for SEH with the new IRGen. llvm-svn: 247318
Diffstat (limited to 'clang/lib/CodeGen/CGException.cpp')
-rw-r--r--clang/lib/CodeGen/CGException.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp
index 5549239a8f7..1a20403e84e 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -1807,7 +1807,7 @@ void CodeGenFunction::EnterSEHTryStmt(const SEHTryStmt &S) {
HelperCGF.GenerateSEHFilterFunction(*this, *Except);
llvm::Constant *OpaqueFunc =
llvm::ConstantExpr::getBitCast(FilterFunc, Int8PtrTy);
- CatchScope->setHandler(0, OpaqueFunc, createBasicBlock("__except"));
+ CatchScope->setHandler(0, OpaqueFunc, createBasicBlock("__except.ret"));
}
void CodeGenFunction::ExitSEHTryStmt(const SEHTryStmt &S) {
@@ -1848,6 +1848,18 @@ void CodeGenFunction::ExitSEHTryStmt(const SEHTryStmt &S) {
EmitBlockAfterUses(ExceptBB);
+ if (CGM.getCodeGenOpts().NewMSEH) {
+ // __except blocks don't get outlined into funclets, so immediately do a
+ // catchret.
+ llvm::BasicBlock *CatchPadBB = ExceptBB->getSinglePredecessor();
+ assert(CatchPadBB && "only ExceptBB pred should be catchpad");
+ llvm::CatchPadInst *CPI =
+ cast<llvm::CatchPadInst>(CatchPadBB->getFirstNonPHI());
+ ExceptBB = createBasicBlock("__except");
+ Builder.CreateCatchRet(CPI, ExceptBB);
+ EmitBlock(ExceptBB);
+ }
+
// On Win64, the exception pointer is the exception code. Copy it to the slot.
if (CGM.getTarget().getTriple().getArch() != llvm::Triple::x86) {
llvm::Value *Code =
OpenPOWER on IntegriCloud