Support calling functions with SIMD vectors that couldn't be used in the caller #132865
Labels
A-ABI
Area: Concerning the application binary interface (ABI)
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
A-SIMD
Area: SIMD (Single Instruction Multiple Data)
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-opsem
Relevant to the opsem team
WG-llvm
Working group: LLVM backend code generation
We now lint and will eventually error on this program:
The lint is necessary because the way we codegen this function would be unsound (and indeed, if you run this on the playground you can see that the argument value gets corrupted). See #116558 for more context.
However, there's no fundamental reason that we couldn't compile this code! We "just" need to generate the call to
with_target_feature
using its proper ABI, i.e., using the AVX registers. This is sound because the function anyway requires that target feature, so the caller must have already ensured that this target feature is available.The problem is that LLVM currently simply has no way to express such a call. So we have three options:
call
operations llvm/llvm-project#70563) -- I am told this is quite hardavx
feature gate, and calls the actual callee -- not a pretty solution since the extra function call is bad for performance, and performance is the reason people manually write SIMD code to begin withLucky enough, this only affects non-Rust ABIs, so users should only rarely run into this.
Cc @rust-lang/wg-llvm @rust-lang/opsem @chorman0773 @veluca93
The text was updated successfully, but these errors were encountered: