[llvm-branch-commits] [llvm] [BOLT] Add profile density computation	(PR #101094)
    via llvm-branch-commits 
    llvm-branch-commits at lists.llvm.org
       
    Sat Aug 10 20:13:32 PDT 2024
    
    
  
================
@@ -1441,6 +1458,22 @@ Error PrintProgramStats::runOnFunctions(BinaryContext &BC) {
       StaleSampleCount += SampleCount;
       ++NumAllStaleFunctions;
     }
+
+    if (opts::ShowDensity) {
+      uint64_t Size = Function.getSize();
+      // In case of BOLT split functions registered in BAT, executed traces are
+      // automatically attributed to the main fragment. Add up function sizes
+      // for all fragments.
+      if (IsHotParentOfBOLTSplitFunction)
+        for (const BinaryFunction *Fragment : Function.getFragments())
+          Size += Fragment->getSize();
+      double Density = (double)1.0 * Function.getExecutedBytes() / Size;
+      FuncDensityList.emplace_back(Density, SampleCount);
----------------
WenleiHe wrote:
> What do you mean by that? 
@aaupov I meant to give you suggestions on alternative names. 
> Comments above the variable and the method say it's dynamically executed bytes 
Good naming should not be confusing, without need to look at comments. `ExecutedBytes` is confusing as it really lead people to think it's coverage in bytes. 
https://github.com/llvm/llvm-project/pull/101094
    
    
More information about the llvm-branch-commits
mailing list