[PATCH] D139163: Utils: Add utility pass to lower ifuncs
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 22 11:47:59 PST 2022
MaskRay added a comment.
In D139163#4012919 <https://reviews.llvm.org/D139163#4012919>, @arsenm wrote:
> In D139163#4012366 <https://reviews.llvm.org/D139163#4012366>, @MaskRay wrote:
>
>> What's the motivation for piggybacking the functionality on top of ifunc? Does AMDGPU want to use ifunc to do something special?
>
> I'm considering it as an option to deal with some of the builtin library complexity, so it would be used with a restricted set of known functions. I'm not planning on exposing this as a user facing feature. The resolver would be known trivial after link and optimize out most of the time, but needs a fallback where a global constructor will do just fine.
Is there a reason that reusing ifunc is better than a global function pointer? Here is an example of a global function pointer.
I just added it to https://maskray.me/blog/2021-01-18-gnu-indirect-function#alternative
void impl();
void (*resolver())() { return impl; }
extern void (*const ifunc)() = resolver();
void use() {
ifunc();
ifunc();
// ifunc = nullptr; // do not compile
}
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139163/new/
https://reviews.llvm.org/D139163
More information about the llvm-commits
mailing list