<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [PPC] Lowering of llvm.init_trampoline problem with libgcc"
   href="https://bugs.llvm.org/show_bug.cgi?id=49004">49004</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[PPC] Lowering of llvm.init_trampoline problem with libgcc
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: PowerPC
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>v.churavy@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, nemanja.i.ibm@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>@llvm.init_trampoline on PPC lowers [1] to a call to `__trampoline_setup` which
IIUC is either defined in libgcc [2] or compiler-rt [3]. As far as I can tell
`compiler-rt` doesn't implement it for powerpc64le, and libgcc has a bug in the
assembly where it checks that the passed `trampoline size` (size of the
allocated buffer) is **smaller** than the required/computed by the linker
`trampoline size`. `r8` contains the  trampoline size as calculated by the
linker, and `r4` contains the trampoline size passed in from the outside. LLVM
will always pass 48 as a value on ppc64le, whereas the calculated trampoline
size could vary and on the systems I have access to is `32`.

`libgcc` then does a:

if (r4 < r8)
  abort();

[1]
<a href="https://github.com/llvm/llvm-project/blob/ffc3e800c65ee58166255ff897f8b7e6d850ddda/llvm/lib/Target/PowerPC/PPCISelLowering.cpp#L3485">https://github.com/llvm/llvm-project/blob/ffc3e800c65ee58166255ff897f8b7e6d850ddda/llvm/lib/Target/PowerPC/PPCISelLowering.cpp#L3485</a>
[2]
<a href="https://github.com/gcc-mirror/gcc/blob/02551aa99960ff6b0d9a44d234b8f6c9b230788c/libgcc/config/rs6000/tramp.S#L150">https://github.com/gcc-mirror/gcc/blob/02551aa99960ff6b0d9a44d234b8f6c9b230788c/libgcc/config/rs6000/tramp.S#L150</a>
[3]
<a href="https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/builtins/trampoline_setup.c">https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/builtins/trampoline_setup.c</a>

I haven't been able to fill a bug against libgcc since account registration is
restricted.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>