From: Tim Shen Date: Wed, 17 May 2017 21:20:00 +0000 (+0000) Subject: [XRay] Fix __xray_function_address on PPC reguarding local entry points. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=af3ffcc1f8d13b2b5f26e8283df25dd05ea1a3f0;p=platform%2Fupstream%2Fllvm.git [XRay] Fix __xray_function_address on PPC reguarding local entry points. Reviewers: echristo, dberris Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33266 llvm-svn: 303302 --- diff --git a/compiler-rt/lib/xray/xray_interface.cc b/compiler-rt/lib/xray/xray_interface.cc index c437a72..523ed16 100644 --- a/compiler-rt/lib/xray/xray_interface.cc +++ b/compiler-rt/lib/xray/xray_interface.cc @@ -326,7 +326,14 @@ uintptr_t __xray_function_address(int32_t FuncId) XRAY_NEVER_INSTRUMENT { __sanitizer::SpinMutexLock Guard(&XRayInstrMapMutex); if (FuncId <= 0 || static_cast(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 { diff --git a/compiler-rt/test/xray/TestCases/Linux/func-id-utils.cc b/compiler-rt/test/xray/TestCases/Linux/func-id-utils.cc index c9a2952..17185c3 100644 --- a/compiler-rt/test/xray/TestCases/Linux/func-id-utils.cc +++ b/compiler-rt/test/xray/TestCases/Linux/func-id-utils.cc @@ -31,18 +31,10 @@ "each function id must be assigned to a unique function"); std::set not_instrumented; - const auto comp = [](void *lhs, void *rhs) { -#ifdef __PPC__ - return reinterpret_cast(lhs) + 8 < - reinterpret_cast(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");