[clang] [llvm] [InstrPGO] Instrument sampling profile based cold function (PR #109837)
    Ellis Hoag via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Wed Oct  2 17:27:37 PDT 2024
    
    
  
================
@@ -1119,6 +1125,18 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
       // removed.
       MPM.addPass(
           PGOIndirectCallPromotion(true /* IsInLTO */, true /* SamplePGO */));
+
+    if (InstrumentSampleColdFuncPath.getNumOccurrences() &&
+        Phase != ThinOrFullLTOPhase::ThinLTOPostLink) {
+      assert(!InstrumentSampleColdFuncPath.empty() &&
+             "File path is requeired for instrumentation generation");
+      InstrumentColdFunctionCoverage = true;
+      addPreInlinerPasses(MPM, Level, Phase);
+      addPGOInstrPasses(MPM, Level, /* RunProfileGen */ true,
+                        /* IsCS */ false, /* AtomicCounterUpdate */ false,
+                        InstrumentSampleColdFuncPath, "",
+                        IntrusiveRefCntPtr<vfs::FileSystem>());
+    }
----------------
ellishg wrote:
I don't see how there would be any functional difference between using `IsSampleColdFuncCovGen` and `IsXXXColdFuncCovGen`, but I could be missing something. If we can have a single flag for all cases, I think that would be cleaner and I can also try to use it for my case.
https://github.com/llvm/llvm-project/pull/109837
    
    
More information about the llvm-commits
mailing list