[compiler-rt] r303302 - [XRay] Fix __xray_function_address on PPC reguarding local entry points.
Tim Shen via llvm-commits
llvm-commits at lists.llvm.org
Wed May 17 14:20:01 PDT 2017
Author: timshen
Date: Wed May 17 16:20:00 2017
New Revision: 303302
URL: http://llvm.org/viewvc/llvm-project?rev=303302&view=rev
Log:
[XRay] Fix __xray_function_address on PPC reguarding local entry points.
Reviewers: echristo, dberris
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D33266
Modified:
compiler-rt/trunk/lib/xray/xray_interface.cc
compiler-rt/trunk/test/xray/TestCases/Linux/func-id-utils.cc
Modified: compiler-rt/trunk/lib/xray/xray_interface.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_interface.cc?rev=303302&r1=303301&r2=303302&view=diff
==============================================================================
--- compiler-rt/trunk/lib/xray/xray_interface.cc (original)
+++ compiler-rt/trunk/lib/xray/xray_interface.cc Wed May 17 16:20:00 2017
@@ -326,7 +326,14 @@ uintptr_t __xray_function_address(int32_
__sanitizer::SpinMutexLock Guard(&XRayInstrMapMutex);
if (FuncId <= 0 || static_cast<size_t>(FuncId) > XRayInstrMap.Functions)
return 0;
- return XRayInstrMap.SledsIndex[FuncId - 1].Begin->Address;
+ return XRayInstrMap.SledsIndex[FuncId - 1].Begin->Address
+// On PPC, function entries are always aligned to 16 bytes. The beginning of a
+// sled might be a local entry, which is always +8 based on the global entry.
+// Always return the global entry.
+#ifdef __PPC__
+ & ~0xf
+#endif
+ ;
}
size_t __xray_max_function_id() XRAY_NEVER_INSTRUMENT {
Modified: compiler-rt/trunk/test/xray/TestCases/Linux/func-id-utils.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/xray/TestCases/Linux/func-id-utils.cc?rev=303302&r1=303301&r2=303302&view=diff
==============================================================================
--- compiler-rt/trunk/test/xray/TestCases/Linux/func-id-utils.cc (original)
+++ compiler-rt/trunk/test/xray/TestCases/Linux/func-id-utils.cc Wed May 17 16:20:00 2017
@@ -31,18 +31,10 @@
"each function id must be assigned to a unique function");
std::set<void *> not_instrumented;
- const auto comp = [](void *lhs, void *rhs) {
-#ifdef __PPC__
- return reinterpret_cast<uintptr_t>(lhs) + 8 <
- reinterpret_cast<uintptr_t>(rhs);
-#else
- return lhs < rhs;
-#endif
- };
- std::set_difference(must_be_instrumented.begin(), must_be_instrumented.end(),
- all_instrumented.begin(), all_instrumented.end(),
- std::inserter(not_instrumented, not_instrumented.begin()),
- comp);
+ std::set_difference(
+ must_be_instrumented.begin(), must_be_instrumented.end(),
+ all_instrumented.begin(), all_instrumented.end(),
+ std::inserter(not_instrumented, not_instrumented.begin()));
assert(
not_instrumented.empty() &&
"we should see all explicitly instrumented functions with function ids");
More information about the llvm-commits
mailing list