summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/mir
AgeCommit message (Collapse)AuthorLines
2025-06-22centralize `-Zmin-function-alignment` logicFolkert de Vries-6/+2
2025-06-18Rollup merge of #142619 - klensy:or_fun_call, r=nnethercoteJakub Beránek-5/+5
apply clippy::or_fun_call Applies https://rust-lang.github.io/rust-clippy/master/index.html?groups=nursery#or_fun_call to reduce needless allocs.
2025-06-18Rollup merge of #142383 - scottmcm:operandref-builder, r=workingjubileeJakub Beránek-75/+115
CodeGen: rework Aggregate implemention for rvalue_creates_operand cases A non-trivial refactor pulled out from rust-lang/rust#138759 r? workingjubilee The previous implementation I'd written here based on `index_by_increasing_offset` is complicated to follow and difficult to extend to non-structs. This changes the implementation, without actually changing any codegen (thus no test changes either), to be more like the existing `extract_field` (<https://github.com/rust-lang/rust/blob/2b0274c71dba0e24370ebf65593da450e2e91868/compiler/rustc_codegen_ssa/src/mir/operand.rs#L345-L425>) in that it allows setting a particular field directly. Notably I've found this one much easier to get right, in particular because having the `OperandRef<Result<V, Scalar>>` gives a really useful thing to include in ICE messages if something did happen to go wrong.
2025-06-17CodeGen: rework Aggregate implemention for rvalue_creates_operand casesScott McMurray-75/+115
Another refactor pulled out from 138759 The previous implementation I'd written here based on `index_by_increasing_offset` is complicated to follow and difficult to extend to non-structs. This changes the implementation, without actually changing any codegen (thus no test changes either), to be more like the existing `extract_field` (<https://github.com/rust-lang/rust/blob/2b0274c71dba0e24370ebf65593da450e2e91868/compiler/rustc_codegen_ssa/src/mir/operand.rs#L345-L425>) in that it allows setting a particular field directly. Notably I've found this one much easier to get right, in particular because having the `OperandRef<Result<V, Scalar>>` gives a really useful thing to include in ICE messages if something did happen to go wrong.
2025-06-17apply clippy::or_fun_callklensy-5/+5
2025-06-16Fix RISC-V C function ABI when passing/returning structs containing floatsbeetrees-7/+50
2025-06-14Remove all support for wasm's legacy ABIbjorn3-38/+7
2025-06-12intrinsics: rename min_align_of to align_ofRalf Jung-1/+1
2025-06-10Remove unneeded `FunctionCx` from some codegen methodsScott McMurray-96/+94
No changes; just removing the `self` that wasn't needed.
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-178/+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-05Update `InterpCx::project_field` to take `FieldIdx`Scott McMurray-2/+2
As suggested by Ralf in 142005.
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-05Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of NoneOli Scherer-4/+5
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-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-28get rid of rustc_codegen_ssa::common::AtomicOrderingRalf Jung-13/+5
2025-05-28atomic_load intrinsic: use const generic parameter for orderingRalf Jung-34/+59
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-19/+9
2025-05-26Pass PlaceRef rather than Bx::Value to codegen_intrinsic_callbjorn3-4/+5
2025-05-26Move caller_location handling into codegen_intrinsic_callbjorn3-18/+20
2025-05-26Always use fn_span in codegen_call_terminatorbjorn3-15/+11
2025-05-26Move some code around in codegen_call_terminatorbjorn3-99/+103
2025-05-26Auto merge of #138489 - tmiasko:call-tmps-lifetime, r=workingjubileebors-13/+35
Describe lifetime of call argument temporaries passed indirectly Fixes #132014.
2025-05-24Auto merge of #141372 - khuey:ir_call_dbg_loc, r=jieyouxubors-0/+1
Use the fn_span when emitting function calls for better debug info. This especially improves the developer experience for long chains of function calls that span multiple lines, which is common with builder patterns, chains of iterator/future combinators, etc. try-job: armhf-gnu try-job: test-various try-job: x86_64-msvc-1 try-job: arm-android r? `@jieyouxu`
2025-05-22Use the fn_span when emitting function calls for better debug info.Kyle Huey-0/+1
This especially improves the developer experience for long chains of function calls that span multiple lines, which is common with builder patterns, chains of iterator/future combinators, etc.
2025-05-22Rename `kw::Empty` as `sym::empty`.Nicholas Nethercote-3/+3
Because the empty string is not a keyword.
2025-05-19Rollup merge of #140874 - mejrs:rads, r=WaffleLapkinStuart Cook-1/+1
make `rustc_attr_parsing` less dominant in the rustc crate graph It has/had a glob re-export of `rustc_attr_data_structures`, which is a crate much lower in the graph, and a lot of crates were using it *just* (or *mostly*) for that re-export, while they can rely on `rustc_attr_data_structures` directly. Previous graph: ![graph_1](https://github.com/user-attachments/assets/f4a5f13c-4222-4903-b56d-28c83511fcbd) Graph with this PR: ![graph_2](https://github.com/user-attachments/assets/1e053d9c-75cc-402b-84df-86229c98277a) The first commit keeps the re-export, and just changes the dependency if possible. The second commit is the "breaking change" which removes the re-export, and "explicitly" adds the `rustc_attr_data_structures` dependency where needed. It also switches over some src/tools/*. The second commit is actually a lot more involved than I expected. Please let me know if it's a better idea to back it out and just keep the first commit.
2025-05-18Remove rustc_attr_data_structures re-export from rustc_attr_parsingmejrs-1/+1
2025-05-17Describe lifetime of call argument temporaries passed indirectlyTomasz Miąsko-13/+35
2025-05-10Rollup merge of #140660 - RalfJung:more-order, r=WaffleLapkinMatthias Krüger-1/+0
remove 'unordered' atomic intrinsics As their doc comment already indicates, these operations do not currently have a place in our memory model. The intrinsics were introduced to support a hack in compiler-builtins, but that hack recently got removed (see https://github.com/rust-lang/compiler-builtins/issues/788).
2025-05-09remove 'unordered' atomic intrinsicsRalf Jung-1/+0
2025-05-05Resolve instance for SymFn in global/naked asmMichael Goulet-1/+3
2025-04-30Rollup merge of #134232 - bjorn3:naked_asm_improvements, r=wesleywiserMatthias Krüger-25/+32
Share the naked asm impl between cg_ssa and cg_clif This was introduced in https://github.com/rust-lang/rust/pull/128004.
2025-04-28AsyncDrop implementation using shim codegen of ↵Andrew Zhogin-7/+11
async_drop_in_place::{closure}, scoped async drop added.
2025-04-14Pass &mut self to codegen_global_asmbjorn3-1/+1
2025-04-14Make codegen_naked_asm publicbjorn3-2/+2
This allows it to be reused by codegen backends that don't use cg_ssa like cg_clif.
2025-04-14Pass MonoItemData to MonoItem::definebjorn3-6/+5
2025-04-14Move codegen_naked_asm call up into MonoItem::definebjorn3-7/+3
2025-04-14Make codegen_naked_asm retrieve the MIR Body itselfbjorn3-5/+6
2025-04-14Only require a CodegenCx for codegen_naked_asmbjorn3-9/+17
2025-04-14Don't begin defining a function when codegening a naked functionbjorn3-7/+7
While LLVM is rather permissive in this regards, some other codegen backends demand that once you declare a function for definition you actually define contents of the function, which doesn't happen for naked functions as we actually generate assembly for them.
2025-04-14Handle protected visibility in codegen_naked_asmbjorn3-4/+7
2025-04-14Use START_BLOCK in codegen_naked_asmbjorn3-2/+2