[PATCH] D49853: [gcov] Display the hit counter for the line of a function definition

calixte via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 26 07:09:34 PDT 2018


calixte created this revision.
calixte added reviewers: marco-c, davidxl.
Herald added a subscriber: llvm-commits.

Right now there is no hit counter on the line of function.
So the idea is add the line of the function to all the lines covered by the entry block.
Tests in compiler-rt/profile will be fixed in another patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D49853

Files:
  lib/Transforms/Instrumentation/GCOVProfiling.cpp


Index: lib/Transforms/Instrumentation/GCOVProfiling.cpp
===================================================================
--- lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -583,6 +583,10 @@
                                                 Options.ExitBlockBeforeBody));
       GCOVFunction &Func = *Funcs.back();
 
+      // Add the function line number to the lines of the entry block
+      // to have a counter for the function definition
+      Func.getBlock(&F.getEntryBlock()).getFile(SP->getFilename()).addLine(SP->getLine());
+
       for (auto &BB : F) {
         GCOVBlock &Block = Func.getBlock(&BB);
         TerminatorInst *TI = BB.getTerminator();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49853.157480.patch
Type: text/x-patch
Size: 723 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180726/d62c3651/attachment.bin>


More information about the llvm-commits mailing list