[llvm] r344228 - [gcov] Display the hit counter for the line of a function definition

Calixte Denizet via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 11 01:53:43 PDT 2018


Author: calixte
Date: Thu Oct 11 01:53:43 2018
New Revision: 344228

URL: http://llvm.org/viewvc/llvm-project?rev=344228&view=rev
Log:
[gcov] Display the hit counter for the line of a function definition

Summary:
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: https://reviews.llvm.org/D49854

Reviewers: marco-c, davidxl

Reviewed By: marco-c

Subscribers: sylvestre.ledru, llvm-commits

Differential Revision: https://reviews.llvm.org/D49853

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=344228&r1=344227&r2=344228&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Thu Oct 11 01:53:43 2018
@@ -570,6 +570,12 @@ void GCOVProfiler::emitProfileNotes() {
                                                 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(&EntryBlock)
+          .getFile(SP->getFilename())
+          .addLine(SP->getLine());
+
       for (auto &BB : F) {
         GCOVBlock &Block = Func.getBlock(&BB);
         TerminatorInst *TI = BB.getTerminator();




More information about the llvm-commits mailing list