summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2013-02-01 19:09:49 +0000
committerDavid Blaikie <dblaikie@gmail.com>2013-02-01 19:09:49 +0000
commit357aafb566cdaf5ac689d787f08db998545ce1e1 (patch)
tree4ab90c3ed7a6288290e8bda8738e2c1f36de88c6 /clang/lib/CodeGen/CodeGenFunction.cpp
parentd0ef72808ce5474add9ecbf8d7d6b5e7620b6d8e (diff)
downloadbcm5719-llvm-357aafb566cdaf5ac689d787f08db998545ce1e1.tar.gz
bcm5719-llvm-357aafb566cdaf5ac689d787f08db998545ce1e1.zip
Fix exception handling line table problems introduced by r173593
r173593 made us a little too eager to associate all code at the end of a function with the user-written 'return' line. This caused problems with breakpoints as they'd be set in exception handling code preceeding the actual non-exception return handling code, leading to the breakpoint never being hit in non-exceptional execution. This change restores the pre-r173593 exception handling line information where the cleanup code is associated with the '}' not the return line. llvm-svn: 174206
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 59e38e63d51..729cdba4dee 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -117,7 +117,7 @@ bool CodeGenFunction::hasAggregateLLVMType(QualType type) {
llvm_unreachable("unknown type kind!");
}
-bool CodeGenFunction::EmitReturnBlock() {
+void CodeGenFunction::EmitReturnBlock() {
// For cleanliness, we try to avoid emitting the return block for
// simple cases.
llvm::BasicBlock *CurBB = Builder.GetInsertBlock();
@@ -132,7 +132,7 @@ bool CodeGenFunction::EmitReturnBlock() {
delete ReturnBlock.getBlock();
} else
EmitBlock(ReturnBlock.getBlock());
- return false;
+ return;
}
// Otherwise, if the return block is the target of a single direct
@@ -144,11 +144,13 @@ bool CodeGenFunction::EmitReturnBlock() {
if (BI && BI->isUnconditional() &&
BI->getSuccessor(0) == ReturnBlock.getBlock()) {
// Reset insertion point, including debug location, and delete the branch.
+ // this is really subtle & only works because the next change in location
+ // will hit the caching in CGDebugInfo::EmitLocation & not override this
Builder.SetCurrentDebugLocation(BI->getDebugLoc());
Builder.SetInsertPoint(BI->getParent());
BI->eraseFromParent();
delete ReturnBlock.getBlock();
- return true;
+ return;
}
}
@@ -157,7 +159,6 @@ bool CodeGenFunction::EmitReturnBlock() {
// region.end for now.
EmitBlock(ReturnBlock.getBlock());
- return false;
}
static void EmitIfUsed(CodeGenFunction &CGF, llvm::BasicBlock *BB) {
@@ -171,6 +172,9 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
assert(BreakContinueStack.empty() &&
"mismatched push/pop in break/continue stack!");
+ if (CGDebugInfo *DI = getDebugInfo())
+ DI->EmitLocation(Builder, EndLoc);
+
// Pop any cleanups that might have been associated with the
// parameters. Do this in whatever block we're currently in; it's
// important to do this before we enter the return block or return
@@ -179,14 +183,13 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
PopCleanupBlocks(PrologueCleanupDepth);
// Emit function epilog (to return).
- bool MoveEndLoc = EmitReturnBlock();
+ EmitReturnBlock();
if (ShouldInstrumentFunction())
EmitFunctionInstrumentation("__cyg_profile_func_exit");
// Emit debug descriptor for function end.
if (CGDebugInfo *DI = getDebugInfo()) {
- if (!MoveEndLoc) DI->setLocation(EndLoc);
DI->EmitFunctionEnd(Builder);
}
OpenPOWER on IntegriCloud