Rollup merge of #148131 - tmiasko:deduce-spread-arg, r=wesleywiser

Skip parameter attribute deduction for MIR with `spread_arg`

When a MIR argument is spread at ABI level, deduced attributes are potentially misapplied, since a spread argument can correspond to zero or more arguments at ABI level.

Disable deduction for MIR using spread argument for the time being.
This commit is contained in:
Matthias Krüger
2025-10-29 08:07:50 +01:00
committed by GitHub
2 changed files with 14 additions and 1 deletions

View File

@@ -195,6 +195,11 @@ pub(super) fn deduced_param_attrs<'tcx>(
// Grab the optimized MIR. Analyze it to determine which arguments have been mutated. // Grab the optimized MIR. Analyze it to determine which arguments have been mutated.
let body: &Body<'tcx> = tcx.optimized_mir(def_id); let body: &Body<'tcx> = tcx.optimized_mir(def_id);
// Arguments spread at ABI level are currently unsupported.
if body.spread_arg.is_some() {
return &[];
}
let mut deduce = DeduceParamAttrs::new(body); let mut deduce = DeduceParamAttrs::new(body);
deduce.visit_body(body); deduce.visit_body(body);
tracing::trace!(?deduce.usage); tracing::trace!(?deduce.usage);

View File

@@ -3,7 +3,7 @@
//@ revisions: LLVM21 LLVM20 //@ revisions: LLVM21 LLVM20
//@ [LLVM21] min-llvm-version: 21 //@ [LLVM21] min-llvm-version: 21
//@ [LLVM20] max-llvm-major-version: 20 //@ [LLVM20] max-llvm-major-version: 20
#![feature(custom_mir, core_intrinsics)] #![feature(custom_mir, core_intrinsics, unboxed_closures)]
#![crate_type = "lib"] #![crate_type = "lib"]
extern crate core; extern crate core;
use core::intrinsics::mir::*; use core::intrinsics::mir::*;
@@ -170,3 +170,11 @@ pub fn not_captured_return_place() -> [u8; 80] {
pub fn captured_return_place() -> [u8; 80] { pub fn captured_return_place() -> [u8; 80] {
black_box([0u8; 80]) black_box([0u8; 80])
} }
// Arguments spread at ABI level are unsupported.
//
// CHECK-LABEL: @spread_arg(
// CHECK-NOT: readonly
// CHECK-SAME: )
#[no_mangle]
pub extern "rust-call" fn spread_arg(_: (Big, Big, Big)) {}