Skip to content

Commit 8707132

Browse files
committed
Auto merge of #128968 - jieyouxu:rollup-l23j21x, r=jieyouxu
Rollup of 5 pull requests Successful merges: - #128643 (Refactor `powerpc64` call ABI handling) - #128873 (Add windows-targets crate to std's sysroot) - #128916 (Tidy up `dump-ice-to-disk` and make assertion failures dump ICE messages) - #128929 (Fix codegen-units tests that were disabled 8 years ago) - #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

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

Lines changed: 12 additions & 55 deletions
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
}

library/Cargo.lock

Lines changed: 6 additions & 1 deletion
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"

library/Cargo.toml

Lines changed: 1 addition & 0 deletions
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]

library/std/Cargo.toml

Lines changed: 4 additions & 1 deletion
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

library/std/src/sys/pal/windows/alloc.rs

Lines changed: 1 addition & 1 deletion
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)]

library/std/src/sys/pal/windows/c.rs

Lines changed: 0 additions & 2 deletions
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

library/std/src/sys/pal/windows/c/windows_sys.rs

Lines changed: 0 additions & 1 deletion
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;

library/windows_targets/Cargo.toml

Lines changed: 10 additions & 0 deletions
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 = []

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

Lines changed: 4 additions & 0 deletions
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 {

src/tools/compiletest/src/runtest.rs

Lines changed: 7 additions & 1 deletion
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)

0 commit comments

Comments
 (0)