[llvm] [PGO] Sampled instrumentation in PGO to speed up instrumentation binary (PR #69535)

David Li via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 18 22:17:26 PDT 2023


================
@@ -412,30 +424,91 @@ PreservedAnalyses InstrProfiling::run(Module &M, ModuleAnalysisManager &AM) {
   return PreservedAnalyses::none();
 }
 
+// Perform instrumentation sampling.
+// We transform:
+//   Increment_Instruction;
+// to:
+//   if (__llvm_profile_sampling__ <= SampleDuration) {
+//     Increment_Instruction;
+//   }
+//   __llvm_profile_sampling__ += 1;
----------------
david-xl wrote:

It can be problem for static count, but might be ok with runtime count. Data changes at runtime introduce some randomness -- for instance loop trip count. It is unlikely all loops in a program have fixed trip count through out the training run.

https://github.com/llvm/llvm-project/pull/69535


More information about the llvm-commits mailing list