summaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/CGCleanup.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-12-12 05:39:21 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-12-12 05:39:21 +0000
commit29849678b042e40cbd64994ed8f7563500f6d48d (patch)
tree04e40b51a403be4934b2df16bf0565dc4a01ae7d /lib/CodeGen/CGCleanup.cpp
parent222a971bb76cba8ae1f9a62981304fa7c4c3969d (diff)
Update clang to use the updated LLVM EH instructions
Depends on D15139. Reviewers: rnk Differential Revision: http://reviews.llvm.org/D15140 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@255423 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCleanup.cpp')
-rw-r--r--lib/CodeGen/CGCleanup.cpp37
1 files changed, 6 insertions, 31 deletions
diff --git a/lib/CodeGen/CGCleanup.cpp b/lib/CodeGen/CGCleanup.cpp
index 5b6e497673..245d6a7e4b 100644
--- a/lib/CodeGen/CGCleanup.cpp
+++ b/lib/CodeGen/CGCleanup.cpp
@@ -246,13 +246,6 @@ void EHScopeStack::pushTerminate() {
InnermostEHScope = stable_begin();
}
-void EHScopeStack::pushPadEnd(llvm::BasicBlock *PadEndBB) {
- char *Buffer = allocate(EHPadEndScope::getSize());
- auto *CES = new (Buffer) EHPadEndScope(InnermostEHScope);
- CES->setCachedEHDispatchBlock(PadEndBB);
- InnermostEHScope = stable_begin();
-}
-
/// Remove any 'null' fixups on the stack. However, we can't pop more
/// fixups than the fixup depth on the innermost normal cleanup, or
/// else fixups that we try to add to that cleanup will end up in the
@@ -909,24 +902,17 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) {
// throwing cleanups. For funclet EH personalities, the cleanupendpad models
// program termination when cleanups throw.
bool PushedTerminate = false;
- SaveAndRestore<bool> RestoreIsCleanupPadScope(IsCleanupPadScope);
+ SaveAndRestore<llvm::Instruction *> RestoreCurrentFuncletPad(
+ CurrentFuncletPad);
llvm::CleanupPadInst *CPI = nullptr;
- llvm::BasicBlock *CleanupEndBB = nullptr;
if (!EHPersonality::get(*this).usesFuncletPads()) {
EHStack.pushTerminate();
PushedTerminate = true;
} else {
- CPI = Builder.CreateCleanupPad({});
-
- // Build a cleanupendpad to unwind through. Our insertion point should be
- // in the cleanuppad block.
- CleanupEndBB = createBasicBlock("ehcleanup.end");
- CGBuilderTy(*this, CleanupEndBB).CreateCleanupEndPad(CPI, NextAction);
- EHStack.pushPadEnd(CleanupEndBB);
-
- // Mark that we're inside a cleanuppad to block inlining.
- // FIXME: Remove this once the inliner knows when it's safe to do so.
- IsCleanupPadScope = true;
+ llvm::Value *ParentPad = CurrentFuncletPad;
+ if (!ParentPad)
+ ParentPad = llvm::ConstantTokenNone::get(CGM.getLLVMContext());
+ CurrentFuncletPad = CPI = Builder.CreateCleanupPad(ParentPad);
}
// We only actually emit the cleanup code if the cleanup is either
@@ -941,17 +927,6 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) {
else
Builder.CreateBr(NextAction);
- // Insert the cleanupendpad block here, if it has any uses.
- if (CleanupEndBB) {
- EHStack.popPadEnd();
- if (CleanupEndBB->hasNUsesOrMore(1)) {
- CurFn->getBasicBlockList().insertAfter(
- Builder.GetInsertBlock()->getIterator(), CleanupEndBB);
- } else {
- delete CleanupEndBB;
- }
- }
-
// Leave the terminate scope.
if (PushedTerminate)
EHStack.popTerminate();