Skip to content

Commit 8707132

Browse files
committed
Auto merge of rust-lang#128968 - jieyouxu:rollup-l23j21x, r=jieyouxu
Rollup of 5 pull requests Successful merges: - rust-lang#128643 (Refactor `powerpc64` call ABI handling) - rust-lang#128873 (Add windows-targets crate to std's sysroot) - rust-lang#128916 (Tidy up `dump-ice-to-disk` and make assertion failures dump ICE messages) - rust-lang#128929 (Fix codegen-units tests that were disabled 8 years ago) - rust-lang#128937 (Fix warnings in rmake tests on `x86_64-unknown-linux-gnu`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents c9bd03c + d1b29fc commit 8707132

File tree

51 files changed

+437
-316
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+437
-316
lines changed

Diff for: compiler/rustc_target/src/abi/call/powerpc64.rs

+12-55
Original file line numberDiff line numberDiff line change
@@ -41,64 +41,23 @@ where
4141
})
4242
}
4343

44-
fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>, abi: ABI)
44+
fn classify<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>, abi: ABI, is_ret: bool)
4545
where
4646
Ty: TyAbiInterface<'a, C> + Copy,
4747
C: HasDataLayout,
4848
{
49-
if !ret.layout.is_sized() {
49+
if arg.is_ignore() || !arg.layout.is_sized() {
5050
// Not touching this...
5151
return;
5252
}
53-
if !ret.layout.is_aggregate() {
54-
ret.extend_integer_width_to(64);
53+
if !arg.layout.is_aggregate() {
54+
arg.extend_integer_width_to(64);
5555
return;
5656
}
5757

5858
// The ELFv1 ABI doesn't return aggregates in registers
59-
if abi == ELFv1 {
60-
ret.make_indirect();
61-
return;
62-
}
63-
64-
if let Some(uniform) = is_homogeneous_aggregate(cx, ret, abi) {
65-
ret.cast_to(uniform);
66-
return;
67-
}
68-
69-
let size = ret.layout.size;
70-
let bits = size.bits();
71-
if bits <= 128 {
72-
let unit = if cx.data_layout().endian == Endian::Big {
73-
Reg { kind: RegKind::Integer, size }
74-
} else if bits <= 8 {
75-
Reg::i8()
76-
} else if bits <= 16 {
77-
Reg::i16()
78-
} else if bits <= 32 {
79-
Reg::i32()
80-
} else {
81-
Reg::i64()
82-
};
83-
84-
ret.cast_to(Uniform::new(unit, size));
85-
return;
86-
}
87-
88-
ret.make_indirect();
89-
}
90-
91-
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>, abi: ABI)
92-
where
93-
Ty: TyAbiInterface<'a, C> + Copy,
94-
C: HasDataLayout,
95-
{
96-
if !arg.layout.is_sized() {
97-
// Not touching this...
98-
return;
99-
}
100-
if !arg.layout.is_aggregate() {
101-
arg.extend_integer_width_to(64);
59+
if is_ret && abi == ELFv1 {
60+
arg.make_indirect();
10261
return;
10362
}
10463

@@ -108,7 +67,10 @@ where
10867
}
10968

11069
let size = arg.layout.size;
111-
if size.bits() <= 64 {
70+
if is_ret && size.bits() > 128 {
71+
// Non-homogeneous aggregates larger than two doublewords are returned indirectly.
72+
arg.make_indirect();
73+
} else if size.bits() <= 64 {
11274
// Aggregates smaller than a doubleword should appear in
11375
// the least-significant bits of the parameter doubleword.
11476
arg.cast_to(Reg { kind: RegKind::Integer, size })
@@ -138,14 +100,9 @@ where
138100
}
139101
};
140102

141-
if !fn_abi.ret.is_ignore() {
142-
classify_ret(cx, &mut fn_abi.ret, abi);
143-
}
103+
classify(cx, &mut fn_abi.ret, abi, true);
144104

145105
for arg in fn_abi.args.iter_mut() {
146-
if arg.is_ignore() {
147-
continue;
148-
}
149-
classify_arg(cx, arg, abi);
106+
classify(cx, arg, abi, false);
150107
}
151108
}

Diff for: library/Cargo.lock

+6-1
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ dependencies = [
339339
"std_detect",
340340
"unwind",
341341
"wasi",
342+
"windows-targets 0.0.0",
342343
]
343344

344345
[[package]]
@@ -421,9 +422,13 @@ version = "0.52.0"
421422
source = "registry+https://github.com/rust-lang/crates.io-index"
422423
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
423424
dependencies = [
424-
"windows-targets",
425+
"windows-targets 0.52.5",
425426
]
426427

428+
[[package]]
429+
name = "windows-targets"
430+
version = "0.0.0"
431+
427432
[[package]]
428433
name = "windows-targets"
429434
version = "0.52.5"

Diff for: library/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ members = [
88
exclude = [
99
# stdarch has its own Cargo workspace
1010
"stdarch",
11+
"windows_targets"
1112
]
1213

1314
[profile.release.package.compiler_builtins]

Diff for: library/std/Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ object = { version = "0.36.0", default-features = false, optional = true, featur
5757
'archive',
5858
] }
5959

60+
[target.'cfg(windows)'.dependencies.windows-targets]
61+
path = "../windows_targets"
62+
6063
[dev-dependencies]
6164
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }
6265
rand_xorshift = "0.3.0"
@@ -116,7 +119,7 @@ std_detect_env_override = ["std_detect/std_detect_env_override"]
116119

117120
# Enable using raw-dylib for Windows imports.
118121
# This will eventually be the default.
119-
windows_raw_dylib = []
122+
windows_raw_dylib = ["windows-targets/windows_raw_dylib"]
120123

121124
[package.metadata.fortanix-sgx]
122125
# Maximum possible number of threads when testing

Diff for: library/std/src/sys/pal/windows/alloc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::alloc::{GlobalAlloc, Layout, System};
44
use crate::ffi::c_void;
55
use crate::ptr;
66
use crate::sync::atomic::{AtomicPtr, Ordering};
7-
use crate::sys::c::{self, windows_targets};
7+
use crate::sys::c;
88
use crate::sys::common::alloc::{realloc_fallback, MIN_ALIGN};
99

1010
#[cfg(test)]

Diff for: library/std/src/sys/pal/windows/c.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
use core::ffi::{c_uint, c_ulong, c_ushort, c_void, CStr};
99
use core::{mem, ptr};
1010

11-
pub(super) mod windows_targets;
12-
1311
mod windows_sys;
1412
pub use windows_sys::*;
1513

Diff for: library/std/src/sys/pal/windows/c/windows_sys.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3317,4 +3317,3 @@ pub struct WSADATA {
33173317
#[cfg(target_arch = "arm")]
33183318
pub enum CONTEXT {}
33193319
// ignore-tidy-filelength
3320-
use super::windows_targets;

Diff for: library/windows_targets/Cargo.toml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "windows-targets"
3+
description = "A drop-in replacement for the real windows-targets crate for use in std only."
4+
version = "0.0.0"
5+
edition = "2021"
6+
7+
[features]
8+
# Enable using raw-dylib for Windows imports.
9+
# This will eventually be the default.
10+
windows_raw_dylib = []

Diff for: library/std/src/sys/pal/windows/c/windows_targets.rs renamed to library/windows_targets/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
//!
33
//! This is a simple wrapper around an `extern` block with a `#[link]` attribute.
44
//! It's very roughly equivalent to the windows-targets crate.
5+
#![no_std]
6+
#![no_core]
7+
#![feature(decl_macro)]
8+
#![feature(no_core)]
59

610
#[cfg(feature = "windows_raw_dylib")]
711
pub macro link {

Diff for: src/tools/compiletest/src/runtest.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -3027,11 +3027,17 @@ impl<'test> TestCx<'test> {
30273027
const PREFIX: &str = "MONO_ITEM ";
30283028
const CGU_MARKER: &str = "@@";
30293029

3030+
// Some MonoItems can contain {closure@/path/to/checkout/tests/codgen-units/test.rs}
3031+
// To prevent the current dir from leaking, we just replace the entire path to the test
3032+
// file with TEST_PATH.
30303033
let actual: Vec<MonoItem> = proc_res
30313034
.stdout
30323035
.lines()
30333036
.filter(|line| line.starts_with(PREFIX))
3034-
.map(|line| str_to_mono_item(line, true))
3037+
.map(|line| {
3038+
line.replace(&self.testpaths.file.display().to_string(), "TEST_PATH").to_string()
3039+
})
3040+
.map(|line| str_to_mono_item(&line, true))
30353041
.collect();
30363042

30373043
let expected: Vec<MonoItem> = errors::load_errors(&self.testpaths.file, None)

Diff for: src/tools/generate-windows-sys/src/main.rs

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ fn main() -> Result<(), Box<dyn Error>> {
3535
let mut f = std::fs::File::options().append(true).open("windows_sys.rs")?;
3636
f.write_all(ARM32_SHIM.as_bytes())?;
3737
writeln!(&mut f, "// ignore-tidy-filelength")?;
38-
writeln!(&mut f, "use super::windows_targets;")?;
3938

4039
Ok(())
4140
}

Diff for: src/tools/tidy/src/pal.rs

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use crate::walk::{filter_dirs, walk};
3636

3737
// Paths that may contain platform-specific code.
3838
const EXCEPTION_PATHS: &[&str] = &[
39+
"library/windows_targets",
3940
"library/panic_abort",
4041
"library/panic_unwind",
4142
"library/unwind",

Diff for: tests/assembly/powerpc64-struct-abi.rs

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
//@ revisions: elfv1-be elfv2-be elfv2-le
2+
//@ assembly-output: emit-asm
3+
//@[elfv1-be] compile-flags: --target powerpc64-unknown-linux-gnu
4+
//@[elfv1-be] needs-llvm-components: powerpc
5+
//@[elfv2-be] compile-flags: --target powerpc64-unknown-linux-musl
6+
//@[elfv2-be] needs-llvm-components: powerpc
7+
//@[elfv2-le] compile-flags: --target powerpc64le-unknown-linux-gnu
8+
//@[elfv2-le] needs-llvm-components: powerpc
9+
//@[elfv1-be] filecheck-flags: --check-prefix be
10+
//@[elfv2-be] filecheck-flags: --check-prefix be
11+
12+
#![feature(no_core, lang_items)]
13+
#![no_std]
14+
#![no_core]
15+
#![crate_type = "lib"]
16+
17+
#[lang = "sized"]
18+
trait Sized {}
19+
20+
#[lang = "copy"]
21+
trait Copy {}
22+
23+
#[lang = "freeze"]
24+
trait Freeze {}
25+
26+
#[lang = "unpin"]
27+
trait Unpin {}
28+
29+
impl Copy for u8 {}
30+
impl Copy for u16 {}
31+
impl Copy for u32 {}
32+
impl Copy for FiveU32s {}
33+
impl Copy for FiveU16s {}
34+
impl Copy for ThreeU8s {}
35+
36+
#[repr(C)]
37+
struct FiveU32s(u32, u32, u32, u32, u32);
38+
39+
#[repr(C)]
40+
struct FiveU16s(u16, u16, u16, u16, u16);
41+
42+
#[repr(C)]
43+
struct ThreeU8s(u8, u8, u8);
44+
45+
// CHECK-LABEL: read_large
46+
// be: lwz [[REG1:.*]], 16(4)
47+
// be-NEXT: stw [[REG1]], 16(3)
48+
// be-NEXT: ld [[REG2:.*]], 8(4)
49+
// be-NEXT: ld [[REG3:.*]], 0(4)
50+
// be-NEXT: std [[REG2]], 8(3)
51+
// be-NEXT: std [[REG3]], 0(3)
52+
// elfv2-le: lxvd2x [[REG1:.*]], 0, 4
53+
// elfv2-le-NEXT: lwz [[REG2:.*]], 16(4)
54+
// elfv2-le-NEXT: stw [[REG2]], 16(3)
55+
// elfv2-le-NEXT: stxvd2x [[REG1]], 0, 3
56+
// CHECK-NEXT: blr
57+
#[no_mangle]
58+
extern "C" fn read_large(x: &FiveU32s) -> FiveU32s {
59+
*x
60+
}
61+
62+
// CHECK-LABEL: read_medium
63+
// elfv1-be: lhz [[REG1:.*]], 8(4)
64+
// elfv1-be-NEXT: ld [[REG2:.*]], 0(4)
65+
// elfv1-be-NEXT: sth [[REG1]], 8(3)
66+
// elfv1-be-NEXT: std [[REG2]], 0(3)
67+
// elfv2-be: lhz [[REG1:.*]], 8(3)
68+
// elfv2-be-NEXT: ld 3, 0(3)
69+
// elfv2-be-NEXT: sldi 4, [[REG1]], 48
70+
// elfv2-le: ld [[REG1:.*]], 0(3)
71+
// elfv2-le-NEXT: lhz 4, 8(3)
72+
// elfv2-le-NEXT: mr 3, [[REG1]]
73+
// CHECK-NEXT: blr
74+
#[no_mangle]
75+
extern "C" fn read_medium(x: &FiveU16s) -> FiveU16s {
76+
*x
77+
}
78+
79+
// CHECK-LABEL: read_small
80+
// elfv1-be: lbz [[REG1:.*]], 2(4)
81+
// elfv1-be-NEXT: lhz [[REG2:.*]], 0(4)
82+
// elfv1-be-NEXT: stb [[REG1]], 2(3)
83+
// elfv1-be-NEXT: sth [[REG2]], 0(3)
84+
// elfv2-be: lhz [[REG1:.*]], 0(3)
85+
// elfv2-be-NEXT: lbz 3, 2(3)
86+
// elfv2-be-NEXT: rldimi 3, [[REG1]], 8, 0
87+
// elfv2-le: lbz [[REG1:.*]], 2(3)
88+
// elfv2-le-NEXT: lhz 3, 0(3)
89+
// elfv2-le-NEXT: rldimi 3, [[REG1]], 16, 0
90+
// CHECK-NEXT: blr
91+
#[no_mangle]
92+
extern "C" fn read_small(x: &ThreeU8s) -> ThreeU8s {
93+
*x
94+
}
95+
96+
// CHECK-LABEL: write_large
97+
// CHECK: std 3, 0(6)
98+
// be-NEXT: rldicl [[REG1:.*]], 5, 32, 32
99+
// CHECK-NEXT: std 4, 8(6)
100+
// be-NEXT: stw [[REG1]], 16(6)
101+
// elfv2-le-NEXT: stw 5, 16(6)
102+
// CHECK-NEXT: blr
103+
#[no_mangle]
104+
extern "C" fn write_large(x: FiveU32s, dest: &mut FiveU32s) {
105+
*dest = x;
106+
}
107+
108+
// CHECK-LABEL: write_medium
109+
// CHECK: std 3, 0(5)
110+
// be-NEXT: rldicl [[REG1:.*]], 4, 16, 48
111+
// be-NEXT: sth [[REG1]], 8(5)
112+
// elfv2-le-NEXT: sth 4, 8(5)
113+
// CHECK-NEXT: blr
114+
#[no_mangle]
115+
extern "C" fn write_medium(x: FiveU16s, dest: &mut FiveU16s) {
116+
*dest = x;
117+
}
118+
119+
// CHECK-LABEL: write_small
120+
// be: stb 3, 2(4)
121+
// be-NEXT: srwi [[REG1:.*]], 3, 8
122+
// be-NEXT: sth [[REG1]], 0(4)
123+
// The order these instructions are emitted in changed in LLVM 18.
124+
// elfv2-le-DAG: sth 3, 0(4)
125+
// elfv2-le-DAG: srwi [[REG1:.*]], 3, 16
126+
// elfv2-le-NEXT: stb [[REG1]], 2(4)
127+
// CHECK-NEXT: blr
128+
#[no_mangle]
129+
extern "C" fn write_small(x: ThreeU8s, dest: &mut ThreeU8s) {
130+
*dest = x;
131+
}

Diff for: tests/codegen-units/item-collection/auxiliary/cgu_extern_closures.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ compile-flags: -Zinline-mir=no
2+
13
#![crate_type = "lib"]
24

35
#[inline]

0 commit comments

Comments
 (0)