Skip to content

Commit eb99ea5

Browse files
committed
Revert "Wasm-bindgen abi compat using cast_to"
This reverts commit 903c553.
1 parent 903c553 commit eb99ea5

File tree

3 files changed

+9
-49
lines changed

3 files changed

+9
-49
lines changed

compiler/rustc_middle/src/ty/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2860,7 +2860,7 @@ where
28602860
return;
28612861
}
28622862

2863-
if let Err(msg) = self.adjust_for_cabi(cx, &cx.tcx().sess.target_features, abi) {
2863+
if let Err(msg) = self.adjust_for_cabi(cx, abi) {
28642864
cx.tcx().sess.fatal(&msg);
28652865
}
28662866
}

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

+2-9
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ pub enum PassMode {
5353
// Hack to disable non_upper_case_globals only for the bitflags! and not for the rest
5454
// of this module
5555
pub use attr_impl::ArgAttribute;
56-
use rustc_data_structures::stable_set::FxHashSet;
57-
use rustc_span::Symbol;
5856

5957
#[allow(non_upper_case_globals)]
6058
#[allow(unused)]
@@ -594,12 +592,7 @@ pub struct FnAbi<'a, Ty> {
594592
}
595593

596594
impl<'a, Ty> FnAbi<'a, Ty> {
597-
pub fn adjust_for_cabi<C>(
598-
&mut self,
599-
cx: &C,
600-
target_features: &FxHashSet<Symbol>,
601-
abi: spec::abi::Abi,
602-
) -> Result<(), String>
595+
pub fn adjust_for_cabi<C>(&mut self, cx: &C, abi: spec::abi::Abi) -> Result<(), String>
603596
where
604597
Ty: TyAndLayoutMethods<'a, C> + Copy,
605598
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
@@ -640,7 +633,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
640633
"riscv32" | "riscv64" => riscv::compute_abi_info(cx, self),
641634
"wasm32" => match cx.target_spec().os.as_str() {
642635
"emscripten" | "wasi" => wasm32::compute_abi_info(cx, self),
643-
_ => wasm32_bindgen_compat::compute_abi_info(cx, target_features, self),
636+
_ => wasm32_bindgen_compat::compute_abi_info(self),
644637
},
645638
"asmjs" => wasm32::compute_abi_info(cx, self),
646639
a => return Err(format!("unrecognized arch \"{}\" in target specification", a)),

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

+6-39
Original file line numberDiff line numberDiff line change
@@ -5,58 +5,25 @@
55
// can be fixed to work with the correct ABI. See #63649 for further
66
// discussion.
77

8-
use rustc_data_structures::stable_set::FxHashSet;
9-
use rustc_span::Symbol;
8+
use crate::abi::call::{ArgAbi, FnAbi};
109

11-
use crate::abi::call::{ArgAbi, FnAbi, Uniform};
12-
use crate::abi::{HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
13-
14-
fn classify_ret<'a, Ty, C>(cx: &C, target_features: &FxHashSet<Symbol>, ret: &mut ArgAbi<'a, Ty>)
15-
where
16-
Ty: TyAndLayoutMethods<'a, C> + Copy,
17-
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
18-
{
19-
if ret.layout.is_aggregate() {
20-
if let Some(unit) = ret.layout.homogeneous_aggregate(cx).ok().and_then(|ha| ha.unit()) {
21-
let size = ret.layout.size;
22-
if unit.size == size || target_features.contains(&Symbol::intern("multivalue")) {
23-
ret.cast_to(Uniform { unit, total: size });
24-
}
25-
}
26-
}
10+
fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
2711
ret.extend_integer_width_to(32);
2812
}
2913

30-
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
31-
where
32-
Ty: TyAndLayoutMethods<'a, C> + Copy,
33-
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
34-
{
35-
if arg.layout.is_aggregate() {
36-
if let Some(unit) = arg.layout.homogeneous_aggregate(cx).ok().and_then(|ha| ha.unit()) {
37-
let size = arg.layout.size;
38-
arg.cast_to(Uniform { unit, total: size });
39-
}
40-
}
14+
fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) {
4115
arg.extend_integer_width_to(32);
4216
}
4317

44-
pub fn compute_abi_info<'a, Ty, C>(
45-
cx: &C,
46-
target_features: &FxHashSet<Symbol>,
47-
fn_abi: &mut FnAbi<'a, Ty>,
48-
) where
49-
Ty: TyAndLayoutMethods<'a, C> + Copy,
50-
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
51-
{
18+
pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
5219
if !fn_abi.ret.is_ignore() {
53-
classify_ret(cx, target_features, &mut fn_abi.ret);
20+
classify_ret(&mut fn_abi.ret);
5421
}
5522

5623
for arg in &mut fn_abi.args {
5724
if arg.is_ignore() {
5825
continue;
5926
}
60-
classify_arg(cx, arg);
27+
classify_arg(arg);
6128
}
6229
}

0 commit comments

Comments
 (0)