-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[GlobalOpt] Crash when optimizing global alias to ifunc. #96197
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
@jroelofs I believe the optimization of static ifuncs does not interact well with the optimization of global aliases. If we guard your optimization by checking that none of the ifunc users is a global alias, then it will never trigger. So perhaps we want to remove the emission of the alias from clang in the first place. I am not sure why it's there, if anyone relies on it. Perhaps @DanielKristofKiss knows. More digging -> #74358 (comment) |
We could guard it on not having a global alias, or if there is one, on having a definition for the resolvee. It would turn the optimization off for forward declaration uses like this one, and keep it for uses within a TU or in LTO. |
That's an option; a bit conservative in my opinion. For non LTO compilation with version declaration in one file and implementation in another your optimization won't trigger. I guess it's the only option if we care about backwards compatibility, which was the reason we added the alias in the first place as far as I understand from reading #74358. |
Fixes llvm#96197. A global alias should always point to a definition. Ifuncs are definitions, so far so good. However an ifunc may be statically resolved to a function that is declared but not defined in the translation unit. With this patch we perform static resolution if: * the resolvee is defined * otherwise none of the ifunc users is a global alias
Long story short the interaction of two optimizations happening in GlobalOpt results in a crash. For more details look at the issue llvm#96197. I will be fixing this in GlobalOpt but it is a conservative solution since it won't allow us to optimize resolvers which return a pointer to a function whose definition is in another TU when compiling without LTO: __attribute__((target_version("simd"))) void bar(void); __attribute__((target_version("default"))) void bar(void); int foo() { bar(); }
Alias added due to conservative thinking, nothing more. |
Long story short the interaction of two optimizations happening in GlobalOpt results in a crash. For more details look at the issue #96197. I will be fixing this in GlobalOpt but it is a conservative solution since it won't allow us to optimize resolvers which return a pointer to a function whose definition is in another TU when compiling without LTO: ``` __attribute__((target_version("simd"))) void bar(void); __attribute__((target_version("default"))) void bar(void); int foo() { bar(); } ``` fixes: #96197
…lvm#96220) Fixes llvm#96197. A global alias should always point to a definition. Ifuncs are definitions, so far so good. However an ifunc may be statically resolved to a function that is declared but not defined in the translation unit. With this patch we perform static resolution if: * the resolvee is defined, else if * none of the ifunc users is a global alias
Long story short the interaction of two optimizations happening in GlobalOpt results in a crash. For more details look at the issue llvm#96197. I will be fixing this in GlobalOpt but it is a conservative solution since it won't allow us to optimize resolvers which return a pointer to a function whose definition is in another TU when compiling without LTO: ``` __attribute__((target_version("simd"))) void bar(void); __attribute__((target_version("default"))) void bar(void); int foo() { bar(); } ``` fixes: llvm#96197
Uh oh!
There was an error while loading. Please reload this page.
We found a crash when compiling a trivial examle of Function Multiversioning on AArch64:
$ clang -O3 --target=aarch64-linux-gnu -rtlib=compiler-rt -c test.c
Looks like we are trying to run an analysis on a function declaration or something like that. Digging more I found that the problem comes from GlobalOpt. Here is the minimal reproducer:
$ opt -passes=globalopt -S test.ll -debug
The text was updated successfully, but these errors were encountered: