Skip to content

Commit 57a8a7e

Browse files
committed
Auto merge of rust-lang#132736 - matthiaskrgr:rollup-66naqwb, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - rust-lang#132638 (Remove fixme comment about clobber_abi on PowerPC) - rust-lang#132726 (Remove unused intercrate dependencies) - rust-lang#132729 (Make fn_abi_sanity_check a bit stricter) - rust-lang#132734 ( remove 'platform-intrinsic' ABI leftovers) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9a77c3c + fd41a37 commit 57a8a7e

File tree

17 files changed

+72
-61
lines changed

17 files changed

+72
-61
lines changed

Cargo.lock

-12
Original file line numberDiff line numberDiff line change
@@ -3274,7 +3274,6 @@ name = "rustc_ast_lowering"
32743274
version = "0.0.0"
32753275
dependencies = [
32763276
"rustc_ast",
3277-
"rustc_ast_pretty",
32783277
"rustc_data_structures",
32793278
"rustc_errors",
32803279
"rustc_fluent_macro",
@@ -3469,7 +3468,6 @@ dependencies = [
34693468
"rustc_macros",
34703469
"rustc_metadata",
34713470
"rustc_middle",
3472-
"rustc_monomorphize",
34733471
"rustc_query_system",
34743472
"rustc_serialize",
34753473
"rustc_session",
@@ -3745,7 +3743,6 @@ dependencies = [
37453743
"rustc_feature",
37463744
"rustc_fluent_macro",
37473745
"rustc_hir",
3748-
"rustc_hir_pretty",
37493746
"rustc_index",
37503747
"rustc_infer",
37513748
"rustc_lint_defs",
@@ -3793,7 +3790,6 @@ dependencies = [
37933790
"rustc_middle",
37943791
"rustc_session",
37953792
"rustc_span",
3796-
"rustc_target",
37973793
"rustc_trait_selection",
37983794
"rustc_type_ir",
37993795
"smallvec",
@@ -3853,9 +3849,7 @@ dependencies = [
38533849
"rustc_index",
38543850
"rustc_macros",
38553851
"rustc_middle",
3856-
"rustc_next_trait_solver",
38573852
"rustc_span",
3858-
"rustc_target",
38593853
"rustc_type_ir",
38603854
"smallvec",
38613855
"thin-vec",
@@ -3934,7 +3928,6 @@ dependencies = [
39343928
"rustc_feature",
39353929
"rustc_fluent_macro",
39363930
"rustc_hir",
3937-
"rustc_hir_pretty",
39383931
"rustc_index",
39393932
"rustc_infer",
39403933
"rustc_macros",
@@ -4162,7 +4155,6 @@ dependencies = [
41624155
name = "rustc_next_trait_solver"
41634156
version = "0.0.0"
41644157
dependencies = [
4165-
"bitflags 2.6.0",
41664158
"derive-where",
41674159
"rustc_ast_ir",
41684160
"rustc_data_structures",
@@ -4458,9 +4450,7 @@ dependencies = [
44584450
"object 0.36.4",
44594451
"rustc_abi",
44604452
"rustc_data_structures",
4461-
"rustc_feature",
44624453
"rustc_fs_util",
4463-
"rustc_index",
44644454
"rustc_macros",
44654455
"rustc_serialize",
44664456
"rustc_span",
@@ -4492,8 +4482,6 @@ dependencies = [
44924482
"rustc_middle",
44934483
"rustc_next_trait_solver",
44944484
"rustc_parse_format",
4495-
"rustc_query_system",
4496-
"rustc_serialize",
44974485
"rustc_session",
44984486
"rustc_span",
44994487
"rustc_transmute",

compiler/rustc/src/main.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// We need this feature as it changes `dylib` linking behavior and allows us to link to `rustc_driver`.
22
#![feature(rustc_private)]
3+
// Several crates are depended upon but unused so that they are present in the sysroot
4+
#![expect(unused_crate_dependencies)]
35

46
// A note about jemalloc: rustc uses jemalloc when built for CI and
57
// distribution. The obvious way to do this is with the `#[global_allocator]`

compiler/rustc_ast_lowering/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ doctest = false
99
[dependencies]
1010
# tidy-alphabetical-start
1111
rustc_ast = { path = "../rustc_ast" }
12-
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
1312
rustc_data_structures = { path = "../rustc_data_structures" }
1413
rustc_errors = { path = "../rustc_errors" }
1514
rustc_fluent_macro = { path = "../rustc_fluent_macro" }

compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Codegen of intrinsics. This includes `extern "rust-intrinsic"`, `extern "platform-intrinsic"`
1+
//! Codegen of intrinsics. This includes `extern "rust-intrinsic"`,
22
//! and LLVM intrinsics that have symbol names starting with `llvm.`.
33
44
macro_rules! intrinsic_args {

compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Codegen `extern "platform-intrinsic"` intrinsics.
1+
//! Codegen SIMD intrinsics.
22
33
use cranelift_codegen::ir::immediates::Offset32;
44
use rustc_target::abi::Endian;

compiler/rustc_codegen_ssa/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ rustc_index = { path = "../rustc_index" }
2828
rustc_macros = { path = "../rustc_macros" }
2929
rustc_metadata = { path = "../rustc_metadata" }
3030
rustc_middle = { path = "../rustc_middle" }
31-
rustc_monomorphize = { path = "../rustc_monomorphize" }
3231
rustc_query_system = { path = "../rustc_query_system" }
3332
rustc_serialize = { path = "../rustc_serialize" }
3433
rustc_session = { path = "../rustc_session" }

compiler/rustc_hir_analysis/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ rustc_errors = { path = "../rustc_errors" }
1919
rustc_feature = { path = "../rustc_feature" }
2020
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
2121
rustc_hir = { path = "../rustc_hir" }
22-
rustc_hir_pretty = { path = "../rustc_hir_pretty" }
2322
rustc_index = { path = "../rustc_index" }
2423
rustc_infer = { path = "../rustc_infer" }
2524
rustc_lint_defs = { path = "../rustc_lint_defs" }

compiler/rustc_hir_analysis/src/check/intrinsic.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//! Type-checking for the rust-intrinsic and platform-intrinsic
2-
//! intrinsics that the compiler exposes.
1+
//! Type-checking for the rust-intrinsic intrinsics that the compiler exposes.
32
43
use rustc_abi::ExternAbi;
54
use rustc_errors::codes::*;

compiler/rustc_hir_typeck/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ rustc_macros = { path = "../rustc_macros" }
2323
rustc_middle = { path = "../rustc_middle" }
2424
rustc_session = { path = "../rustc_session" }
2525
rustc_span = { path = "../rustc_span" }
26-
rustc_target = { path = "../rustc_target" }
2726
rustc_trait_selection = { path = "../rustc_trait_selection" }
2827
rustc_type_ir = { path = "../rustc_type_ir" }
2928
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }

compiler/rustc_infer/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ rustc_hir = { path = "../rustc_hir" }
1616
rustc_index = { path = "../rustc_index" }
1717
rustc_macros = { path = "../rustc_macros" }
1818
rustc_middle = { path = "../rustc_middle" }
19-
rustc_next_trait_solver = { path = "../rustc_next_trait_solver" }
2019
rustc_span = { path = "../rustc_span" }
21-
rustc_target = { path = "../rustc_target" }
2220
rustc_type_ir = { path = "../rustc_type_ir" }
2321
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
2422
thin-vec = "0.2.12"

compiler/rustc_lint/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ rustc_errors = { path = "../rustc_errors" }
1414
rustc_feature = { path = "../rustc_feature" }
1515
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
1616
rustc_hir = { path = "../rustc_hir" }
17-
rustc_hir_pretty = { path = "../rustc_hir_pretty" }
1817
rustc_index = { path = "../rustc_index" }
1918
rustc_infer = { path = "../rustc_infer" }
2019
rustc_macros = { path = "../rustc_macros" }

compiler/rustc_middle/src/ty/instance.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub enum InstanceKind<'tcx> {
7171
/// - coroutines
7272
Item(DefId),
7373

74-
/// An intrinsic `fn` item (with `"rust-intrinsic"` or `"platform-intrinsic"` ABI).
74+
/// An intrinsic `fn` item (with `"rust-intrinsic"` ABI).
7575
///
7676
/// Alongside `Virtual`, this is the only `InstanceKind` that does not have its own callable MIR.
7777
/// Instead, codegen and const eval "magically" evaluate calls to intrinsics purely in the

compiler/rustc_next_trait_solver/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ edition = "2021"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
bitflags = "2.4.1"
98
derive-where = "1.2.7"
109
rustc_ast_ir = { path = "../rustc_ast_ir", default-features = false }
1110
rustc_data_structures = { path = "../rustc_data_structures", optional = true }

compiler/rustc_target/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ edition = "2021"
88
bitflags = "2.4.1"
99
rustc_abi = { path = "../rustc_abi" }
1010
rustc_data_structures = { path = "../rustc_data_structures" }
11-
rustc_feature = { path = "../rustc_feature" }
1211
rustc_fs_util = { path = "../rustc_fs_util" }
13-
rustc_index = { path = "../rustc_index" }
1412
rustc_macros = { path = "../rustc_macros" }
1513
rustc_serialize = { path = "../rustc_serialize" }
1614
rustc_span = { path = "../rustc_span" }

compiler/rustc_target/src/asm/mod.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,21 @@ impl InlineAsmClobberAbi {
11281128
},
11291129
InlineAsmClobberAbi::PowerPC => clobbered_regs! {
11301130
PowerPC PowerPCInlineAsmReg {
1131+
// Refs:
1132+
// - PPC32 SysV: "3.2. Function Calling Sequence" in Power Architecture® 32-bit Application Binary Interface Supplement 1.0 - Linux® & Embedded
1133+
// https://web.archive.org/web/20120608163804/https://www.power.org/resources/downloads/Power-Arch-32-bit-ABI-supp-1.0-Unified.pdf
1134+
// - PPC64 ELFv1: "3.2. Function Calling Sequence" in 64-bit PowerPC ELF Application Binary Interface Supplement 1.9
1135+
// https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#FUNC-CALL
1136+
// - PPC64 ELFv2: "2.2 Function Calling Sequence" in 64-Bit ELF V2 ABI Specification: Power Architecture, Revision 1.5
1137+
// https://openpowerfoundation.org/specifications/64bitelfabi/
1138+
// - AIX:
1139+
// - Register usage and conventions
1140+
// https://www.ibm.com/docs/en/aix/7.3?topic=overview-register-usage-conventions
1141+
// - Special registers in the PowerPC®
1142+
// https://www.ibm.com/docs/en/aix/7.3?topic=overview-special-registers-in-powerpc
1143+
// - AIX vector programming
1144+
// https://www.ibm.com/docs/en/aix/7.3?topic=concepts-aix-vector-programming
1145+
11311146
// r0, r3-r12
11321147
r0,
11331148
r3, r4, r5, r6, r7,
@@ -1138,8 +1153,6 @@ impl InlineAsmClobberAbi {
11381153
f8, f9, f10, f11, f12, f13,
11391154

11401155
// v0-v19
1141-
// FIXME: PPC32 SysV ABI does not mention vector registers processing.
1142-
// https://refspecs.linuxfoundation.org/elf/elfspec_ppc.pdf
11431156
v0, v1, v2, v3, v4, v5, v6, v7,
11441157
v8, v9, v10, v11, v12, v13, v14,
11451158
v15, v16, v17, v18, v19,

compiler/rustc_trait_selection/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ rustc_macros = { path = "../rustc_macros" }
1919
rustc_middle = { path = "../rustc_middle" }
2020
rustc_next_trait_solver = { path = "../rustc_next_trait_solver" }
2121
rustc_parse_format = { path = "../rustc_parse_format" }
22-
rustc_query_system = { path = "../rustc_query_system" }
23-
rustc_serialize = { path = "../rustc_serialize" }
2422
rustc_session = { path = "../rustc_session" }
2523
rustc_span = { path = "../rustc_span" }
2624
rustc_transmute = { path = "../rustc_transmute", features = ["rustc"] }

compiler/rustc_ty_utils/src/abi.rs

+51-30
Original file line numberDiff line numberDiff line change
@@ -463,43 +463,64 @@ fn fn_abi_sanity_check<'tcx>(
463463
arg: &ArgAbi<'tcx, Ty<'tcx>>,
464464
) {
465465
let tcx = cx.tcx();
466+
467+
if spec_abi == ExternAbi::Rust
468+
|| spec_abi == ExternAbi::RustCall
469+
|| spec_abi == ExternAbi::RustCold
470+
{
471+
if arg.layout.is_zst() {
472+
// Casting closures to function pointers depends on ZST closure types being
473+
// omitted entirely in the calling convention.
474+
assert!(arg.is_ignore());
475+
}
476+
if let PassMode::Indirect { on_stack, .. } = arg.mode {
477+
assert!(!on_stack, "rust abi shouldn't use on_stack");
478+
}
479+
}
480+
466481
match &arg.mode {
467-
PassMode::Ignore => {}
482+
PassMode::Ignore => {
483+
assert!(arg.layout.is_zst() || arg.layout.is_uninhabited());
484+
}
468485
PassMode::Direct(_) => {
469486
// Here the Rust type is used to determine the actual ABI, so we have to be very
470-
// careful. Scalar/ScalarPair is fine, since backends will generally use
471-
// `layout.abi` and ignore everything else. We should just reject `Aggregate`
472-
// entirely here, but some targets need to be fixed first.
473-
if matches!(arg.layout.backend_repr, BackendRepr::Memory { .. }) {
474-
// For an unsized type we'd only pass the sized prefix, so there is no universe
475-
// in which we ever want to allow this.
476-
assert!(
477-
arg.layout.is_sized(),
478-
"`PassMode::Direct` for unsized type in ABI: {:#?}",
479-
fn_abi
480-
);
481-
// This really shouldn't happen even for sized aggregates, since
482-
// `immediate_llvm_type` will use `layout.fields` to turn this Rust type into an
483-
// LLVM type. This means all sorts of Rust type details leak into the ABI.
484-
// However wasm sadly *does* currently use this mode so we have to allow it --
485-
// but we absolutely shouldn't let any more targets do that.
486-
// (Also see <https://github.com/rust-lang/rust/issues/115666>.)
487-
//
488-
// The unstable abi `PtxKernel` also uses Direct for now.
489-
// It needs to switch to something else before stabilization can happen.
490-
// (See issue: https://github.com/rust-lang/rust/issues/117271)
491-
assert!(
492-
matches!(&*tcx.sess.target.arch, "wasm32" | "wasm64")
493-
|| matches!(spec_abi, ExternAbi::PtxKernel | ExternAbi::Unadjusted),
494-
"`PassMode::Direct` for aggregates only allowed for \"unadjusted\" and \"ptx-kernel\" functions and on wasm\n\
487+
// careful. Scalar/Vector is fine, since backends will generally use
488+
// `layout.backend_repr` and ignore everything else. We should just reject
489+
//`Aggregate` entirely here, but some targets need to be fixed first.
490+
match arg.layout.backend_repr {
491+
BackendRepr::Uninhabited
492+
| BackendRepr::Scalar(_)
493+
| BackendRepr::Vector { .. } => {}
494+
BackendRepr::ScalarPair(..) => {
495+
panic!("`PassMode::Direct` used for ScalarPair type {}", arg.layout.ty)
496+
}
497+
BackendRepr::Memory { sized } => {
498+
// For an unsized type we'd only pass the sized prefix, so there is no universe
499+
// in which we ever want to allow this.
500+
assert!(sized, "`PassMode::Direct` for unsized type in ABI: {:#?}", fn_abi);
501+
// This really shouldn't happen even for sized aggregates, since
502+
// `immediate_llvm_type` will use `layout.fields` to turn this Rust type into an
503+
// LLVM type. This means all sorts of Rust type details leak into the ABI.
504+
// However wasm sadly *does* currently use this mode so we have to allow it --
505+
// but we absolutely shouldn't let any more targets do that.
506+
// (Also see <https://github.com/rust-lang/rust/issues/115666>.)
507+
//
508+
// The unstable abi `PtxKernel` also uses Direct for now.
509+
// It needs to switch to something else before stabilization can happen.
510+
// (See issue: https://github.com/rust-lang/rust/issues/117271)
511+
assert!(
512+
matches!(&*tcx.sess.target.arch, "wasm32" | "wasm64")
513+
|| matches!(spec_abi, ExternAbi::PtxKernel | ExternAbi::Unadjusted),
514+
"`PassMode::Direct` for aggregates only allowed for \"unadjusted\" and \"ptx-kernel\" functions and on wasm\n\
495515
Problematic type: {:#?}",
496-
arg.layout,
497-
);
516+
arg.layout,
517+
);
518+
}
498519
}
499520
}
500521
PassMode::Pair(_, _) => {
501-
// Similar to `Direct`, we need to make sure that backends use `layout.abi` and
502-
// ignore the rest of the layout.
522+
// Similar to `Direct`, we need to make sure that backends use `layout.backend_repr`
523+
// and ignore the rest of the layout.
503524
assert!(
504525
matches!(arg.layout.backend_repr, BackendRepr::ScalarPair(..)),
505526
"PassMode::Pair for type {}",

0 commit comments

Comments
 (0)