[PATCH] D53600: [GCOV] Function counters are wrong when on one line

calixte via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 23 12:06:13 PDT 2018


calixte created this revision.
calixte added a reviewer: marco-c.
Herald added a subscriber: llvm-commits.

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() { })


Repository:
  rL LLVM

https://reviews.llvm.org/D53600

Files:
  lib/Transforms/Instrumentation/GCOVProfiling.cpp


Index: lib/Transforms/Instrumentation/GCOVProfiling.cpp
===================================================================
--- lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -572,9 +572,8 @@
 
       // 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 @@
           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 @@
           GCOVLines &Lines = Block.getFile(SP->getFilename());
           Lines.addLine(Loc.getLine());
         }
+        Line = 0;
       }
       EdgeDestinations += Func.getEdgeDestinations();
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53600.170721.patch
Type: text/x-patch
Size: 1195 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181023/cd525cf9/attachment.bin>


More information about the llvm-commits mailing list