[llvm] [PGO] Sampled instrumentation in PGO to speed up instrumentation binary (PR #69535)
Hongtao Yu via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 18 22:04:16 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;
----------------
htyu wrote:
Since `__llvm_profile_sampling__` is shared by all PGO counters, I'm wondering if biasing could happen to code always shadowed in the range `[__llvm_profile_sampling__, 65536]`. E.g, assume two loops in the program, they count up to 65536 iterations in all, and the second loop will unlikely be counted?
https://github.com/llvm/llvm-project/pull/69535
More information about the llvm-commits
mailing list