<div dir="ltr">I found the wrong assumption I had when implementing PPC. The ABI requires large aggregates (e.g. std::pair<long, long>) to return by register, but I mistakenly (rather shame to admit, actually :/) thought that only single-register value can be returned by register.<div><br></div><div>I'm working on the fix.</div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, May 7, 2017 at 5:14 PM Dean Michael Berris <<a href="mailto:dberris@google.com">dberris@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><a class="m_-6024819072328263923GWVZpf m_-6024819072328263923gW" id="m_-6024819072328263923IloFPc-2" href="mailto:timshen@google.com" target="_blank">+Tim Shen</a> for looking into more deeply, I'll XFAIL in the meantime (if it hasn't been yet).</div><br><div class="gmail_quote"><div dir="ltr">On Sat, May 6, 2017 at 3:13 AM Bill Seurer <<a href="mailto:seurer@linux.vnet.ibm.com" target="_blank">seurer@linux.vnet.ibm.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The new test here also fails on powerpcle:<br>
<br>
<a href="http://lab.llvm.org:8011/builders/clang-ppc64le-linux/builds/6079/steps/ninja%20check%201/logs/FAIL%3A%20XRay-powerpc64le-linux%3A%3Afunc-id-utils.cc" rel="noreferrer" target="_blank">http://lab.llvm.org:8011/builders/clang-ppc64le-linux/builds/6079/steps/ninja%20check%201/logs/FAIL%3A%20XRay-powerpc64le-linux%3A%3Afunc-id-utils.cc</a><br>
<br>
If this is something that can't be immediately fixed please xfail the<br>
test like I did for coverage-samples.cc.  I won't be available to take<br>
care of it today.<br>
<br>
On 05/04/2017 08:27 PM, Dean Michael Berris via llvm-commits wrote:<br>
> Author: dberris<br>
> Date: Thu May  4 20:27:11 2017<br>
> New Revision: 302210<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=302210&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=302210&view=rev</a><br>
> Log:<br>
> [XRay][compiler-rt] Add function id utilities for XRay<br>
><br>
> Summary:<br>
> This change allows us to provide users and implementers of XRay handlers<br>
> a means of converting XRay function id's to addresses. This, in<br>
> combination with the facilities provided in D32695, allows users to find<br>
> out:<br>
><br>
>   - How many function id's there are defined in the current binary.<br>
>   - Get the address of the function associated with this function id.<br>
>   - Patch only specific functions according to their requirements.<br>
><br>
> While we don't directly provide symbolization support in XRay, having<br>
> the function's address lets users determine this information easily<br>
> either during runtime, or offline with tools like 'addr2line'.<br>
><br>
> Reviewers: dblaikie, echristo, pelikan<br>
><br>
> Subscribers: kpw, llvm-commits<br>
><br>
> Differential Revision: <a href="https://reviews.llvm.org/D32846" rel="noreferrer" target="_blank">https://reviews.llvm.org/D32846</a><br>
><br>
> Added:<br>
>     compiler-rt/trunk/test/xray/TestCases/Linux/func-id-utils.cc<br>
> Modified:<br>
>     compiler-rt/trunk/include/xray/xray_interface.h<br>
>     compiler-rt/trunk/lib/xray/xray_interface.cc<br>
><br>
> Modified: compiler-rt/trunk/include/xray/xray_interface.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/include/xray/xray_interface.h?rev=302210&r1=302209&r2=302210&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/include/xray/xray_interface.h?rev=302210&r1=302209&r2=302210&view=diff</a><br>
> ==============================================================================<br>
> --- compiler-rt/trunk/include/xray/xray_interface.h (original)<br>
> +++ compiler-rt/trunk/include/xray/xray_interface.h Thu May  4 20:27:11 2017<br>
> @@ -15,6 +15,7 @@<br>
>  #define XRAY_XRAY_INTERFACE_H<br>
><br>
>  #include <cstdint><br>
> +#include <stddef.h><br>
><br>
>  extern "C" {<br>
><br>
> @@ -86,6 +87,14 @@ extern XRayPatchingStatus __xray_patch_f<br>
>  /// result values.<br>
>  extern XRayPatchingStatus __xray_unpatch_function(int32_t FuncId);<br>
><br>
> +/// This function returns the address of the function provided a valid function<br>
> +/// id. We return 0 if we encounter any error, even if 0 may be a valid function<br>
> +/// address.<br>
> +extern uintptr_t __xray_function_address(int32_t FuncId);<br>
> +<br>
> +/// This function returns the maximum valid function id. Returns 0 if we<br>
> +/// encounter errors (when there are no instrumented functions, etc.).<br>
> +extern size_t __xray_max_function_id();<br>
><br>
>  }<br>
><br>
><br>
> Modified: compiler-rt/trunk/lib/xray/xray_interface.cc<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_interface.cc?rev=302210&r1=302209&r2=302210&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_interface.cc?rev=302210&r1=302209&r2=302210&view=diff</a><br>
> ==============================================================================<br>
> --- compiler-rt/trunk/lib/xray/xray_interface.cc (original)<br>
> +++ compiler-rt/trunk/lib/xray/xray_interface.cc Thu May  4 20:27:11 2017<br>
> @@ -255,7 +255,7 @@ XRayPatchingStatus patchFunction(int32_t<br>
><br>
>    // FuncId must be a positive number, less than the number of functions<br>
>    // instrumented.<br>
> -  if (FuncId <= 0 || static_cast<size_t>(FuncId) >= InstrMap.Functions) {<br>
> +  if (FuncId <= 0 || static_cast<size_t>(FuncId) > InstrMap.Functions) {<br>
>      Report("Invalid function id provided: %d\n", FuncId);<br>
>      return XRayPatchingStatus::FAILED;<br>
>    }<br>
> @@ -302,3 +302,15 @@ int __xray_set_handler_arg1(void (*Handl<br>
>    return 1;<br>
>  }<br>
>  int __xray_remove_handler_arg1() { return __xray_set_handler_arg1(nullptr); }<br>
> +<br>
> +uintptr_t __xray_function_address(int32_t FuncId) XRAY_NEVER_INSTRUMENT {<br>
> +  __sanitizer::SpinMutexLock Guard(&XRayInstrMapMutex);<br>
> +  if (FuncId <= 0 || static_cast<size_t>(FuncId) > XRayInstrMap.Functions)<br>
> +    return 0;<br>
> +  return XRayInstrMap.SledsIndex[FuncId - 1].Begin->Address;<br>
> +}<br>
> +<br>
> +size_t __xray_max_function_id() XRAY_NEVER_INSTRUMENT {<br>
> +  __sanitizer::SpinMutexLock Guard(&XRayInstrMapMutex);<br>
> +  return XRayInstrMap.Functions;<br>
> +}<br>
><br>
> Added: compiler-rt/trunk/test/xray/TestCases/Linux/func-id-utils.cc<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/xray/TestCases/Linux/func-id-utils.cc?rev=302210&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/xray/TestCases/Linux/func-id-utils.cc?rev=302210&view=auto</a><br>
> ==============================================================================<br>
> --- compiler-rt/trunk/test/xray/TestCases/Linux/func-id-utils.cc (added)<br>
> +++ compiler-rt/trunk/test/xray/TestCases/Linux/func-id-utils.cc Thu May  4 20:27:11 2017<br>
> @@ -0,0 +1,46 @@<br>
> +// Check that we can turn a function id to a function address, and also get the<br>
> +// maximum function id for the current binary.<br>
> +//<br>
> +// RUN: %clangxx_xray -std=c++11 %s -o %t<br>
> +// RUN: XRAY_OPTIONS="patch_premain=false xray_naive_log=false" %run %t | FileCheck %s<br>
> +<br>
> +#include "xray/xray_interface.h"<br>
> +#include <algorithm><br>
> +#include <cstdio><br>
> +#include <set><br>
> +#include <iterator><br>
> +<br>
> +[[clang::xray_always_instrument]] void bar(){<br>
> +    // do nothing!<br>
> +}<br>
> +<br>
> +    [[clang::xray_always_instrument]] void foo() {<br>
> +  bar();<br>
> +}<br>
> +<br>
> +[[clang::xray_always_instrument]] int main(int argc, char *argv[]) {<br>
> +  printf("max function id: %zu\n", __xray_max_function_id());<br>
> +  // CHECK: max function id: [[MAX:.*]]<br>
> +<br>
> +  std::set<void *> must_be_instrumented;<br>
> +  must_be_instrumented.insert(reinterpret_cast<void*>(&foo));<br>
> +  must_be_instrumented.insert(reinterpret_cast<void*>(&bar));<br>
> +  printf("addresses:\n");<br>
> +  std::set<void *> all_instrumented;<br>
> +  for (auto i = __xray_max_function_id(); i != 0; --i) {<br>
> +    auto addr = __xray_function_address(i);<br>
> +    printf("#%lu -> @%04lx\n", i, addr);<br>
> +    all_instrumented.insert(reinterpret_cast<void *>(addr));<br>
> +  }<br>
> +<br>
> +  // CHECK-LABEL: addresses:<br>
> +  // CHECK: #[[MAX]] -> @[[ADDR:.*]]<br>
> +  // CHECK-NOT: #0 -> @{{.*}}<br>
> +  std::set<void *> common;<br>
> +<br>
> +  std::set_intersection(all_instrumented.begin(), all_instrumented.end(),<br>
> +                        must_be_instrumented.begin(),<br>
> +                        must_be_instrumented.end(),<br>
> +                        std::inserter(common, common.begin()));<br>
> +  return common == must_be_instrumented ? 0 : 1;<br>
> +}<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
><br>
<br>
<br>
--<br>
<br>
-Bill Seurer<br>
<br>
</blockquote></div>
</blockquote></div>