summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2015-01-02 22:07:26 +0000
committerDavid Blaikie <dblaikie@gmail.com>2015-01-02 22:07:26 +0000
commitb9a23c91559a86dcdf7c6b9eba3e9fcbb383be6e (patch)
treeecdb37a6dfa370ced7d8260dfb5b80eee4a3ff0b /clang/lib/CodeGen/CodeGenFunction.cpp
parent61770ab26f4b11bf1c3c185bb4fe24e82397baf3 (diff)
downloadbcm5719-llvm-b9a23c91559a86dcdf7c6b9eba3e9fcbb383be6e.tar.gz
bcm5719-llvm-b9a23c91559a86dcdf7c6b9eba3e9fcbb383be6e.zip
DebugInfo: Provide a less subtle way to set the debug location of simple ret instructions
un-XFAILing the test XFAIL'd in r225086 after it regressed in r225083. llvm-svn: 225090
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 4e97f9bfe39..826171a46e2 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -158,7 +158,7 @@ TypeEvaluationKind CodeGenFunction::getEvaluationKind(QualType type) {
}
}
-void CodeGenFunction::EmitReturnBlock() {
+llvm::DebugLoc CodeGenFunction::EmitReturnBlock() {
// For cleanliness, we try to avoid emitting the return block for
// simple cases.
llvm::BasicBlock *CurBB = Builder.GetInsertBlock();
@@ -173,7 +173,7 @@ void CodeGenFunction::EmitReturnBlock() {
delete ReturnBlock.getBlock();
} else
EmitBlock(ReturnBlock.getBlock());
- return;
+ return llvm::DebugLoc();
}
// Otherwise, if the return block is the target of a single direct
@@ -184,15 +184,13 @@ void CodeGenFunction::EmitReturnBlock() {
dyn_cast<llvm::BranchInst>(*ReturnBlock.getBlock()->user_begin());
if (BI && BI->isUnconditional() &&
BI->getSuccessor(0) == ReturnBlock.getBlock()) {
- // Reset insertion point, including debug location, and delete the
- // branch. This is really subtle and only works because the next change
- // in location will hit the caching in CGDebugInfo::EmitLocation and not
- // override this.
- Builder.SetCurrentDebugLocation(BI->getDebugLoc());
+ // Record/return the DebugLoc of the simple 'return' expression to be used
+ // later by the actual 'ret' instruction.
+ llvm::DebugLoc Loc = BI->getDebugLoc();
Builder.SetInsertPoint(BI->getParent());
BI->eraseFromParent();
delete ReturnBlock.getBlock();
- return;
+ return Loc;
}
}
@@ -201,6 +199,7 @@ void CodeGenFunction::EmitReturnBlock() {
// region.end for now.
EmitBlock(ReturnBlock.getBlock());
+ return llvm::DebugLoc();
}
static void EmitIfUsed(CodeGenFunction &CGF, llvm::BasicBlock *BB) {
@@ -254,16 +253,18 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
}
// Emit function epilog (to return).
- EmitReturnBlock();
+ llvm::DebugLoc Loc = EmitReturnBlock();
if (ShouldInstrumentFunction())
EmitFunctionInstrumentation("__cyg_profile_func_exit");
// Emit debug descriptor for function end.
- if (CGDebugInfo *DI = getDebugInfo()) {
+ if (CGDebugInfo *DI = getDebugInfo())
DI->EmitFunctionEnd(Builder);
- }
+ // Reset the debug location to that of the simple 'return' expression, if any
+ // rather than that of the end of the function's scope '}'.
+ ApplyDebugLocation AL(*this, Loc);
EmitFunctionEpilog(*CurFnInfo, EmitRetDbgLoc, EndLoc);
EmitEndEHSpec(CurCodeDecl);
OpenPOWER on IntegriCloud