Skip to content

Commit b05fd2a

Browse files
committed
Auto merge of #81388 - bjorn3:wasm_bindgen_fix, r=nikomatsakis
Fix abi for wasm-bindgen Hopefully fixes #81386. `@alexcrichton` can you confirm this fixes wasm-bindgen? r? `@alexcrichton`
2 parents c0b64d9 + c1c06f3 commit b05fd2a

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

compiler/rustc_middle/src/ty/layout.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -2866,10 +2866,9 @@ where
28662866
let max_by_val_size = Pointer.size(cx) * 2;
28672867
let size = arg.layout.size;
28682868

2869-
let is_indirect_not_on_stack =
2870-
matches!(arg.mode, PassMode::Indirect { on_stack: false, .. });
2871-
assert!(is_indirect_not_on_stack, "{:?}", arg);
2872-
if !arg.layout.is_unsized() && size <= max_by_val_size {
2869+
if arg.layout.is_unsized() || size > max_by_val_size {
2870+
arg.make_indirect();
2871+
} else {
28732872
// We want to pass small aggregates as immediates, but using
28742873
// a LLVM aggregate type for this leads to bad optimizations,
28752874
// so we pick an appropriately sized integer type instead.

compiler/rustc_target/src/abi/call/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub enum PassMode {
3232
Ignore,
3333
/// Pass the argument directly.
3434
///
35-
/// The argument has a layout abi of `Scalar` or `Vector`.
35+
/// The argument has a layout abi of `Scalar`, `Vector` or in rare cases `Aggregate`.
3636
Direct(ArgAttributes),
3737
/// Pass a pair's elements directly in two arguments.
3838
///
@@ -453,7 +453,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
453453
scalar_attrs(&layout, b, a.value.size(cx).align_to(b.value.align(cx).abi)),
454454
),
455455
Abi::Vector { .. } => PassMode::Direct(ArgAttributes::new()),
456-
Abi::Aggregate { .. } => Self::indirect_pass_mode(&layout),
456+
Abi::Aggregate { .. } => PassMode::Direct(ArgAttributes::new()),
457457
};
458458
ArgAbi { layout, pad: None, mode }
459459
}

0 commit comments

Comments
 (0)