about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-01-28 22:01:42 +0000
committerbors <bors@rust-lang.org>2021-01-28 22:01:42 +0000
commitb05fd2a15de7c9e50110e9ed4c01f114be215739 (patch)
tree1ae77b99a62b6d881988b65172372e6ab2749755
parentc0b64d97beebb09325b5587abed39f4f1621026f (diff)
parentc1c06f3e3f7bbe7336709f2b4749e969b44c0dbb (diff)
downloadrust-b05fd2a15de7c9e50110e9ed4c01f114be215739.tar.gz
rust-b05fd2a15de7c9e50110e9ed4c01f114be215739.zip
Auto merge of #81388 - bjorn3:wasm_bindgen_fix, r=nikomatsakis
Fix abi for wasm-bindgen

Hopefully fixes https://github.com/rust-lang/rust/issues/81386. `@alexcrichton` can you confirm this fixes wasm-bindgen?

r? `@alexcrichton`
-rw-r--r--compiler/rustc_middle/src/ty/layout.rs7
-rw-r--r--compiler/rustc_target/src/abi/call/mod.rs4
2 files changed, 5 insertions, 6 deletions
diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs
index ee837d88b7b..adee88ac1c9 100644
--- a/compiler/rustc_middle/src/ty/layout.rs
+++ b/compiler/rustc_middle/src/ty/layout.rs
@@ -2866,10 +2866,9 @@ where
                 let max_by_val_size = Pointer.size(cx) * 2;
                 let size = arg.layout.size;
 
-                let is_indirect_not_on_stack =
-                    matches!(arg.mode, PassMode::Indirect { on_stack: false, .. });
-                assert!(is_indirect_not_on_stack, "{:?}", arg);
-                if !arg.layout.is_unsized() && size <= max_by_val_size {
+                if arg.layout.is_unsized() || size > max_by_val_size {
+                    arg.make_indirect();
+                } else {
                     // We want to pass small aggregates as immediates, but using
                     // a LLVM aggregate type for this leads to bad optimizations,
                     // so we pick an appropriately sized integer type instead.
diff --git a/compiler/rustc_target/src/abi/call/mod.rs b/compiler/rustc_target/src/abi/call/mod.rs
index 2cbd52bf3e9..aa1c31bda54 100644
--- a/compiler/rustc_target/src/abi/call/mod.rs
+++ b/compiler/rustc_target/src/abi/call/mod.rs
@@ -32,7 +32,7 @@ pub enum PassMode {
     Ignore,
     /// Pass the argument directly.
     ///
-    /// The argument has a layout abi of `Scalar` or `Vector`.
+    /// The argument has a layout abi of `Scalar`, `Vector` or in rare cases `Aggregate`.
     Direct(ArgAttributes),
     /// Pass a pair's elements directly in two arguments.
     ///
@@ -453,7 +453,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
                 scalar_attrs(&layout, b, a.value.size(cx).align_to(b.value.align(cx).abi)),
             ),
             Abi::Vector { .. } => PassMode::Direct(ArgAttributes::new()),
-            Abi::Aggregate { .. } => Self::indirect_pass_mode(&layout),
+            Abi::Aggregate { .. } => PassMode::Direct(ArgAttributes::new()),
         };
         ArgAbi { layout, pad: None, mode }
     }