[PATCH] D149848: [AArch64, compiler-rt] Implement trampoline intrinsics

Saleem Abdulrasool via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 30 20:15:05 PDT 2023


compnerd added inline comments.


================
Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:5776
+    report_fatal_error("trampoline intrinsics are "
+                       "not supported on this platform.");
+
----------------
iamlouk wrote:
> compnerd wrote:
> > Is this intrinsic available in GCC?  When was it added there?  This could be an ABI break otherwise.  We should check the runtime that we are going to link against before lowering this I think.
> No, GCC/libgcc does not have this for AArch64. GCC actually writes a trampoline template into the text section, then copies it over onto the stack of the function that calls GCCs equivalent of init.trampoline, and then creates instructions that store the address of the function and nest parameter into the copied-over template.
> 
> On x86 for example, inlining the trampoline creation is very simple because there is a instruction for loading a 64 bit immediate, but the lack thereof makes this tricky on AArch64.
> 
> I can give a version that is more similar to what GCC does a try, if that is preferred. That would remove the call to compiler-rt (and the function there), but make the lowering of the intrinsic a lot more complex.
> 
> It is maybe worth pointing out that clang does not actually implement nested functions, and will never create these intrinsics, so I don't know what ABI would break here.
> 
> (Sorry for the very late reply)
That makes this even less valuable - GCC will not create the call, clang will not create the function.  I think that doing what GCC does here is the correct thing to do.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149848/new/

https://reviews.llvm.org/D149848



More information about the llvm-commits mailing list