Skip to content

Commit 3bc5c19

Browse files
committed
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.
1 parent e517798 commit 3bc5c19

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
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
@@ -170,6 +170,11 @@ pub(super) fn deduced_param_attrs<'tcx>(
170170

171171
// Grab the optimized MIR. Analyze it to determine which arguments have been mutated.
172172
let body: &Body<'tcx> = tcx.optimized_mir(def_id);
173+
// Arguments spread at ABI level are currently unsupported.
174+
if body.spread_arg.is_some() {
175+
return &[];
176+
}
177+
173178
let mut deduce_read_only = DeduceReadOnly::new(body.arg_count);
174179
deduce_read_only.visit_body(body);
175180
tracing::trace!(?deduce_read_only.read_only);

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![crate_type = "lib"]
44
#![allow(internal_features)]
55
#![feature(unsized_fn_params)]
6+
#![feature(unboxed_closures)]
67

78
use std::cell::Cell;
89
use std::hint;
@@ -79,3 +80,11 @@ pub fn forward_big_cell_container(big_cell_container: BigCellContainer) {
7980
pub fn forward_big_container(big_struct: BigStruct) {
8081
use_something_freeze(big_struct)
8182
}
83+
84+
// Arguments spread at ABI level are unsupported.
85+
//
86+
// CHECK-LABEL: @spread_arg(
87+
// CHECK-NOT: readonly
88+
// CHECK-SAME: )
89+
#[no_mangle]
90+
pub extern "rust-call" fn spread_arg(_: (BigStruct, BigStruct, BigStruct)) {}

0 commit comments

Comments
 (0)