[llvm-branch-commits] [llvm] daeea96 - [llvm-profgen][NFC] Fix the incorrect computation of callsite sample count

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jan 19 18:15:54 PST 2021


Author: wlei
Date: 2021-01-19T17:50:48-08:00
New Revision: daeea961a6d93f301e7a22659a2c203846fd58f2

URL: https://github.com/llvm/llvm-project/commit/daeea961a6d93f301e7a22659a2c203846fd58f2
DIFF: https://github.com/llvm/llvm-project/commit/daeea961a6d93f301e7a22659a2c203846fd58f2.diff

LOG: [llvm-profgen][NFC] Fix the incorrect computation of callsite sample count

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

Added: 
    

Modified: 
    llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test
    llvm/tools/llvm-profgen/ProfileGenerator.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test b/llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test
index 385009d2d539..9beecb271fc0 100644
--- a/llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test
+++ b/llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test
@@ -7,7 +7,7 @@
 ; CHECK: 2: 2
 ; CHECK: 4: 1
 ; CHECK: 5: 3
-; CHECK:[main:1 @ foo]:9:0
+; CHECK:[main:1 @ foo]:6:0
 ; CHECK: 2: 3
 ; CHECK: 3: 3 bar:3
 

diff  --git a/llvm/tools/llvm-profgen/ProfileGenerator.cpp b/llvm/tools/llvm-profgen/ProfileGenerator.cpp
index 7c5c5e3d5fa9..265beccb84a8 100644
--- a/llvm/tools/llvm-profgen/ProfileGenerator.cpp
+++ b/llvm/tools/llvm-profgen/ProfileGenerator.cpp
@@ -239,11 +239,9 @@ void CSProfileGenerator::populateFunctionBoundarySamples(
 
     // Record called target sample and its count
     const FrameLocation &LeafLoc = Binary->getInlineLeafFrameLoc(SourceOffset);
-
     FunctionProfile.addCalledTargetSamples(LeafLoc.second.LineOffset,
                                            LeafLoc.second.Discriminator,
                                            CalleeName, Count);
-    FunctionProfile.addTotalSamples(Count);
 
     // Record head sample for called target(callee)
     // TODO: Cleanup ' @ '
@@ -311,8 +309,10 @@ void CSProfileGenerator::populateInferredFunctionSamples() {
         CallerLeafFrameLoc.second.LineOffset,
         CallerLeafFrameLoc.second.Discriminator, CalleeProfile.getName(),
         EstimatedCallCount);
-    updateBodySamplesforFunctionProfile(CallerProfile, CallerLeafFrameLoc,
-                                        EstimatedCallCount);
+    CallerProfile.addBodySamples(CallerLeafFrameLoc.second.LineOffset,
+                                 CallerLeafFrameLoc.second.Discriminator,
+                                 EstimatedCallCount);
+    CallerProfile.addTotalSamples(EstimatedCallCount);
   }
 }
 


        


More information about the llvm-branch-commits mailing list