about summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift/src/base.rs
AgeCommit message (Collapse)AuthorLines
2023-04-01Use `FieldIdx` in various things related to aggregatesScott McMurray-3/+4
Shrank `AggregateKind` by 8 bytes on x64, since the active field of a union is tracked as an `Option<FieldIdx>` instead of `Option<usize>`.
2023-03-31Auto merge of #98112 - saethlin:mir-alignment-checks, r=oli-obkbors-0/+12
Insert alignment checks for pointer dereferences when debug assertions are enabled Closes https://github.com/rust-lang/rust/issues/54915 - [x] Jake tells me this sounds like a place to use `MirPatch`, but I can't figure out how to insert a new basic block with a new terminator in the middle of an existing basic block, using `MirPatch`. (if nobody else backs up this point I'm checking this as "not actually a good idea" because the code looks pretty clean to me after rearranging it a bit) - [x] Using `CastKind::PointerExposeAddress` is definitely wrong, we don't want to expose. Calling a function to get the pointer address seems quite excessive. ~I'll see if I can add a new `CastKind`.~ `CastKind::Transmute` to the rescue! - [x] Implement a more helpful panic message like slice bounds checking. r? `@oli-obk`
2023-03-28Move `mir::Field` → `abi::FieldIdx`Scott McMurray-1/+1
The first PR for https://github.com/rust-lang/compiler-team/issues/606 This is just the move-and-rename, because it's plenty big-and-bitrotty already. Future PRs will start using `FieldIdx` more broadly, and concomitantly removing `FieldIdx::new`s.
2023-03-25Refactor: `VariantIdx::from_u32(0)` -> `FIRST_VARIANT`Scott McMurray-1/+1
Since structs are always `VariantIdx(0)`, there's a bunch of files where the only reason they had `VariantIdx` or `vec::Idx` imported at all was to get the first variant. So this uses a constant for that, and adds some doc-comments to `VariantIdx` while I'm there, since it doesn't have any today.
2023-03-23A MIR transform that checks pointers are alignedBen Kimock-0/+12
2023-03-22Add `CastKind::Transmute` to MIRScott McMurray-0/+4
Updates `interpret`, `codegen_ssa`, and `codegen_cranelift` to consume the new cast instead of the intrinsic. Includes `CastTransmute` for custom MIR building, to be able to test the extra UB.
2023-03-16Tweak implementation of overflow checking assertionsTomasz Miąsko-11/+4
Extract and reuse logic controlling behaviour of overflow checking assertions instead of duplicating it three times.
2023-03-15Merge commit 'dec0daa8f6d0a0e1c702f169abb6bf3eee198c67' into ↵bjorn3-11/+7
sync_cg_clif-2023-03-15
2023-03-09Introduce a no-op PlaceMention statement for `let _ =`.Camille GILLOT-0/+1
2023-03-07Remove DropAndReplace terminatorGiacomo Pasini-1/+0
PR 107844 made DropAndReplace unused, let's remove it completely from the codebase.
2023-02-18Adapt cg_clif.Camille GILLOT-10/+7
2023-02-14s/eval_usize/eval_target_usize/ for clarityOli Scherer-1/+1
2023-02-09Merge commit '7d53619064ab7045c383644cb445052d2a3d46db' into ↵bjorn3-33/+58
sync_cg_clif-2023-02-09
2023-01-29Auto merge of #106227 - bryangarza:ctfe-limit, r=oli-obkbors-0/+1
Use stable metric for const eval limit instead of current terminator-based logic This patch adds a `MirPass` that inserts a new MIR instruction `ConstEvalCounter` to any loops and function calls in the CFG. This instruction is used during Const Eval to count against the `const_eval_limit`, and emit the `StepLimitReached` error, replacing the current logic which uses Terminators only. The new method of counting loops and function calls should be more stable across compiler versions (i.e., not cause crates that compiled successfully before, to no longer compile when changes to the MIR generation/optimization are made). Also see: #103877
2023-01-24Merge commit '598f0909568a51de8a2d1148f55a644fd8dffad0' into ↵bjorn3-10/+32
sync_cg_clif-2023-01-24
2023-01-23Update codegen cranelift for ConstEvalCounterBryan Garza-0/+1
2022-12-14Merge commit '2bb3996244cf1b89878da9e39841e9f6bf061602' into ↵bjorn3-10/+2
sync_cg_clif-2022-12-14
2022-12-09Remove unneeded field from `SwitchTargets`Jakob Degen-2/+4
2022-10-27Update toolingMaybe Waffle-5/+1
2022-10-23Merge commit '266e96785ab71834b917bf474f130a6d8fdecd4b' into ↵bjorn3-5/+7
sync_cg_clif-2022-10-23
2022-10-06Remove `mir::CastKind::Misc`ouz-a-1/+6
2022-09-16Revert "Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, ↵Oli Scherer-0/+1
r=estebank"" This reverts commit 4a742a691e7dd2522bad68b86fe2fd5a199d5561.
2022-09-12Make x.py check workEric Holk-0/+4
2022-09-06Generalize the Assume intrinsic statement to a general Intrinsic statementOli Scherer-16/+25
2022-09-06Lower the assume intrinsic to a MIR statementOli Scherer-0/+2
2022-08-31Rollup merge of #100730 - CleanCut:diagnostics-rustc_monomorphize, r=davidtwcoRalf Jung-2/+5
Migrate rustc_monomorphize to use SessionDiagnostic ### Description - Migrates diagnostics in `rustc_monomorphize` to use `SessionDiagnostic` - Adds an `impl IntoDiagnosticArg for PathBuf` ### TODO / Help! - [x] I'm having trouble figuring out how to apply an optional note. 😕 Help!? - Resolved. It was bad docs. Fixed in https://github.com/rust-lang/rustc-dev-guide/pull/1437/files - [x] `errors:RecursionLimit` should be `#[fatal ...]`, but that doesn't exist so it's `#[error ...]` at the moment. - Maybe I can switch after this is merged in? --> https://github.com/rust-lang/rust/pull/100694 - Or maybe I need to manually implement `SessionDiagnostic` instead of deriving it? - [x] How does one go about converting an error inside of [a call to struct_span_lint_hir](https://github.com/rust-lang/rust/blob/8064a495086c2e63c0ef77e8e82fe3b9b5dc535f/compiler/rustc_monomorphize/src/collector.rs#L917-L927)? - [x] ~What placeholder do you use in the fluent template to refer to the value in a vector? It seems like [this code](https://github.com/rust-lang/rust/blob/0b79f758c9aa6646606662a6d623a0752286cd17/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs#L83-L114) ought to have the answer (or something near it)...but I can't figure it out.~ You can't. Punted.
2022-08-26Replace `Body::basic_blocks()` with field accessTomasz Miąsko-2/+2
2022-08-25adjust to new error valueNathan Stocks-2/+5
2022-08-24Merge commit 'e9d1a0a7b0b28dd422f1a790ccde532acafbf193' into ↵bjorn3-118/+109
sync_cg_clif-2022-08-24
2022-07-25Merge commit 'c19edfd71a1d0ddef86c2c67fdb40718d40a72b4' into ↵bjorn3-10/+29
sync_cg_clif-2022-07-25
2022-07-20Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, r=estebank"Oli Scherer-1/+0
This reverts commit 6f8fb911ad504b77549cf3256a09465621beab9d, reversing changes made to 7210e46dc69a4b197a313d093fe145722c248b7d.
2022-07-15Introduce opaque type to hidden type projectionOli Scherer-0/+1
2022-07-12add new rval, pull deref earlyouz-a-0/+5
2022-07-05Auto merge of #96862 - oli-obk:enum_cast_mir, r=RalfJungbors-23/+0
Change enum->int casts to not go through MIR casts. follow-up to https://github.com/rust-lang/rust/pull/96814 this simplifies all backends and even gives LLVM more information about the return value of `Rvalue::Discriminant`, enabling optimizations in more cases.
2022-06-30Recover when failing to normalize closure signature.Camille GILLOT-0/+1
2022-06-30Change enum->int casts to not go through MIR casts.Oli Scherer-23/+0
Instead we generate a discriminant rvalue and cast the result of that.
2022-06-14Rename the `ConstS::val` field as `kind`.Nicholas Nethercote-1/+1
And likewise for the `Const::val` method. Because its type is called `ConstKind`. Also `val` is a confusing name because `ConstKind` is an enum with seven variants, one of which is called `Value`. Also, this gives consistency with `TyS` and `PredicateS` which have `kind` fields. The commit also renames a few `Const` variables from `val` to `c`, to avoid confusion with the `ConstKind::Value` variant.
2022-06-02add cast kind of from_exposed_addr (int-to-ptr casts)Ralf Jung-1/+3
2022-06-01rename PointerAddress → PointerExposeAddressRalf Jung-1/+5
2022-05-31Add a pointer to address cast kindTomasz Miąsko-1/+1
A pointer to address cast are often special-cased. Introduce a dedicated cast kind to make them easy distinguishable.
2022-05-23Refactor call terminator to always hold a destination placeJakob Degen-0/+2
2022-05-15Merge commit '63734fcdd718cca089f84c42f3a42c0096cfd431' into ↵bjorn3-8/+18
sync_cg_clif-2022-05-15
2022-04-22Merge commit 'f2cdd4a78d89c009342197cf5844a21f8aa813df' into ↵bjorn3-1/+2
sync_cg_clif-2022-04-22
2022-04-11Add new `Deinit` statement kindJakob Degen-0/+1
2022-03-20Merge commit '370c397ec9169809e5ad270079712e0043514240' into ↵bjorn3-12/+23
sync_cg_clif-2022-03-20
2022-02-23Merge commit '35d9c6bf256968e1b40e0d554607928bdf9cebea' into ↵bjorn3-16/+40
sync_cg_clif-2022-02-23
2022-02-15Overhaul `Const`.Nicholas Nethercote-1/+1
Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as this: ``` pub struct Const<'tcx>(&'tcx Interned<ConstS>); ``` This now matches `Ty` and `Predicate` more closely, including using pointer-based `eq` and `hash`. Notable changes: - `mk_const` now takes a `ConstS`. - `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a we need separate arena for it, because we can't use the `Dropless` one any more. - Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes - Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes. - Lots of tedious sigil fiddling.
2022-02-15Overhaul `TyS` and `Ty`.Nicholas Nethercote-4/+4
Specifically, change `Ty` from this: ``` pub type Ty<'tcx> = &'tcx TyS<'tcx>; ``` to this ``` pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>); ``` There are two benefits to this. - It's now a first class type, so we can define methods on it. This means we can move a lot of methods away from `TyS`, leaving `TyS` as a barely-used type, which is appropriate given that it's not meant to be used directly. - The uniqueness requirement is now explicit, via the `Interned` type. E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather than via `TyS`, which wasn't obvious at all. Much of this commit is boring churn. The interesting changes are in these files: - compiler/rustc_middle/src/arena.rs - compiler/rustc_middle/src/mir/visit.rs - compiler/rustc_middle/src/ty/context.rs - compiler/rustc_middle/src/ty/mod.rs Specifically: - Most mentions of `TyS` are removed. It's very much a dumb struct now; `Ty` has all the smarts. - `TyS` now has `crate` visibility instead of `pub`. - `TyS::make_for_test` is removed in favour of the static `BOOL_TY`, which just works better with the new structure. - The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned` (pointer-based, for the `Equal` case) and partly on `TyS` (contents-based, for the other cases). - There are many tedious sigil adjustments, i.e. adding or removing `*` or `&`. They seem to be unavoidable.
2022-01-12Remove deprecated LLVM-style inline assemblyTomasz Miąsko-12/+0
2022-01-03Rollup merge of #90102 - nbdd0121:box3, r=jonas-schievinkMatthias Krüger-25/+0
Remove `NullOp::Box` Follow up of #89030 and MCP rust-lang/compiler-team#460. ~1 month later nothing seems to be broken, apart from a small regression that #89332 (1aac85bb716c09304b313d69d30d74fe7e8e1a8e) shows could be regained by remvoing the diverging path, so it shall be safe to continue and remove `NullOp::Box` completely. r? `@jonas-schievink` `@rustbot` label T-compiler