about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/mir/block.rs
AgeCommit message (Collapse)AuthorLines
2025-10-02codegen: Generate `dbg_value` for the ref statementdianqk-0/+1
2025-09-19added typetree support for memcpyKaran Janthe-0/+1
2025-09-17Remove `DynKind`León Orell Valerian Liehr-1/+1
2025-09-03explicitly start `va_list` lifetimeFolkert de Vries-1/+1
2025-08-31explicitly end `va_list` lifetimeFolkert de Vries-0/+3
2025-08-14drive-by: fix typoWaffle Lapkin-1/+1
2025-08-13fix tail calls to `#[track_caller]` functionsWaffle Lapkin-5/+27
2025-07-26Implement support for explicit tail calls in the MIR block builders and the ↵Joel Wejdenstål-11/+62
LLVM codegen backend.
2025-07-01Remove support for dyn*Michael Goulet-71/+0
2025-06-28Auto merge of #141759 - 1c3t3a:discriminants-query, r=saethlinbors-0/+6
Insert checks for enum discriminants when debug assertions are enabled Similar to the existing null-pointer and alignment checks, this checks for valid enum discriminants on creation of enums through unsafe transmutes. Essentially this sanitizes patterns like the following: ```rust let val: MyEnum = unsafe { std::mem::transmute<u32, MyEnum>(42) }; ``` An extension of this check will be done in a follow-up that explicitly sanitizes for extern enum values that come into Rust from e.g. C/C++. This check is similar to Miri's capabilities of checking for valid construction of enum values. This PR is inspired by saethlin@'s PR https://github.com/rust-lang/rust/pull/104862. Thank you so much for keeping this code up and the detailed comments! I also pair-programmed large parts of this together with vabr-g@. r? `@saethlin`
2025-06-27Insert checks for enum discriminants when debug assertions are enabledBastian Kersting-0/+6
Similar to the existing nullpointer and alignment checks, this checks for valid enum discriminants on creation of enums through unsafe transmutes. Essentially this sanitizes patterns like the following: ```rust let val: MyEnum = unsafe { std::mem::transmute<u32, MyEnum>(42) }; ``` An extension of this check will be done in a follow-up that explicitly sanitizes for extern enum values that come into Rust from e.g. C/C++. This check is similar to Miri's capabilities of checking for valid construction of enum values. This PR is inspired by saethlin@'s PR https://github.com/rust-lang/rust/pull/104862. Thank you so much for keeping this code up and the detailed comments! I also pair-programmed large parts of this together with vabr-g@.
2025-06-16Fix RISC-V C function ABI when passing/returning structs containing floatsbeetrees-6/+48
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-05Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of NoneOli Scherer-4/+5
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-8/+2
2025-05-26Pass PlaceRef rather than Bx::Value to codegen_intrinsic_callbjorn3-1/+3
2025-05-26Move caller_location handling into codegen_intrinsic_callbjorn3-16/+9
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-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-17Describe lifetime of call argument temporaries passed indirectlyTomasz Miąsko-13/+35
2025-04-28AsyncDrop implementation using shim codegen of ↵Andrew Zhogin-7/+11
async_drop_in_place::{closure}, scoped async drop added.
2025-03-17Flatten `if`s in `rustc_codegen_ssa`Yotam Ofek-19/+19
2025-03-06Use `trunc nuw`+`br` for 0/1 branches even in optimized buildsScott McMurray-0/+34
Rather than needing to use `switch` for them to include the `unreachable` arm
2025-02-24Rollup merge of #137505 - tgross35:builtins-cannot-call-error, r=compiler-errorsJacob Pratt-3/+7
Add a span to `CompilerBuiltinsCannotCall` Currently, this error emit a diagnostic with no context like: error: `compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `<math::libm::support::hex_float::Hexf<i32> as core::fmt::LowerHex>::fmt` to `core::fmt::num::<impl core::fmt::LowerHex for i32>::fmt` With this change, it at least usually points to the problematic function: error: `compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `<math::libm::support::hex_float::Hexf<i32> as core::fmt::LowerHex>::fmt` to `core::fmt::num::<impl core::fmt::LowerHex for i32>::fmt` --> src/../libm/src/math/support/hex_float.rs:270:5 | 270 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
2025-02-24Add a span to `CompilerBuiltinsCannotCall`Trevor Gross-3/+7
Currently, this error emit a diagnostic with no context like: error: `compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `<math::libm::support::hex_float::Hexf<i32> as core::fmt::LowerHex>::fmt` to `core::fmt::num::<impl core::fmt::LowerHex for i32>::fmt` With this change, it at least usually points to the problematic function: error: `compiler_builtins` cannot call functions through upstream monomorphizations; encountered invalid call from `<math::libm::support::hex_float::Hexf<i32> as core::fmt::LowerHex>::fmt` to `core::fmt::num::<impl core::fmt::LowerHex for i32>::fmt` --> src/../libm/src/math/support/hex_float.rs:270:5 | 270 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
2025-02-23Rollup merge of #136439 - yotamofek:pr/codegen-ssa-no-indexing, r=NoratriebTrevor Gross-2/+3
Misc. `rustc_codegen_ssa` cleanups 🧹 Just a bunch of stuff I found while reading the crate's code. Each commit can stand on its own. Maybe r? `@Noratrieb` because I saw you did some similar cleanups on these files a while ago? (feel free to re-assign, I'm just guessing)
2025-02-22Fix binding mode problemsMichael Goulet-2/+2
2025-02-20Add test that uninhabited repr(transparent) type has same function return ↵Zachary S-21/+7
ABI as wrapped type. Fix codegen of uninhabited PassMode::Indirect return types. Add codegen test for uninhabited PassMode::Indirect return types. Enable optimizations for uninhabited return type codegen test
2025-02-19Rework `OperandRef::extract_field` to stop calling `to_immediate_scalar` on ↵Scott McMurray-5/+5
things which are already immediates That means it stops trying to truncate things that are already `i1`s.
2025-02-18Auto merge of #133852 - x17jiri:cold_path, r=saethlinbors-5/+28
improve cold_path() #120370 added a new instrinsic `cold_path()` and used it to fix `likely` and `unlikely` However, in order to limit scope, the information about cold code paths is only used in 2-target switch instructions. This is sufficient for `likely` and `unlikely`, but limits usefulness of `cold_path` for idiomatic rust. For example, code like this: ``` if let Some(x) = y { ... } ``` may generate 3-target switch: ``` switch y.discriminator: 0 => true branch 1 = > false branch _ => unreachable ``` and therefore marking a branch as cold will have no effect. This PR improves `cold_path()` to work with arbitrary switch instructions. Note that for 2-target switches, we can use `llvm.expect`, but for multiple targets we need to manually emit branch weights. I checked Clang and it also emits weights in this situation. The Clang's weight calculation is more complex that this PR, which I believe is mainly because `switch` in `C/C++` can have multiple cases going to the same target.
2025-02-17improve cold_path()Jiri Bobek-5/+28
2025-02-11rustc_codegen_ssa: cleanup nested `if`s and a needless `match`Yotam Ofek-2/+3
2025-02-10Rename rustc_middle::Ty::is_unsafe_ptr to is_raw_ptrBastian Kersting-2/+2
The wording unsafe pointer is less common and not mentioned in a lot of places, instead this is usually called a "raw pointer". For the sake of uniformity, we rename this method. This came up during the review of https://github.com/rust-lang/rust/pull/134424.
2025-02-09Auto merge of #136751 - bjorn3:update_rustfmt, r=Mark-Simulacrumbors-4/+4
Update bootstrap compiler and rustfmt The rustfmt version we previously used formats things differently from what the latest nightly rustfmt does. This causes issues for subtrees that get formatted both in-tree and in their own repo. Updating the rustfmt used in-tree solves those issues. Also bumped the bootstrap compiler as the stage0 update command always updates both at the same time.
2025-02-08Rollup merge of #136706 - workingjubilee:finish-up-rustc-abi-updates, ↵Jubilee-3/+3
r=compiler-errors compiler: mostly-finish `rustc_abi` updates This almost-finishes all the updates in the compiler to use `rustc_abi` and removes some of the reexports of `rustc_abi` items in `rustc_target` that were previously available. r? ```@compiler-errors```
2025-02-08Rustfmtbjorn3-4/+4
2025-02-08Rollup merge of #136200 - purplesyringa:wasm-eh-fixes, r=bjorn3Matthias Krüger-6/+23
Generate correct terminate block under Wasm EH This fixes failing LLVM assertions during insnsel. Improves #135665. r? bjorn3 ^ you reviewed the PR bringing Wasm EH in, I assume this is within your area of expertise?
2025-02-07compiler: remove reexports from rustc_target::callconvJubilee Young-3/+3
2025-02-06Generate correct terminate block under Wasm EHAlisa Sireneva-6/+23
This fixes failing LLVM assertions during insnsel. Improves #135665.
2025-01-31Insert null checks for pointer dereferences when debug assertions are enabledBastian Kersting-0/+5
Similar to how the alignment is already checked, this adds a check for null pointer dereferences in debug mode. It is implemented similarly to the alignment check as a MirPass. This is related to a 2025H1 project goal for better UB checks in debug mode: https://github.com/rust-lang/rust-project-goals/pull/177.
2024-12-06Remove polymorphizationBen Kimock-4/+7
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-10/+4
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
2024-11-17Likely unlikely fixJiri Bobek-5/+17
2024-11-03compiler: Directly use rustc_abi in codegenJubilee Young-4/+3
2024-10-29compiler: `rustc_abi::Abi` => `BackendRepr`Jubilee Young-1/+1
The initial naming of "Abi" was an awful mistake, conveying wrong ideas about how psABIs worked and even more about what the enum meant. It was only meant to represent the way the value would be described to a codegen backend as it was lowered to that intermediate representation. It was never meant to mean anything about the actual psABI handling! The conflation is because LLVM typically will associate a certain form with a certain ABI, but even that does not hold when the special cases that actually exist arise, plus the IR annotations that modify the ABI. Reframe `rustc_abi::Abi` as the `BackendRepr` of the type, and rename `BackendRepr::Aggregate` as `BackendRepr::Memory`. Unfortunately, due to the persistent misunderstandings, this too is now incorrect: - Scattered ABI-relevant code is entangled with BackendRepr - We do not always pre-compute a correct BackendRepr that reflects how we "actually" want this value to be handled, so we leave the backend interface to also inject various special-cases here - In some cases `BackendRepr::Memory` is a "real" aggregate, but in others it is in fact using memory, and in some cases it is a scalar! Our rustc-to-backend lowering code handles this sort of thing right now. That will eventually be addressed by lifting duplicated lowering code to either rustc_codegen_ssa or rustc_target as appropriate.