diff options
author | Reid Kleckner <rnk@google.com> | 2015-10-08 21:14:56 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2015-10-08 21:14:56 +0000 |
commit | 55391524043b55115dbec692fd898afb676a3cb4 (patch) | |
tree | de9da3fe2f43a1d380bebf0d765a74a4b893081f /clang/lib/CodeGen/CGException.cpp | |
parent | 5beec213e24139e99ebbf1b35ca9731849f8843a (diff) | |
download | bcm5719-llvm-55391524043b55115dbec692fd898afb676a3cb4.tar.gz bcm5719-llvm-55391524043b55115dbec692fd898afb676a3cb4.zip |
[WinEH] Push cleanupendpad scopes around exceptional cleanups
We were only doing this for SEH as a special case. Generalize it to all
cleanups.
llvm-svn: 249748
Diffstat (limited to 'clang/lib/CodeGen/CGException.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGException.cpp | 30 |
1 files changed, 3 insertions, 27 deletions
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index 16f6e83647b..2c1ede4b76d 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -1410,10 +1410,8 @@ void CodeGenFunction::EmitSEHTryStmt(const SEHTryStmt &S) { namespace { struct PerformSEHFinally final : EHScopeStack::Cleanup { llvm::Function *OutlinedFinally; - EHScopeStack::stable_iterator EnclosingScope; - PerformSEHFinally(llvm::Function *OutlinedFinally, - EHScopeStack::stable_iterator EnclosingScope) - : OutlinedFinally(OutlinedFinally), EnclosingScope(EnclosingScope) {} + PerformSEHFinally(llvm::Function *OutlinedFinally) + : OutlinedFinally(OutlinedFinally) {} void Emit(CodeGenFunction &CGF, Flags F) override { ASTContext &Context = CGF.getContext(); @@ -1438,28 +1436,7 @@ struct PerformSEHFinally final : EHScopeStack::Cleanup { CGM.getTypes().arrangeFreeFunctionCall(Args, FPT, /*chainCall=*/false); - // If this is the normal cleanup, just emit the call. - if (!F.isForEHCleanup()) { - CGF.EmitCall(FnInfo, OutlinedFinally, ReturnValueSlot(), Args); - return; - } - - // Build a cleanupendpad to unwind through. - llvm::BasicBlock *CleanupBB = CGF.Builder.GetInsertBlock(); - llvm::BasicBlock *CleanupEndBB = CGF.createBasicBlock("ehcleanup.end"); - llvm::Instruction *PadInst = CleanupBB->getFirstNonPHI(); - auto *CPI = cast<llvm::CleanupPadInst>(PadInst); - CGBuilderTy(CGF, CleanupEndBB) - .CreateCleanupEndPad(CPI, CGF.getEHDispatchBlock(EnclosingScope)); - - // Push and pop the cleanupendpad around the call. - CGF.EHStack.pushPadEnd(CleanupEndBB); CGF.EmitCall(FnInfo, OutlinedFinally, ReturnValueSlot(), Args); - CGF.EHStack.popPadEnd(); - - // Insert the catchendpad block here. - CGF.CurFn->getBasicBlockList().insertAfter(CGF.Builder.GetInsertBlock(), - CleanupEndBB); } }; } // end anonymous namespace @@ -1815,8 +1792,7 @@ void CodeGenFunction::EnterSEHTryStmt(const SEHTryStmt &S) { HelperCGF.GenerateSEHFinallyFunction(*this, *Finally); // Push a cleanup for __finally blocks. - EHStack.pushCleanup<PerformSEHFinally>(NormalAndEHCleanup, FinallyFunc, - EHStack.getInnermostEHScope()); + EHStack.pushCleanup<PerformSEHFinally>(NormalAndEHCleanup, FinallyFunc); return; } |