Skip to content

Commit 9489751

Browse files
authored
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.
2 parents 8da95ac + e9252a4 commit 9489751

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

compiler/rustc_mir_transform/src/deduce_param_attrs.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ pub(super) fn deduced_param_attrs<'tcx>(
195195

196196
// Grab the optimized MIR. Analyze it to determine which arguments have been mutated.
197197
let body: &Body<'tcx> = tcx.optimized_mir(def_id);
198+
// Arguments spread at ABI level are currently unsupported.
199+
if body.spread_arg.is_some() {
200+
return &[];
201+
}
202+
198203
let mut deduce = DeduceParamAttrs::new(body);
199204
deduce.visit_body(body);
200205
tracing::trace!(?deduce.usage);

tests/codegen-llvm/deduced-param-attrs.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//@ revisions: LLVM21 LLVM20
44
//@ [LLVM21] min-llvm-version: 21
55
//@ [LLVM20] max-llvm-major-version: 20
6-
#![feature(custom_mir, core_intrinsics)]
6+
#![feature(custom_mir, core_intrinsics, unboxed_closures)]
77
#![crate_type = "lib"]
88
extern crate core;
99
use core::intrinsics::mir::*;
@@ -170,3 +170,11 @@ pub fn not_captured_return_place() -> [u8; 80] {
170170
pub fn captured_return_place() -> [u8; 80] {
171171
black_box([0u8; 80])
172172
}
173+
174+
// Arguments spread at ABI level are unsupported.
175+
//
176+
// CHECK-LABEL: @spread_arg(
177+
// CHECK-NOT: readonly
178+
// CHECK-SAME: )
179+
#[no_mangle]
180+
pub extern "rust-call" fn spread_arg(_: (Big, Big, Big)) {}

0 commit comments

Comments
 (0)