-
Notifications
You must be signed in to change notification settings - Fork 13.4k
unnecessary GOT lookup when calling visibility hidden or protected function #3520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Here is a somewhat analogous case on darwin (which uses a completely different pic model than linux): void g(); class attribute((visibility("hidden"))) Foo { test compiles to:
... with both GCC and llvm-gcc (the former indirecting through a darwin stub, the later not). The difference between the two is that the Foo::h compiles to having 'linkonce hidden' visibility. The merging behavior of linkonce happens before the internalization of hidden. However, would it always be safe to call directly to __ZN3Foo1hEv? |
Revision 60571 fixed a related problem that have to do with GV non-lazy pointer for Darwin. |
Chris, neither gcc nor llvm-gcc generates a stub indirect for your Darwin example. Can you check again? |
Nevermind my previous comments. gcc does generate a stub for Foo:h. llvm-gcc does not. |
On Mac OS X 10.5 and above, function stubs are automatically synthesized by dyld. That's why llvm is not emitting the stub. |
Support looking up absolute symbols
Looks like this got fixed in LLVM 2.9: https://godbolt.org/z/9asYxqxGK |
Extended Description
GCC elides the GOT lookup when calling a hidden or protected function. Here's a quick, silly example:
Firstly, if f() is empty, GCC inlines it into g() despite the noinline tag. I consider that naughty, and we shouldn't follow its lead there.
Because it's hidden, the GOT lookup is unnecessary. Please eliminate it. Same with protected.
The text was updated successfully, but these errors were encountered: