Skip to content

Commit b33dd7d

Browse files
Rollup merge of #130450 - workingjubilee:these-names-are-indirect, r=bjorn3
Reduce confusion about `make_indirect_byval` by renaming it As part of doing so, remove the incorrect handling of the wasm target's `make_indirect_byval` (i.e. using it at all).
2 parents 591ec6c + 51718e8 commit b33dd7d

File tree

9 files changed

+14
-39
lines changed

9 files changed

+14
-39
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) {
1414
return;
1515
}
1616
if arg.layout.is_aggregate() {
17-
arg.make_indirect_byval(None);
17+
arg.pass_by_stack_offset(None);
1818
} else {
1919
arg.extend_integer_width_to(32);
2020
}

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub enum PassMode {
6464
/// (which ensures that padding is preserved and that we do not rely on LLVM's struct layout),
6565
/// and will use the alignment specified in `attrs.pointee_align` (if `Some`) or the type's
6666
/// alignment (if `None`). This means that the alignment will not always
67-
/// match the Rust type's alignment; see documentation of `make_indirect_byval` for more info.
67+
/// match the Rust type's alignment; see documentation of `pass_by_stack_offset` for more info.
6868
///
6969
/// `on_stack` cannot be true for unsized arguments, i.e., when `meta_attrs` is `Some`.
7070
Indirect { attrs: ArgAttributes, meta_attrs: Option<ArgAttributes>, on_stack: bool },
@@ -681,7 +681,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
681681
/// either in the caller (if the type's alignment is lower than the byval alignment)
682682
/// or in the callee (if the type's alignment is higher than the byval alignment),
683683
/// to ensure that Rust code never sees an underaligned pointer.
684-
pub fn make_indirect_byval(&mut self, byval_align: Option<Align>) {
684+
pub fn pass_by_stack_offset(&mut self, byval_align: Option<Align>) {
685685
assert!(!self.layout.is_unsized(), "used byval ABI for unsized layout");
686686
self.make_indirect();
687687
match self.mode {
@@ -879,8 +879,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
879879
{
880880
if abi == spec::abi::Abi::X86Interrupt {
881881
if let Some(arg) = self.args.first_mut() {
882-
// FIXME(pcwalton): This probably should use the x86 `byval` ABI...
883-
arg.make_indirect_byval(None);
882+
arg.pass_by_stack_offset(None);
884883
}
885884
return Ok(());
886885
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ where
4040
}
4141
arg.extend_integer_width_to(32);
4242
if arg.layout.is_aggregate() && !unwrap_trivial_aggregate(cx, arg) {
43-
arg.make_indirect_byval(None);
43+
arg.make_indirect();
4444
}
4545
}
4646

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ where
122122
align_4
123123
};
124124

125-
arg.make_indirect_byval(Some(byval_align));
125+
arg.pass_by_stack_offset(Some(byval_align));
126126
} else {
127127
arg.extend_integer_width_to(32);
128128
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ where
219219
if is_arg {
220220
// The x86_64 ABI doesn't have any special requirements for `byval` alignment,
221221
// the type's alignment is always used.
222-
arg.make_indirect_byval(None);
222+
arg.pass_by_stack_offset(None);
223223
} else {
224224
// `sret` parameter thus one less integer register available
225225
arg.make_indirect();

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ where
6868
*arg_gprs_left -= needed_arg_gprs;
6969

7070
if must_use_stack {
71-
arg.make_indirect_byval(None);
71+
arg.pass_by_stack_offset(None);
7272
} else if is_xtensa_aggregate(arg) {
7373
// Aggregates which are <= max_size will be passed in
7474
// registers if possible, so coerce to integers.

tests/codegen/align-byval.rs

+2-26
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// ignore-tidy-linelength
2-
//@ revisions:m68k wasm x86_64-linux x86_64-windows i686-linux i686-windows
2+
//@ revisions:m68k x86_64-linux x86_64-windows i686-linux i686-windows
33

44
//@[m68k] compile-flags: --target m68k-unknown-linux-gnu
55
//@[m68k] needs-llvm-components: m68k
6-
//@[wasm] compile-flags: --target wasm32-unknown-emscripten
7-
//@[wasm] needs-llvm-components: webassembly
86
//@[x86_64-linux] compile-flags: --target x86_64-unknown-linux-gnu
97
//@[x86_64-linux] needs-llvm-components: x86
108
//@[x86_64-windows] compile-flags: --target x86_64-pc-windows-msvc
@@ -15,7 +13,7 @@
1513
//@[i686-windows] needs-llvm-components: x86
1614

1715
// Tests that `byval` alignment is properly specified (#80127).
18-
// The only targets that use `byval` are m68k, wasm, x86-64, and x86.
16+
// The only targets that use `byval` are m68k, x86-64, and x86.
1917
// Note also that Windows mandates a by-ref ABI here, so it does not use byval.
2018

2119
#![feature(no_core, lang_items)]
@@ -112,9 +110,6 @@ pub unsafe fn call_na1(x: NaturalAlign1) {
112110
// m68k: [[ALLOCA:%[a-z0-9+]]] = alloca [2 x i8], align 1
113111
// m68k: call void @natural_align_1({{.*}}byval([2 x i8]) align 1{{.*}} [[ALLOCA]])
114112

115-
// wasm: [[ALLOCA:%[a-z0-9+]]] = alloca [2 x i8], align 1
116-
// wasm: call void @natural_align_1({{.*}}byval([2 x i8]) align 1{{.*}} [[ALLOCA]])
117-
118113
// x86_64-linux: call void @natural_align_1(i16
119114

120115
// x86_64-windows: call void @natural_align_1(i16
@@ -133,7 +128,6 @@ pub unsafe fn call_na2(x: NaturalAlign2) {
133128
// CHECK: start:
134129

135130
// m68k-NEXT: call void @natural_align_2
136-
// wasm-NEXT: call void @natural_align_2
137131
// x86_64-linux-NEXT: call void @natural_align_2
138132
// x86_64-windows-NEXT: call void @natural_align_2
139133

@@ -204,8 +198,6 @@ pub unsafe fn call_fa16(x: ForceAlign16) {
204198
extern "C" {
205199
// m68k: declare void @natural_align_1({{.*}}byval([2 x i8]) align 1{{.*}})
206200

207-
// wasm: declare void @natural_align_1({{.*}}byval([2 x i8]) align 1{{.*}})
208-
209201
// x86_64-linux: declare void @natural_align_1(i16)
210202

211203
// x86_64-windows: declare void @natural_align_1(i16)
@@ -217,8 +209,6 @@ extern "C" {
217209

218210
// m68k: declare void @natural_align_2({{.*}}byval([34 x i8]) align 2{{.*}})
219211

220-
// wasm: declare void @natural_align_2({{.*}}byval([34 x i8]) align 2{{.*}})
221-
222212
// x86_64-linux: declare void @natural_align_2({{.*}}byval([34 x i8]) align 2{{.*}})
223213

224214
// x86_64-windows: declare void @natural_align_2(
@@ -232,8 +222,6 @@ extern "C" {
232222

233223
// m68k: declare void @force_align_4({{.*}}byval([20 x i8]) align 4{{.*}})
234224

235-
// wasm: declare void @force_align_4({{.*}}byval([20 x i8]) align 4{{.*}})
236-
237225
// x86_64-linux: declare void @force_align_4({{.*}}byval([20 x i8]) align 4{{.*}})
238226

239227
// x86_64-windows: declare void @force_align_4(
@@ -247,8 +235,6 @@ extern "C" {
247235

248236
// m68k: declare void @natural_align_8({{.*}}byval([24 x i8]) align 4{{.*}})
249237

250-
// wasm: declare void @natural_align_8({{.*}}byval([24 x i8]) align 8{{.*}})
251-
252238
// x86_64-linux: declare void @natural_align_8({{.*}}byval([24 x i8]) align 8{{.*}})
253239

254240
// x86_64-windows: declare void @natural_align_8(
@@ -262,8 +248,6 @@ extern "C" {
262248

263249
// m68k: declare void @force_align_8({{.*}}byval([24 x i8]) align 8{{.*}})
264250

265-
// wasm: declare void @force_align_8({{.*}}byval([24 x i8]) align 8{{.*}})
266-
267251
// x86_64-linux: declare void @force_align_8({{.*}}byval([24 x i8]) align 8{{.*}})
268252

269253
// x86_64-windows: declare void @force_align_8(
@@ -279,8 +263,6 @@ extern "C" {
279263

280264
// m68k: declare void @lower_fa8({{.*}}byval([24 x i8]) align 4{{.*}})
281265

282-
// wasm: declare void @lower_fa8({{.*}}byval([24 x i8]) align 8{{.*}})
283-
284266
// x86_64-linux: declare void @lower_fa8({{.*}}byval([24 x i8]) align 8{{.*}})
285267

286268
// x86_64-windows: declare void @lower_fa8(
@@ -294,8 +276,6 @@ extern "C" {
294276

295277
// m68k: declare void @wrapped_fa8({{.*}}byval([24 x i8]) align 8{{.*}})
296278

297-
// wasm: declare void @wrapped_fa8({{.*}}byval([24 x i8]) align 8{{.*}})
298-
299279
// x86_64-linux: declare void @wrapped_fa8({{.*}}byval([24 x i8]) align 8{{.*}})
300280

301281
// x86_64-windows: declare void @wrapped_fa8(
@@ -311,8 +291,6 @@ extern "C" {
311291

312292
// m68k: declare void @transparent_fa8({{.*}}byval([24 x i8]) align 8{{.*}})
313293

314-
// wasm: declare void @transparent_fa8({{.*}}byval([24 x i8]) align 8{{.*}})
315-
316294
// x86_64-linux: declare void @transparent_fa8({{.*}}byval([24 x i8]) align 8{{.*}})
317295

318296
// x86_64-windows: declare void @transparent_fa8(
@@ -328,8 +306,6 @@ extern "C" {
328306

329307
// m68k: declare void @force_align_16({{.*}}byval([80 x i8]) align 16{{.*}})
330308

331-
// wasm: declare void @force_align_16({{.*}}byval([80 x i8]) align 16{{.*}})
332-
333309
// x86_64-linux: declare void @force_align_16({{.*}}byval([80 x i8]) align 16{{.*}})
334310

335311
// x86_64-windows: declare void @force_align_16(

tests/codegen/repr/transparent-byval-struct-ptr.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ revisions: i686-linux i686-freebsd x64-linux x64-apple wasm32
1+
//@ revisions: i686-linux i686-freebsd x64-linux x64-apple
22
//@ compile-flags: -O -C no-prepopulate-passes
33

44
//@[i686-linux] compile-flags: --target i686-unknown-linux-gnu
@@ -9,8 +9,6 @@
99
//@[x64-linux] needs-llvm-components: x86
1010
//@[x64-apple] compile-flags: --target x86_64-apple-darwin
1111
//@[x64-apple] needs-llvm-components: x86
12-
//@[wasm32] compile-flags: --target wasm32-wasi
13-
//@[wasm32] needs-llvm-components: webassembly
1412

1513
// See ./transparent.rs
1614
// Some platforms pass large aggregates using immediate arrays in LLVMIR

tests/codegen/repr/transparent-opaque-ptr.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
//@ revisions: aarch64-linux aarch64-darwin
1+
//@ revisions: aarch64-linux aarch64-darwin wasm32-wasi
22
//@ compile-flags: -O -C no-prepopulate-passes
33

44
//@[aarch64-linux] compile-flags: --target aarch64-unknown-linux-gnu
55
//@[aarch64-linux] needs-llvm-components: aarch64
66
//@[aarch64-darwin] compile-flags: --target aarch64-apple-darwin
77
//@[aarch64-darwin] needs-llvm-components: aarch64
8+
//@[wasm32-wasi] compile-flags: --target wasm32-wasi
9+
//@[wasm32-wasi] needs-llvm-components: webassembly
810

911
// See ./transparent.rs
1012
// Some platforms pass large aggregates using immediate arrays in LLVMIR

0 commit comments

Comments
 (0)