diff options
author | Calixte Denizet <cdenizet@mozilla.com> | 2018-09-21 09:17:06 +0000 |
---|---|---|
committer | Calixte Denizet <cdenizet@mozilla.com> | 2018-09-21 09:17:06 +0000 |
commit | 5713db4c4af8261b5306e1a6eb1a60625d8b4cc7 (patch) | |
tree | 758f0b0ecea16f07d1cffd9ab41a0045fe34b0e1 /clang/lib/CodeGen/CGDebugInfo.cpp | |
parent | eaf601ab7a1a994da6a25c4dcae4da3ea59a93e6 (diff) | |
download | bcm5719-llvm-5713db4c4af8261b5306e1a6eb1a60625d8b4cc7.tar.gz bcm5719-llvm-5713db4c4af8261b5306e1a6eb1a60625d8b4cc7.zip |
[CodeGen] Add to emitted DebugLoc information about coverage when it's required
Summary:
Some lines have a hit counter where they should not have one.
Cleanup stuff is located to the last line of the body which is most of the time a '}'.
And Exception stuff is added at the beginning of a function and at the end (represented by '{' and '}').
So in such cases, the DebugLoc used in GCOVProfiling.cpp must be marked as not covered.
This patch is a followup of https://reviews.llvm.org/D49915.
Tests in projects/compiler_rt are fixed by: https://reviews.llvm.org/D49917
Reviewers: marco-c, davidxl
Reviewed By: marco-c
Subscribers: dblaikie, cfe-commits, sylvestre.ledru
Differential Revision: https://reviews.llvm.org/D49916
llvm-svn: 342717
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 7d6eb83f12d..216a12b40d3 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -76,20 +76,22 @@ CGDebugInfo::~CGDebugInfo() { } ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF, - SourceLocation TemporaryLocation) + SourceLocation TemporaryLocation, + bool ImplicitCode) : CGF(&CGF) { - init(TemporaryLocation); + init(TemporaryLocation, false /* DefaultToEmpty */, ImplicitCode); } ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF, bool DefaultToEmpty, - SourceLocation TemporaryLocation) + SourceLocation TemporaryLocation, + bool ImplicitCode) : CGF(&CGF) { - init(TemporaryLocation, DefaultToEmpty); + init(TemporaryLocation, DefaultToEmpty, ImplicitCode); } void ApplyDebugLocation::init(SourceLocation TemporaryLocation, - bool DefaultToEmpty) { + bool DefaultToEmpty, bool ImplicitCode) { auto *DI = CGF->getDebugInfo(); if (!DI) { CGF = nullptr; @@ -102,7 +104,7 @@ void ApplyDebugLocation::init(SourceLocation TemporaryLocation, return; if (TemporaryLocation.isValid()) { - DI->EmitLocation(CGF->Builder, TemporaryLocation); + DI->EmitLocation(CGF->Builder, TemporaryLocation, ImplicitCode); return; } @@ -3484,7 +3486,8 @@ void CGDebugInfo::EmitInlineFunctionEnd(CGBuilderTy &Builder) { setInlinedAt(llvm::DebugLoc(CurInlinedAt).getInlinedAt()); } -void CGDebugInfo::EmitLocation(CGBuilderTy &Builder, SourceLocation Loc) { +void CGDebugInfo::EmitLocation(CGBuilderTy &Builder, SourceLocation Loc, + bool ImplicitCode) { // Update our current location setLocation(Loc); @@ -3492,8 +3495,9 @@ void CGDebugInfo::EmitLocation(CGBuilderTy &Builder, SourceLocation Loc) { return; llvm::MDNode *Scope = LexicalBlockStack.back(); - Builder.SetCurrentDebugLocation(llvm::DebugLoc::get( - getLineNumber(CurLoc), getColumnNumber(CurLoc), Scope, CurInlinedAt)); + Builder.SetCurrentDebugLocation( + llvm::DebugLoc::get(getLineNumber(CurLoc), getColumnNumber(CurLoc), Scope, + CurInlinedAt, ImplicitCode)); } void CGDebugInfo::CreateLexicalBlock(SourceLocation Loc) { @@ -3540,7 +3544,7 @@ void CGDebugInfo::EmitLexicalBlockEnd(CGBuilderTy &Builder, assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!"); // Provide an entry in the line table for the end of the block. - EmitLocation(Builder, Loc); + EmitLocation(Builder, Loc, true /* ImplicitCode */); if (DebugKind <= codegenoptions::DebugLineTablesOnly) return; @@ -3556,7 +3560,7 @@ void CGDebugInfo::EmitFunctionEnd(CGBuilderTy &Builder, llvm::Function *Fn) { // Pop all regions for this function. while (LexicalBlockStack.size() != RCount) { // Provide an entry in the line table for the end of the block. - EmitLocation(Builder, CurLoc); + EmitLocation(Builder, CurLoc, true /* ImplicitCode */); LexicalBlockStack.pop_back(); } FnBeginRegionCount.pop_back(); |