about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa
AgeCommit message (Collapse)AuthorLines
2025-06-08Rollup merge of #142053 - heiher:loong32-none, r=wesleywiserJubilee-2/+3
Add new Tier-3 targets: `loongarch32-unknown-none*` MCP: https://github.com/rust-lang/compiler-team/issues/865 NOTE: LoongArch32 ELF object support is available starting with object v0.37.0.
2025-06-08Remove rustc's notion of "preferred" alignment AKA `__alignof`Jubilee Young-5/+1
In PR 90877 T-lang decided not to remove `intrinsics::pref_align_of`. However, the intrinsic and its supporting code 1. is a nightly feature, so can be removed at compiler/libs discretion 2. requires considerable effort in the compiler to support, as it necessarily complicates every single site reasoning about alignment 3. has been justified based on relevance to codegen, but it is only a requirement for C++ (not C, not Rust) stack frame layout for AIX, in ways Rust would not consider even with increased C++ interop 4. is only used by rustc to overalign some globals, not correctness 5. can be adequately replaced by other rules for globals, as it mostly affects alignments for a few types under 16 bytes of alignment 6. has only one clear benefactor: automating C -> Rust translation for GNU extensions like `__alignof` 7. such code was likely intended to be `alignof` or `_Alignof`, because the GNU extension is a "false friend" of the C keyword, which makes the choice to support such a mapping very questionable 8. makes it easy to do incorrect codegen in the compiler by its mere presence as usual Rust rules of alignment (e.g. `size == align * N`) do not hold with preferred alignment The implementation is clearly damaging the code quality of the compiler. Thus it is within the compiler team's purview to simply rip it out. If T-lang wishes to have this intrinsic restored for c2rust's benefit, it would have to use a radically different implementation that somehow does not cause internal incorrectness. Until then, remove the intrinsic and its supporting code, as one tool and an ill-considered GCC extension cannot justify risking correctness. Because we touch a fair amount of the compiler to change this at all, and unfortunately the duplication of AbiAndPrefAlign is deep-rooted, we keep an "AbiAlign" type which we can wean code off later.
2025-06-07intrinsics: use const generic to set atomic orderingRalf Jung-202/+144
2025-06-06Rollup merge of #142103 - scottmcm:fieldidx-in-interp, r=oli-obkGuillaume Gomez-2/+2
Update `InterpCx::project_field` to take `FieldIdx` As suggested by Ralf in https://github.com/rust-lang/rust/pull/142005#discussion_r2125839015
2025-06-06Auto merge of #142099 - matthiaskrgr:rollup-r9s3c35, r=matthiaskrgrbors-9/+17
Rollup of 11 pull requests Successful merges: - rust-lang/rust#125087 (Optimize `Seek::stream_len` impl for `File`) - rust-lang/rust#141982 (`tests/ui`: A New Order [5/N]) - rust-lang/rust#142012 (Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of None) - rust-lang/rust#142044 (compiler: Document the offset invariant of `OperandValue::Pair`) - rust-lang/rust#142047 (Ensure stack in two places that affect s390x) - rust-lang/rust#142058 (Clean `rustc_attr_parsing/src/lib.rs` documentation) - rust-lang/rust#142067 (canon_abi: make to_erased_extern_abi just a detail in formatting) - rust-lang/rust#142072 (doc: Fix inverted meaning in E0783.md) - rust-lang/rust#142084 (add myself to rotation) - rust-lang/rust#142091 (Fix AIX build) - rust-lang/rust#142092 (rustdoc: Support middle::ty associated const equality predicates again) Failed merges: - rust-lang/rust#142042 (Make E0621 missing lifetime suggestion verbose) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-05Update `InterpCx::project_field` to take `FieldIdx`Scott McMurray-2/+2
As suggested by Ralf in 142005.
2025-06-06Add new Tier-3 targets: `loongarch32-unknown-none*`WANG Rui-1/+2
MCP: https://github.com/rust-lang/compiler-team/issues/865
2025-06-06Rollup merge of #142044 - workingjubilee:document-operandvalue-pair, r=scottmcmMatthias Krüger-2/+8
compiler: Document the offset invariant of `OperandValue::Pair` A subtle invariant of `OperandValue::Pair` that came up during review and was found to be undocumented. Visible in code like this: https://github.com/rust-lang/rust/blob/4b27a04cc8ed4da10a546a871e23e665d03f7a79/compiler/rustc_codegen_ssa/src/mir/operand.rs#L376-L392
2025-06-05Auto merge of #140872 - bjorn3:elf_use_used_linker, r=nikicbors-31/+7
Make #[used(linker)] the default on ELF too `#[used]` currently is an alias for `#[used(linker)]` on all platforms except ELF based ones where it is an alias for `#[used(compiler)]`. The latter has surprising behavior and the LLVM LangRef explicitly states that it "should only be used in rare circumstances, and should not be exposed to source languages." [^2] The reason `#[used]` still was an alias to `#[used(compiler)]` on ELF is because the gold linker has issues with it. Luckily gold has been deprecated with GCC 15 [^1] and seems to be unable to bootstrap rustc anyway [^3]. As such we shouldn't really care about supporting gold. This would also allow re-enabling start-stop-gc with lld. cc https://github.com/rust-lang/rust/issues/93798 Likely fixes https://github.com/rust-lang/rust/issues/85045 [^1]: https://lists.gnu.org/archive/html/info-gnu/2025-02/msg00001.html [^2]: https://llvm.org/docs/LangRef.html#the-llvm-compiler-used-global-variable [^3]: https://github.com/rust-lang/rust/issues/139425
2025-06-05Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of NoneOli Scherer-7/+9
2025-06-05Make #[used(linker)] the default on ELF toobjorn3-31/+7
#[used] currently is an alias for #[used(linker)] on all platforms except ELF based ones where it is an alias for #[used(compiler)]. The latter has surprising behavior and the LLVM LangRef explicitly states that it "should only be used in rare circumstances, and should not be exposed to source languages." The reason #[used] still was an alias to #[used(compiler)] on ELF is because the gold linker has issues with it. Luckily gold has been deprecated with GCC 15 and seems to be unable to bootstrap rustc anyway. As such we shouldn't really care about supporting gold.
2025-06-05Bump objectWANG Rui-1/+1
2025-06-04compiler: Document the offset invariant of `OperandValue::Pair`Jubilee Young-2/+8
2025-06-03Change `tag_field` to `FieldIdx` in `Variants::Multiple`Scott McMurray-4/+4
It was already available as a generic parameter anyway, and it's not like we'll ever put a tag in the 5-billionth field.
2025-06-03Rollup merge of #141569 - workingjubilee:canonicalize-abi, r=bjorn3Matthias Krüger-10/+10
Replace ad-hoc ABI "adjustments" with an `AbiMap` to `CanonAbi` Our `conv_from_spec_abi`, `adjust_abi`, and `is_abi_supported` combine to give us a very confusing way of reasoning about what _actual_ calling convention we want to lower our code to and whether we want to compile the resulting code at all. Instead of leaving this code as a miniature adventure game in which someone tries to combine stateful mutations into a Rube Goldberg machine that will let them escape the maze and arrive at the promised land of codegen, we let `AbiMap` devour this complexity. Once you have an `AbiMap`, you can answer which `ExternAbi`s will lower to what `CanonAbi`s (and whether they will lower at all). Removed: - `conv_from_spec_abi` replaced by `AbiMap::canonize_abi` - `adjust_abi` replaced by same - `Conv::PreserveAll` as unused - `Conv::Cold` as unused - `enum Conv` replaced by `enum CanonAbi` target-spec.json changes: - If you have a target-spec.json then now your "entry-abi" key will be specified in terms of one of the `"{abi}"` strings Rust recognizes, e.g. ```json "entry-abi": "C", "entry-abi": "win64", "entry-abi": "aapcs", ```
2025-06-03compiler: change Conv to CanonAbiJubilee Young-10/+10
2025-06-03Move metadata object generation for dylibs to the linker codebjorn3-95/+51
This deduplicates some code between codegen backends and may in the future allow adding extra metadata that is only known at link time.
2025-06-03Only borrow EncodedMetadata in codegen_cratebjorn3-28/+35
And move passing it to the linker to the driver code.
2025-06-03Remove type_test from IntrinsicCallBuilderMethodsbjorn3-2/+0
It is only used within cg_llvm.
2025-06-03Remove get_dbg_loc from DebugInfoBuilderMethodsbjorn3-1/+0
It is only used within cg_llvm.
2025-06-02Auto merge of #141750 - Noratrieb:gold-rush, r=bjorn3bors-1/+58
Warn when gold was used as the linker gold has been deprecated recently and is known to behave incorrectly around Rust programs, including miscompiling `#[used(linker)]`. Tell people to switch to a different linker instead. closes rust-lang/rust#141748 r? bjorn3
2025-06-02Auto merge of #141760 - bjorn3:intrinsic_rework_part2, r=fee1-deadbors-29/+23
Improve intrinsic handling in cg_ssa (part 2) * Avoid computing function type and signature for intrinsics where possible * Nicer handling of bool returning intrinsics Follow up to https://github.com/rust-lang/rust/pull/141404
2025-05-31Warn when gold was used as the linkerNoratrieb-1/+58
gold has been deprecated recently and is known to behave incorrectly around Rust programs, including miscompiling `#[used(linker)]`. Tell people to switch to a different linker instead. Co-Authored-By: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2025-05-30Rollup merge of #141749 - ↵Matthias Krüger-52/+2
Noratrieb:RUSTC_ACTUALLY_DO_NOT_RETRY_LINKER_ON_SEGFAULT, r=petrochenkov Remove RUSTC_RETRY_LINKER_ON_SEGFAULT hack It looks like this was added in rust-lang/rust#40422 6 years ago because of issues with the MacOS linker. MacOS got a new linker in the meantime, so that should probably be resolved now. Hopefully. r? petrochenkov
2025-05-30Directly use from_immediate for handling boolbjorn3-3/+2
2025-05-30Avoid computing function type for intrinsic instancesbjorn3-8/+8
2025-05-30Use layout field of OperandRef and PlaceRef in codegen_intrinsic_callbjorn3-18/+13
This avoids having to get the function signature.
2025-05-30Rollup merge of #141507 - RalfJung:atomic-intrinsics, r=bjorn3Matthias Krüger-50/+56
atomic_load intrinsic: use const generic parameter for ordering We have a gazillion intrinsics for the atomics because we encode the ordering into the intrinsic name rather than making it a parameter. This is particularly bad for those operations that take two orderings. Let's fix that! This PR only converts `load`, to see if there's any feedback that would fundamentally change the strategy we pursue for the const generic intrinsics. The first two commits are preparation and could be a separate PR if you prefer. `@BoxyUwU` -- I hope this is a use of const generics that is unlikely to explode? All we need is a const generic of enum type. We could funnel it through an integer if we had to but an enum is obviously nicer... `@bjorn3` it seems like the cranelift backend entirely ignores the ordering?
2025-05-29Remove RUSTC_RETRY_LINKER_ON_SEGFAULT hackNoratrieb-52/+2
It looks like this was added 6 years ago because of issues with the MacOS linker. MacOS got a new linker in the meantime, so that should probably be resolved now. Hopefully.
2025-05-29Rollup merge of #141448 - bjorn3:codegen_refactors, r=WaffleLapkinGuillaume Gomez-83/+44
A variety of improvements to the codegen backends Some are just general improvements to cg_ssa or cg_llvm, while others will make it slightly easier to use cg_ssa in cg_clif in the future.
2025-05-29Rollup merge of #138139 - xizheyin:issue-137384, r=ChrisDentonJacob Pratt-0/+19
Emit warning while outputs is not exe and prints linkage info cc #137384 ```bash $ rustc +stage1 /dev/null --print native-static-libs --crate-type staticlib --emit metadata warning: skipping link step due to conflict: cannot output linkage information without emitting executable note: consider emitting executable to print link information warning: 1 warning emitted ```
2025-05-28get rid of rustc_codegen_ssa::common::AtomicOrderingRalf Jung-26/+7
2025-05-28atomic_load intrinsic: use const generic parameter for orderingRalf Jung-34/+59
2025-05-28Remove unused arg_memory_ty methodbjorn3-1/+0
2025-05-28Mark all optimize methods and the codegen method as safebjorn3-22/+13
There is no safety contract and I don't think any of them can actually cause UB in more ways than passing malicious source code to rustc can. While LtoModuleCodegen::optimize says that the returned ModuleCodegen points into the LTO module, the LTO module has already been dropped by the time this function returns, so if the returned ModuleCodegen indeed points into the LTO module, we would have seen crashes on every LTO compilation, which we don't. As such the comment is outdated.
2025-05-28Remove methods from StaticCodegenMethods that are not called in cg_ssa itselfbjorn3-12/+0
2025-05-28Make predefine methods take &mut selfbjorn3-4/+4
2025-05-28Move supports_parallel from CodegenBackend to ExtraBackendMethodsbjorn3-8/+8
It is only relevant when using cg_ssa for driving compilation.
2025-05-28Remove a couple of uses of interior mutability around staticsbjorn3-3/+3
2025-05-28Reduce amount of types that need to be PartialEqbjorn3-3/+3
2025-05-28The personality function is a Function, not a Valuebjorn3-4/+4
2025-05-28Remove codegen_unit from MiscCodegenMethodsbjorn3-28/+11
2025-05-28Rollup merge of #141404 - bjorn3:refactor_cg_ssa_call_codegen, r=davidtwcoTrevor Gross-185/+185
Improve intrinsic handling in cg_ssa * Move all intrinsic handling code to the start of `codegen_call_terminator`. * Push some intrinsic handling code into `codegen_intrinsic_call`. * Don't depend on FnAbi for intrinsics.
2025-05-27Rename unpack to kindMichael Goulet-1/+1
2025-05-26Reduce indentation in codegen_panic_intrinsicbjorn3-49/+47
2025-05-26Don't depend on FnAbi for intrinsicsbjorn3-32/+42
Intrinsics are not real functions and as such don't have any calling convention. Trying to compute a calling convention for an intrinsic anyway is a nonsensical operation.
2025-05-26Remove usage of FnAbi in codegen_intrinsic_callbjorn3-22/+10
2025-05-26Pass PlaceRef rather than Bx::Value to codegen_intrinsic_callbjorn3-5/+7
2025-05-26Move caller_location handling into codegen_intrinsic_callbjorn3-18/+20
2025-05-26Always use fn_span in codegen_call_terminatorbjorn3-15/+11