Update clang to use the updated LLVM EH instructions
Depends on D15139.
Reviewers: rnk
Differential Revision: http://reviews.llvm.org/D15140
llvm-svn: 255423
diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index 5b6e497..245d6a7 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -246,13 +246,6 @@
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 @@
// 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 @@
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();