[compiler-rt] 66e2772 - [InstrProfiling] Support relative CountersPtr for PlatformOther
Jinsong Ji via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 18 10:46:33 PDT 2021
Author: Jinsong Ji
Date: 2021-08-18T17:45:39Z
New Revision: 66e2772e4285588ccc3bcdb5f392c8326debbd7d
URL: https://github.com/llvm/llvm-project/commit/66e2772e4285588ccc3bcdb5f392c8326debbd7d
DIFF: https://github.com/llvm/llvm-project/commit/66e2772e4285588ccc3bcdb5f392c8326debbd7d.diff
LOG: [InstrProfiling] Support relative CountersPtr for PlatformOther
D104556 change the CountersPtr to be relative, however, it did not
update the pointer initialization in __llvm_profile_register_function,
so the platform (eg:AIX) that use __llvm_profile_register_function is now totaly
broken, any PGO code will SEGV.
This patch update the code to reflect that the Data->CountersPtr is now
relative.
Reviewed By: MaskRay, davidxl
Differential Revision: https://reviews.llvm.org/D108304
Added:
Modified:
compiler-rt/lib/profile/InstrProfilingPlatformOther.c
Removed:
################################################################################
diff --git a/compiler-rt/lib/profile/InstrProfilingPlatformOther.c b/compiler-rt/lib/profile/InstrProfilingPlatformOther.c
index 0e59148e2044d..48946ce94253d 100644
--- a/compiler-rt/lib/profile/InstrProfilingPlatformOther.c
+++ b/compiler-rt/lib/profile/InstrProfilingPlatformOther.c
@@ -46,17 +46,19 @@ void __llvm_profile_register_function(void *Data_) {
if (!DataFirst) {
DataFirst = Data;
DataLast = Data + 1;
- CountersFirst = Data->CounterPtr;
- CountersLast = (uint64_t *)Data->CounterPtr + Data->NumCounters;
+ CountersFirst = (uint64_t *)((uintptr_t)Data_ + Data->CounterPtr);
+ CountersLast = CountersFirst + Data->NumCounters;
return;
}
DataFirst = (const __llvm_profile_data *)getMinAddr(DataFirst, Data);
- CountersFirst = (uint64_t *)getMinAddr(CountersFirst, Data->CounterPtr);
+ CountersFirst = (uint64_t *)getMinAddr(
+ CountersFirst, (uint64_t *)((uintptr_t)Data_ + Data->CounterPtr));
DataLast = (const __llvm_profile_data *)getMaxAddr(DataLast, Data + 1);
CountersLast = (uint64_t *)getMaxAddr(
- CountersLast, (uint64_t *)Data->CounterPtr + Data->NumCounters);
+ CountersLast,
+ (uint64_t *)((uintptr_t)Data_ + Data->CounterPtr) + Data->NumCounters);
}
COMPILER_RT_VISIBILITY
More information about the llvm-commits
mailing list