-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Support calling functions with SIMD vectors that couldn't be used in the caller #132865
Copy link
Copy link
Open
Labels
A-ABIArea: Concerning the application binary interface (ABI)Area: Concerning the application binary interface (ABI)A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-SIMDArea: SIMD (Single Instruction Multiple Data)Area: SIMD (Single Instruction Multiple Data)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-opsemRelevant to the opsem teamRelevant to the opsem teamWG-llvmWorking group: LLVM backend code generationWorking group: LLVM backend code generation
Metadata
Metadata
Assignees
Labels
A-ABIArea: Concerning the application binary interface (ABI)Area: Concerning the application binary interface (ABI)A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-SIMDArea: SIMD (Single Instruction Multiple Data)Area: SIMD (Single Instruction Multiple Data)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-opsemRelevant to the opsem teamRelevant to the opsem teamWG-llvmWorking group: LLVM backend code generationWorking group: LLVM backend code generation
Type
Fields
Give feedbackNo fields configured for issues without a type.
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_featureusing 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:
alwaysinlineloses ABI-relevant target feature information atcalloperations llvm/llvm-project#70563) -- I am told this is quite hardavxfeature 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