[llvm] r345624 - [GCOV] Function counters are wrong when on one line

Calixte Denizet via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 30 11:41:31 PDT 2018


Author: calixte
Date: Tue Oct 30 11:41:31 2018
New Revision: 345624

URL: http://llvm.org/viewvc/llvm-project?rev=345624&view=rev
Log:
[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

Modified:
    llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp

Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=345624&r1=345623&r2=345624&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Tue Oct 30 11:41:31 2018
@@ -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();
     }




More information about the llvm-commits mailing list