-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
OrcJIT breaks call with <4 x i64> vector #51373
Comments
Simplified version: define i32 @main() #0 { Instructions generated for the call: Instructions generated for new_function: So the call is using XMM0 and XMM1 for the argument and return value, but the function definition is using YMM0 only. |
This might be a compiler setup bug in JITTargetMachineBuilder, but that system is pretty simple. It seems more likely that this is a code generator bug. How did you generate the MIR in Comment #1? Is that coming out of the JIT? |
Yes, I ran lli --print-after-isel. |
Oh -- You're missing attribute #0 on new_function. I think that's the problem. Could you add it and see if it works? |
Yes, that fixed it. I can change my code to avoid producing the "target-features" mismatch, but I still suggest adding a check to OrcJIT, even if it's just an assertion. |
The proper place to catch this would be in the module verifier, which we do run on every module in LLI. Unfortunately it doesn't seem to catch this bug. I suspect that target-features attributes are opaque to the verifier, so it can't recognize the incompatibility. I've filed llvm/llvm-bugzilla-archive#52156 to investigate making this detectable, but it's outside my wheelhouse -- we'll have to wait for someone else to pick this up and run with it. |
mentioned in issue llvm/llvm-bugzilla-archive#52156 |
Extended Description
On x86-64, lli -jit-kind=orc executes the following code incorrectly. The return value from main should be 0. Instead, it returns 16. lli -jit-kind=mcjit and llc produce the correct output.
define i32 @main() #0 {
br label %1
1: ; preds = %1, %0
%2 = phi i64 [ 0, %0 ], [ %6, %1 ]
%3 = phi <4 x i64> [ <i64 -16, i64 -16, i64 -16, i64 -16>, %0 ], [ %5, %1 ]
%4 = trunc <4 x i64> %3 to <4 x i32>
%5 = call <4 x i64> @new_function(<4 x i64> %3)
%6 = add i64 %2, 1
%7 = icmp eq i64 %6, 2
br i1 %7, label %8, label %1
8: ; preds = %1
%9 = extractelement <4 x i32> %4, i32 3
ret i32 %9
}
define <4 x i64> @new_function(<4 x i64> %0) unnamed_addr {
%2 = add <4 x i64> %0, <i64 16, i64 16, i64 16, i64 16>
ret <4 x i64> %2
}
attributes #0 = { "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" }
The text was updated successfully, but these errors were encountered: