diff options
| author | Calixte Denizet <cdenizet@mozilla.com> | 2018-10-30 18:41:31 +0000 | 
|---|---|---|
| committer | Calixte Denizet <cdenizet@mozilla.com> | 2018-10-30 18:41:31 +0000 | 
| commit | 38d50545feb7faffec8b8bbbb40661d21babf6af (patch) | |
| tree | 9b41907efdffac20f6baca9674cfe6d1596ab5b2 /llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp | |
| parent | eedd2ccd02c19c651070525627ca73432d2a06f0 (diff) | |
| download | bcm5719-llvm-38d50545feb7faffec8b8bbbb40661d21babf6af.tar.gz bcm5719-llvm-38d50545feb7faffec8b8bbbb40661d21babf6af.zip | |
[GCOV] Function counters are wrong when on one line
Summary:
After commit https://reviews.llvm.org/rL344228, the function definitions have a counter but when on one line the counter is wrong (e.g. void foo() { })
I added a test in: https://reviews.llvm.org/D53601
Reviewers: marco-c
Reviewed By: marco-c
Subscribers: llvm-commits, sylvestre.ledru
Differential Revision: https://reviews.llvm.org/D53600
llvm-svn: 345624
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp | 7 | 
1 files changed, 3 insertions, 4 deletions
| diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp index ee546a9a828..01938a0f357 100644 --- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -572,9 +572,8 @@ void GCOVProfiler::emitProfileNotes() {        // Add the function line number to the lines of the entry block        // to have a counter for the function definition. -      Func.getBlock(&EntryBlock) -          .getFile(SP->getFilename()) -          .addLine(SP->getLine()); +      uint32_t Line = SP->getLine(); +      Func.getBlock(&EntryBlock).getFile(SP->getFilename()).addLine(Line);        for (auto &BB : F) {          GCOVBlock &Block = Func.getBlock(&BB); @@ -587,7 +586,6 @@ void GCOVProfiler::emitProfileNotes() {            Block.addEdge(Func.getReturnBlock());          } -        uint32_t Line = 0;          for (auto &I : BB) {            // Debug intrinsic locations correspond to the location of the            // declaration, not necessarily any statements or expressions. @@ -609,6 +607,7 @@ void GCOVProfiler::emitProfileNotes() {            GCOVLines &Lines = Block.getFile(SP->getFilename());            Lines.addLine(Loc.getLine());          } +        Line = 0;        }        EdgeDestinations += Func.getEdgeDestinations();      } | 

