[PATCH] D74162: [Inliner] Inlining should honor nobuiltin attributes

Joseph Huber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 23 20:28:32 PDT 2023


jhuber6 added a comment.

In D74162#4526458 <https://reviews.llvm.org/D74162#4526458>, @efriedma wrote:

>> Was there a reason that we could not simply merge the nobuiltin attribute into the caller?
>
> The primary issue with LTO'ing parts of libc into a program is that we're basically crossing a line: once we start inlining calls into the program, "libc" is no longer an abstract interface, so we have to turn off libcall recognition for the whole module.  I don't think merging the nobuiltin markings when you inline a function is sufficient.

That's completely satisfactory at least for my case, as the GPU has no hosted environment we can make assumptions about not emitting such calls in the backend. There's a similar problem with this that I attempted to solve in https://reviews.llvm.org/D154364 but I'm currently rethinking. The problem there is that we prevent explicit internalization of recognized libcalls during LTO because the backend might emit a call to it later. I think at the end of the day we need a list of libcall functions that each backend can emit, rather than just assume each backend roughly emits everything x64 does. But I'm not familiar enough with the machinery to know where such a function could live. I was thinking that we could maybe has a pass that decorates libcalls with special attributes if we know from the target library info that it is not emitted by the backend, but I don't know how feasible that is in a generic IR pass before touching the backend, not overly familiar with that machinery.

As it stands, not being able to inline even something simple like `isalnum` on the GPU is not great, so I'd appreciate some help in figuring out some kind of workaround even if it's just for the GPU. I feel like this is a bit of an edge case since up until now no one has really considered being able to optimize out libcalls.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74162



More information about the llvm-commits mailing list