Skip to content

Commit c15e9b6

Browse files
committed
Revert "[BOLT][Instrumentation] Don't share counters when using append-pid"
This reverts commit 02c3724. This change breaks instrumented Clang: https://lab.llvm.org/buildbot/#/builders/252/builds/2700
1 parent 4314f4c commit c15e9b6

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

bolt/runtime/instr.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,29 +1586,25 @@ extern "C" void __bolt_instr_indirect_tailcall();
15861586

15871587
/// Initialization code
15881588
extern "C" void __attribute((force_align_arg_pointer)) __bolt_instr_setup() {
1589-
__bolt_ind_call_counter_func_pointer = __bolt_instr_indirect_call;
1590-
__bolt_ind_tailcall_counter_func_pointer = __bolt_instr_indirect_tailcall;
1591-
15921589
const uint64_t CountersStart =
15931590
reinterpret_cast<uint64_t>(&__bolt_instr_locations[0]);
15941591
const uint64_t CountersEnd = alignTo(
15951592
reinterpret_cast<uint64_t>(&__bolt_instr_locations[__bolt_num_counters]),
15961593
0x1000);
15971594
DEBUG(reportNumber("replace mmap start: ", CountersStart, 16));
15981595
DEBUG(reportNumber("replace mmap stop: ", CountersEnd, 16));
1599-
assert(CountersEnd > CountersStart, "no counters");
1600-
1601-
const bool Shared = !__bolt_instr_use_pid;
1602-
const uint64_t MapPrivateOrShared = Shared ? MAP_SHARED : MAP_PRIVATE;
1603-
1596+
assert (CountersEnd > CountersStart, "no counters");
1597+
// Maps our counters to be shared instead of private, so we keep counting for
1598+
// forked processes
16041599
void *Ret =
16051600
__mmap(CountersStart, CountersEnd - CountersStart, PROT_READ | PROT_WRITE,
1606-
MAP_ANONYMOUS | MapPrivateOrShared | MAP_FIXED, -1, 0);
1601+
MAP_ANONYMOUS | MAP_SHARED | MAP_FIXED, -1, 0);
16071602
assert(Ret != MAP_FAILED, "__bolt_instr_setup: Failed to mmap counters!");
1608-
1603+
__bolt_ind_call_counter_func_pointer = __bolt_instr_indirect_call;
1604+
__bolt_ind_tailcall_counter_func_pointer = __bolt_instr_indirect_tailcall;
16091605
// Conservatively reserve 100MiB shared pages
16101606
GlobalAlloc.setMaxSize(0x6400000);
1611-
GlobalAlloc.setShared(Shared);
1607+
GlobalAlloc.setShared(true);
16121608
GlobalWriteProfileMutex = new (GlobalAlloc, 0) Mutex();
16131609
if (__bolt_instr_num_ind_calls > 0)
16141610
GlobalIndCallCounters =

0 commit comments

Comments
 (0)