summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/MicrosoftCXXABI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/MicrosoftCXXABI.cpp')
-rw-r--r--clang/lib/CodeGen/MicrosoftCXXABI.cpp49
1 files changed, 13 insertions, 36 deletions
diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index 504dc3fa09b..369d21f3988 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -879,20 +879,15 @@ void MicrosoftCXXABI::emitRethrow(CodeGenFunction &CGF, bool isNoReturn) {
}
namespace {
-struct CallEndCatchMSVC final : EHScopeStack::Cleanup {
+struct CatchRetScope final : EHScopeStack::Cleanup {
llvm::CatchPadInst *CPI;
- CallEndCatchMSVC(llvm::CatchPadInst *CPI) : CPI(CPI) {}
+ CatchRetScope(llvm::CatchPadInst *CPI) : CPI(CPI) {}
void Emit(CodeGenFunction &CGF, Flags flags) override {
- if (CGF.CGM.getCodeGenOpts().NewMSEH) {
- llvm::BasicBlock *BB = CGF.createBasicBlock("catchret.dest");
- CGF.Builder.CreateCatchRet(CPI, BB);
- CGF.EmitBlock(BB);
- } else {
- CGF.EmitNounwindRuntimeCall(
- CGF.CGM.getIntrinsic(llvm::Intrinsic::eh_endcatch));
- }
+ llvm::BasicBlock *BB = CGF.createBasicBlock("catchret.dest");
+ CGF.Builder.CreateCatchRet(CPI, BB);
+ CGF.EmitBlock(BB);
}
};
}
@@ -902,39 +897,21 @@ void MicrosoftCXXABI::emitBeginCatch(CodeGenFunction &CGF,
// In the MS ABI, the runtime handles the copy, and the catch handler is
// responsible for destruction.
VarDecl *CatchParam = S->getExceptionDecl();
- llvm::Value *Exn = nullptr;
- llvm::Function *BeginCatch = nullptr;
- llvm::CatchPadInst *CPI = nullptr;
- bool NewEH = CGF.CGM.getCodeGenOpts().NewMSEH;
- if (!NewEH) {
- Exn = CGF.getExceptionFromSlot();
- BeginCatch = CGF.CGM.getIntrinsic(llvm::Intrinsic::eh_begincatch);
- } else {
- llvm::BasicBlock *CatchPadBB =
- CGF.Builder.GetInsertBlock()->getSinglePredecessor();
- CPI = cast<llvm::CatchPadInst>(CatchPadBB->getFirstNonPHI());
- }
+ llvm::BasicBlock *CatchPadBB =
+ CGF.Builder.GetInsertBlock()->getSinglePredecessor();
+ llvm::CatchPadInst *CPI =
+ cast<llvm::CatchPadInst>(CatchPadBB->getFirstNonPHI());
+
// If this is a catch-all or the catch parameter is unnamed, we don't need to
// emit an alloca to the object.
if (!CatchParam || !CatchParam->getDeclName()) {
- if (!NewEH) {
- llvm::Value *Args[2] = {Exn, llvm::Constant::getNullValue(CGF.Int8PtrTy)};
- CGF.EmitNounwindRuntimeCall(BeginCatch, Args);
- }
- CGF.EHStack.pushCleanup<CallEndCatchMSVC>(NormalCleanup, CPI);
+ CGF.EHStack.pushCleanup<CatchRetScope>(NormalCleanup, CPI);
return;
}
CodeGenFunction::AutoVarEmission var = CGF.EmitAutoVarAlloca(*CatchParam);
- if (!NewEH) {
- Address ParamAddr =
- CGF.Builder.CreateElementBitCast(var.getObjectAddress(CGF), CGF.Int8Ty);
- llvm::Value *Args[2] = {Exn, ParamAddr.getPointer()};
- CGF.EmitNounwindRuntimeCall(BeginCatch, Args);
- } else {
- CPI->setArgOperand(2, var.getObjectAddress(CGF).getPointer());
- }
- CGF.EHStack.pushCleanup<CallEndCatchMSVC>(NormalCleanup, CPI);
+ CPI->setArgOperand(2, var.getObjectAddress(CGF).getPointer());
+ CGF.EHStack.pushCleanup<CatchRetScope>(NormalCleanup, CPI);
CGF.EmitAutoVarCleanups(var);
}
OpenPOWER on IntegriCloud