[llvm] [BOLT] Enable compatibility of instrumentation-file-append-pid with instrumentation-sleep-time (PR #183919)
Vasily Leonenko via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 4 11:03:54 PST 2026
https://github.com/vleonen updated https://github.com/llvm/llvm-project/pull/183919
>From cf8b406269eb9bf5af7f135bc954e5181fa7796d Mon Sep 17 00:00:00 2001
From: Vasily Leonenko <vasily.leonenko at huawei.com>
Date: Sat, 28 Feb 2026 12:04:57 +0000
Subject: [PATCH] [BOLT] Enable compatibility of
instrumentation-file-append-pid with instrumentation-sleep-time
This commit enables compatibility of instrumentation-file-append-pid and
instrumentation-sleep-time options. It also requires keeping the counters
mapping between the watcher process and the instrumented binary process in
shared mode. This is useful when we instrument a shared library that is used
by several tasks running on the target system. In case when we cannot wait for
every task to complete, we must use the sleep-time option. Without append-pid
option, we would overwrite the profile at the same path but collected from
different tasks, leading to unexpected or suboptimal optimization effects.
---
.../RuntimeLibs/InstrumentationRuntimeLibrary.cpp | 12 +++++-------
bolt/runtime/instr.cpp | 2 +-
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp b/bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
index bca3c440275f7..d71d8ef1c0444 100644
--- a/bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
+++ b/bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
@@ -66,13 +66,11 @@ void InstrumentationRuntimeLibrary::adjustCommandLineOptions(
exit(1);
}
- if ((opts::InstrumentationWaitForks || opts::InstrumentationSleepTime) &&
- opts::InstrumentationFileAppendPID) {
- errs()
- << "BOLT-ERROR: instrumentation-file-append-pid is not compatible with "
- "instrumentation-sleep-time and instrumentation-wait-forks. If you "
- "want a separate profile for each fork, it can only be dumped in "
- "the end of process when instrumentation-file-append-pid is used.\n";
+ if (opts::InstrumentationWaitForks && opts::InstrumentationFileAppendPID) {
+ errs() << "BOLT-ERROR: instrumentation-file-append-pid is not compatible "
+ "with instrumentation-wait-forks. If you want a separate profile "
+ "for each fork, it can only be dumped in the end of process when "
+ "instrumentation-file-append-pid is used.\n";
exit(1);
}
}
diff --git a/bolt/runtime/instr.cpp b/bolt/runtime/instr.cpp
index 67d9f83da37b9..08760c9ca8af1 100644
--- a/bolt/runtime/instr.cpp
+++ b/bolt/runtime/instr.cpp
@@ -1671,7 +1671,7 @@ extern "C" void __attribute((force_align_arg_pointer)) __bolt_instr_setup() {
DEBUG(reportNumber("replace mmap stop: ", CountersEnd, 16));
assert(CountersEnd > CountersStart, "no counters");
- const bool Shared = !__bolt_instr_use_pid;
+ const bool Shared = !__bolt_instr_use_pid | !!__bolt_instr_sleep_time;
const uint64_t MapPrivateOrShared = Shared ? MAP_SHARED : MAP_PRIVATE;
void *Ret =
More information about the llvm-commits
mailing list