@@ -1586,25 +1586,29 @@ extern "C" void __bolt_instr_indirect_tailcall();
1586
1586
1587
1587
// / Initialization code
1588
1588
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
+
1589
1592
const uint64_t CountersStart =
1590
1593
reinterpret_cast <uint64_t >(&__bolt_instr_locations[0 ]);
1591
1594
const uint64_t CountersEnd = alignTo (
1592
1595
reinterpret_cast <uint64_t >(&__bolt_instr_locations[__bolt_num_counters]),
1593
1596
0x1000 );
1594
1597
DEBUG (reportNumber (" replace mmap start: " , CountersStart, 16 ));
1595
1598
DEBUG (reportNumber (" replace mmap stop: " , CountersEnd, 16 ));
1596
- assert (CountersEnd > CountersStart, " no counters" );
1597
- // Maps our counters to be shared instead of private, so we keep counting for
1598
- // forked processes
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
+
1599
1604
void *Ret =
1600
1605
__mmap (CountersStart, CountersEnd - CountersStart, PROT_READ | PROT_WRITE,
1601
- MAP_ANONYMOUS | MAP_SHARED | MAP_FIXED, -1 , 0 );
1606
+ MAP_ANONYMOUS | MapPrivateOrShared | MAP_FIXED, -1 , 0 );
1602
1607
assert (Ret != MAP_FAILED, " __bolt_instr_setup: Failed to mmap counters!" );
1603
- __bolt_ind_call_counter_func_pointer = __bolt_instr_indirect_call;
1604
- __bolt_ind_tailcall_counter_func_pointer = __bolt_instr_indirect_tailcall;
1608
+
1605
1609
// Conservatively reserve 100MiB shared pages
1606
1610
GlobalAlloc.setMaxSize (0x6400000 );
1607
- GlobalAlloc.setShared (true );
1611
+ GlobalAlloc.setShared (Shared );
1608
1612
GlobalWriteProfileMutex = new (GlobalAlloc, 0 ) Mutex ();
1609
1613
if (__bolt_instr_num_ind_calls > 0 )
1610
1614
GlobalIndCallCounters =
0 commit comments