-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
Inlining can cause vector ABI mismatch #52660
Comments
The idea to determine call ABI based on callee target features does not work out because we don't always know the callee. While the callee function type and the calling convention are part of the call, the target features are part of the callee function, which may be unknown (indirect call). So I think the only option here is to prevent inlining in the first place. |
FWIW this is not quite true -- the I also wonder, what about other targets than X86? Won't they need the same treatment? |
@llvm/issue-subscribers-backend-x86 Author: Nikita Popov (nikic)
Consider the following input IR:
```
target triple = "x86_64-unknown-linux-gnu"
define void @test1() "target-features"="+avx" { define internal void @test2() { define i64 @test3(<4 x i64> %arg) noinline {
This inlining is allowed, because test1 has a superset of target features of test2. However, what is now going to happen is that the backend will lower the test3() call using ymm registers (because the function has avx target feature), while the function will expect the arguments in xmm registers (because it does not have avx target feature). Godbolt: https://llvm.godbolt.org/z/M95svT6qY I previously started a discussion about this on the mailing list, but did not get much response: https://groups.google.com/g/llvm-dev/c/g_6THpxasjA (Downstream reports of this miscompile are rust-lang/rust#79865 and rust-lang/rust#91839.) |
Consider the following input IR:
Running this through
opt -inline
produces:This inlining is allowed, because test1 has a superset of target features of test2. However, what is now going to happen is that the backend will lower the test3() call using ymm registers (because the function has avx target feature), while the function will expect the arguments in xmm registers (because it does not have avx target feature).
Godbolt: https://llvm.godbolt.org/z/M95svT6qY
I previously started a discussion about this on the mailing list, but did not get much response: https://groups.google.com/g/llvm-dev/c/g_6THpxasjA
(Downstream reports of this miscompile are rust-lang/rust#79865 and rust-lang/rust#91839.)
The text was updated successfully, but these errors were encountered: