diff options
author | John McCall <rjmccall@apple.com> | 2010-10-05 20:48:15 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-10-05 20:48:15 +0000 |
commit | e71d60d2c948bef21443c3370a9922a2f58bcc3a (patch) | |
tree | fba401a66e633542e98232f411b69a6732e61f8d /lib/CodeGen/CodeGenFunction.cpp | |
parent | 0a0c3e72ce42f84f361c285e6963d44213ab6bea (diff) |
Teach PopCleanupBlock to correctly handle the possibility of branching through
a EH-only cleanup as part of a fallthrough branch-through. That this happens
for this test case is actually a separate bug.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@115668 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 043195cecf..56dccc1c0a 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -846,26 +846,31 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) { llvm::BasicBlock *FallthroughSource = Builder.GetInsertBlock(); bool HasFallthrough = (FallthroughSource != 0 && IsActive); - // As a kindof crazy internal case, branch-through fall-throughs - // leave the insertion point set to the end of the last cleanup. + // Branch-through fall-throughs leave the insertion point set to the + // end of the last cleanup, which points to the current scope. The + // rest of IR gen doesn't need to worry about this; it only happens + // during the execution of PopCleanupBlocks(). bool HasPrebranchedFallthrough = (FallthroughSource && FallthroughSource->getTerminator()); + // If this is a normal cleanup, then having a prebranched + // fallthrough implies that the fallthrough source unconditionally + // jumps here. + assert(!Scope.isNormalCleanup() || !HasPrebranchedFallthrough || + (Scope.getNormalBlock() && + FallthroughSource->getTerminator()->getSuccessor(0) + == Scope.getNormalBlock())); + bool RequiresNormalCleanup = false; if (Scope.isNormalCleanup() && (HasFixups || HasExistingBranches || HasFallthrough)) { RequiresNormalCleanup = true; } - assert(!HasPrebranchedFallthrough || RequiresNormalCleanup || !IsActive); - assert(!HasPrebranchedFallthrough || - (Scope.isNormalCleanup() && Scope.getNormalBlock() && - FallthroughSource->getTerminator()->getSuccessor(0) - == Scope.getNormalBlock())); - // Even if we don't need the normal cleanup, we might still have // prebranched fallthrough to worry about. - if (!RequiresNormalCleanup && HasPrebranchedFallthrough) { + if (Scope.isNormalCleanup() && !RequiresNormalCleanup && + HasPrebranchedFallthrough) { assert(!IsActive); llvm::BasicBlock *NormalEntry = Scope.getNormalBlock(); |