diff options
author | David Blaikie <dblaikie@gmail.com> | 2013-01-26 22:16:26 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2013-01-26 22:16:26 +0000 |
commit | 0a21d0da172d2e4e9e6d5d531811f8fb5ea5282a (patch) | |
tree | 53713cfbc608d33e51f2d954d967f9b30ad70074 /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | 9f4b70dde051d36fe75b8e6a28253419484ecb88 (diff) | |
download | bcm5719-llvm-0a21d0da172d2e4e9e6d5d531811f8fb5ea5282a.tar.gz bcm5719-llvm-0a21d0da172d2e4e9e6d5d531811f8fb5ea5282a.zip |
PR14566: Debug Info: avoid top level lexical blocks in functions
One of the gotchas (see changes to CodeGenFunction) was due to the fix in
r139416 (for PR10829). This only worked previously because the top level
lexical block would set the location to the end of the function, the debug
location would be updated (as per r139416), the location would be set to
the end of the function again (but that would no-op, since it was the same
as the previous location), then the return instruction would be emitted using
the debug location.
Once the top level lexical block was no longer emitted, the end-of-function
location change was causing the debug loc to be updated, regressing that bug.
llvm-svn: 173593
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 1fdcc6f9ecd..59e38e63d51 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!"); } -void CodeGenFunction::EmitReturnBlock() { +bool CodeGenFunction::EmitReturnBlock() { // For cleanliness, we try to avoid emitting the return block for // simple cases. llvm::BasicBlock *CurBB = Builder.GetInsertBlock(); @@ -132,7 +132,7 @@ void CodeGenFunction::EmitReturnBlock() { delete ReturnBlock.getBlock(); } else EmitBlock(ReturnBlock.getBlock()); - return; + return false; } // Otherwise, if the return block is the target of a single direct @@ -148,7 +148,7 @@ void CodeGenFunction::EmitReturnBlock() { Builder.SetInsertPoint(BI->getParent()); BI->eraseFromParent(); delete ReturnBlock.getBlock(); - return; + return true; } } @@ -157,6 +157,7 @@ void CodeGenFunction::EmitReturnBlock() { // region.end for now. EmitBlock(ReturnBlock.getBlock()); + return false; } static void EmitIfUsed(CodeGenFunction &CGF, llvm::BasicBlock *BB) { @@ -178,14 +179,14 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) { PopCleanupBlocks(PrologueCleanupDepth); // Emit function epilog (to return). - EmitReturnBlock(); + bool MoveEndLoc = EmitReturnBlock(); if (ShouldInstrumentFunction()) EmitFunctionInstrumentation("__cyg_profile_func_exit"); // Emit debug descriptor for function end. if (CGDebugInfo *DI = getDebugInfo()) { - DI->setLocation(EndLoc); + if (!MoveEndLoc) DI->setLocation(EndLoc); DI->EmitFunctionEnd(Builder); } @@ -486,7 +487,10 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, void CodeGenFunction::EmitFunctionBody(FunctionArgList &Args) { const FunctionDecl *FD = cast<FunctionDecl>(CurGD.getDecl()); assert(FD->getBody()); - EmitStmt(FD->getBody()); + if (const CompoundStmt *S = dyn_cast<CompoundStmt>(FD->getBody())) + EmitCompoundStmtWithoutScope(*S); + else + EmitStmt(FD->getBody()); } /// Tries to mark the given function nounwind based on the |