summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-10-05 20:48:15 +0000
committerJohn McCall <rjmccall@apple.com>2010-10-05 20:48:15 +0000
commite5dd32da11e703d1ff48731b7cb49c9e473aca2b (patch)
tree06f42b8d899ddd80097097a02a763d98f962a614 /clang/lib/CodeGen/CodeGenFunction.cpp
parent44e5c1f16cec053e3bce342bfa328e51c24b0a1b (diff)
downloadbcm5719-llvm-e5dd32da11e703d1ff48731b7cb49c9e473aca2b.tar.gz
bcm5719-llvm-e5dd32da11e703d1ff48731b7cb49c9e473aca2b.zip
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. llvm-svn: 115668
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 043195cecf1..56dccc1c0a4 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/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();
OpenPOWER on IntegriCloud