diff options
Diffstat (limited to 'compiler-rt/lib/profile/InstrProfilingMerge.c')
-rw-r--r-- | compiler-rt/lib/profile/InstrProfilingMerge.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/compiler-rt/lib/profile/InstrProfilingMerge.c b/compiler-rt/lib/profile/InstrProfilingMerge.c index b5850e9..ad7a50dc 100644 --- a/compiler-rt/lib/profile/InstrProfilingMerge.c +++ b/compiler-rt/lib/profile/InstrProfilingMerge.c @@ -107,6 +107,27 @@ static uintptr_t signextIfWin64(void *V) { #endif } +static uint64_t +getDistanceFromCounterToValueProf(const __llvm_profile_header *const Header) { + // Skip names section, vtable profile data section and vtable names section + // for runtime profile merge. To merge runtime addresses from multiple + // profiles collected from the same instrumented binary, the binary should be + // loaded at fixed base address (e.g., build with -no-pie, or run with ASLR + // disabled). + // In this set-up these three sections remain unchanged. + const uint64_t VTableSectionSize = + Header->NumVTables * sizeof(VTableProfData); + const uint64_t PaddingBytesAfterVTableSection = + __llvm_profile_get_num_padding_bytes(VTableSectionSize); + const uint64_t VNamesSize = Header->VNamesSize; + const uint64_t PaddingBytesAfterVNamesSize = + __llvm_profile_get_num_padding_bytes(VNamesSize); + return Header->NamesSize + + __llvm_profile_get_num_padding_bytes(Header->NamesSize) + + VTableSectionSize + PaddingBytesAfterVTableSection + VNamesSize + + PaddingBytesAfterVNamesSize; +} + COMPILER_RT_VISIBILITY int __llvm_profile_merge_from_buffer(const char *ProfileData, uint64_t ProfileSize) { @@ -136,9 +157,9 @@ int __llvm_profile_merge_from_buffer(const char *ProfileData, Header->NumCounters * __llvm_profile_counter_entry_size(); SrcBitmapStart = SrcCountersEnd; SrcNameStart = SrcBitmapStart + Header->NumBitmapBytes; + SrcValueProfDataStart = - SrcNameStart + Header->NamesSize + - __llvm_profile_get_num_padding_bytes(Header->NamesSize); + SrcNameStart + getDistanceFromCounterToValueProf(Header); if (SrcNameStart < SrcCountersStart || SrcNameStart < SrcBitmapStart) return 1; |