about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/mir/syntax.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/+1
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-3/+11
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-23A MIR transform that checks pointers are alignedBen Kimock-0/+1
2023-03-22Add `CastKind::Transmute` to MIRScott McMurray-0/+7
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-21Rollup merge of #109408 - RalfJung:retags, r=compiler-errorsnils-1/+2
not *all* retags might be explicit in Runtime MIR In https://github.com/rust-lang/rust/pull/105317 I made Miri treat `Rvalue::Ref/AddrOf` as implicit retagging sites. This updates the MIR docs accordingly. For `Rvalue::Ref` I think this makes a lot more sense: creating a new reference is their entire point, so we can avoid bloating the MIR with retags. Also this seems to be the best way to handle cases like `*ptr = &[mut] ...`, where doing a retag is somewhat questionable since maybe `*ptr` points to another place now? For `Rvalue::AddrOf`, Stacked Borrows needs this because even raw ptrs need some retagging, but Tree Borrows doesn't do ant retagging here and I hope we'll end up with a model where raw pointers don't get retagged.
2023-03-20not *all* retags might be explicit in Runtime MIRRalf Jung-1/+2
2023-03-20Fix off-by-one in mir syntax docAndy Wang-1/+1
2023-03-16Tweak implementation of overflow checking assertionsTomasz Miąsko-2/+1
Extract and reuse logic controlling behaviour of overflow checking assertions instead of duplicating it three times.
2023-03-16Rollup merge of #109180 - gimbles:master, r=compiler-errorsMatthias Krüger-1/+1
Unequal → Not equal Fixes #109168
2023-03-15Auto merge of #108282 - cjgillot:mir-checked-sh, r=tmiaskobors-4/+0
Implement checked Shl/Shr at MIR building. This does not require any special handling by codegen backends, as the overflow behaviour is entirely determined by the rhs (shift amount). This allows MIR ConstProp to remove the overflow check for constant shifts. ~There is an existing different behaviour between cg_llvm and cg_clif (cc `@bjorn3).` I took cg_llvm's one as reference: overflow if `rhs < 0 || rhs > number_of_bits_in_lhs_ty`.~ EDIT: `cg_llvm` and `cg_clif` implement the overflow check differently. This PR uses `cg_llvm`'s implementation based on a `BitAnd` instead of `cg_clif`'s one based on an unsigned comparison.
2023-03-15unequal → not equalgimbles-1/+1
2023-03-09Pacify tidy.Camille GILLOT-2/+2
2023-03-09Introduce a no-op PlaceMention statement for `let _ =`.Camille GILLOT-0/+9
2023-03-07Remove DropAndReplace terminatorGiacomo Pasini-38/+0
PR 107844 made DropAndReplace unused, let's remove it completely from the codebase.
2023-02-27Update MIR doc.Camille GILLOT-4/+0
2023-02-18Update compiler/rustc_middle/src/mir/syntax.rsCamille Gillot-1/+2
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-02-18Remove exception from MIR doc.Camille GILLOT-4/+0
2023-02-18Correct comment.Camille GILLOT-2/+4
2023-02-18Add comment.Camille GILLOT-0/+3
2023-02-02Put a DefId in AggregateKind.Camille GILLOT-4/+2
2023-01-23Add comments and remove unnecessary codeBryan Garza-4/+5
2023-01-23Create stable metric to measure long computation in Const EvalBryan Garza-1/+6
This patch adds a `MirPass` that tracks the number of back-edges and function calls in the CFG, adds a new MIR instruction to increment a counter every time they are encountered during Const Eval, and emit a warning if a configured limit is breached.
2023-01-16Add cycle checking to cleanup control flow validationJakob Degen-4/+7
2023-01-16Document wf constraints on control flow in cleanup blocksJakob Degen-0/+7
Also fixes a bug in dominator computation
2022-12-22Auto merge of #103957 - JakobDegen:drop-retag, r=RalfJungbors-8/+7
Retag as FnEntry on `drop_in_place` This commit changes the mir drop shim to always retag its argument as if it were a `&mut`. cc rust-lang/unsafe-code-guidelines#373
2022-12-21Don't run `Drop` terminators on types that do not have drop glue in const evalJakob Degen-8/+7
2022-12-21Forbid `RetagKind::TwoPhase` as wellJakob Degen-2/+1
2022-12-21Clarify that raw retags are not permitted in MirJakob Degen-2/+5
2022-12-19Revert "Auto merge of #103880 - b-naber:field-ty-mir, r=lcnr"Rémy Rakic-35/+4
This reverts commit 03770f0e2b60c02db8fcf52fed5fb36aac70cedc, reversing changes made to 01ef4b21dc5251b58bd9c6fd6face2ae95d56da1.
2022-12-16Auto merge of #103880 - b-naber:field-ty-mir, r=lcnrbors-4/+35
Use non-ascribed type as field's type in mir Fixes https://github.com/rust-lang/rust/issues/96514 r? `@lcnr`
2022-12-14address reviewb-naber-1/+8
2022-12-09Remove unneeded field from `SwitchTargets`Jakob Degen-6/+0
2022-12-09Rollup merge of #105455 - lcnr:correct-reveal-in-validate, r=jackh726Matthias Krüger-0/+8
use the correct `Reveal` during validation supersedes #105454. Deals with https://github.com/rust-lang/rust/issues/105009#issuecomment-1342395333, not closing #105009 as the ICE may leak into beta The issue was the following: - we optimize the mir, using `Reveal::All` - some optimization relies on the hidden type of an opaque type - we then validate using `Reveal::UserFacing` again which is not able to observe the hidden type r? `@jackh726`
2022-12-08validate: use the correct reveal during optslcnr-0/+8
2022-12-06make retagging work even with 'unstable' placesRalf Jung-1/+1
2022-12-01Don't go through the formatting infrastructure just to get the name of a phaseOli Scherer-0/+13
2022-11-25Add empty ConstKind::Abstractkadmin-2/+4
Initial pass at expr/abstract const/s Address comments Switch to using a list instead of &[ty::Const], rm `AbstractConst` Remove try_unify_abstract_consts Update comments Add edits Recurse more More edits Prevent equating associated consts Move failing test to ui Changes this test from incremental to ui, and mark it as failing and a known bug. Does not cause the compiler to ICE, so should be ok.
2022-11-23use no type in ProjectionElem::Field for PlaceBuilder::UpVarb-naber-4/+28
2022-11-13fix some typos in commentscui fliter-1/+1
Signed-off-by: cui fliter <imcusg@gmail.com>
2022-10-12Use `tidy-alphabetical` in the compilerNilstrieb-1/+2
2022-10-06Remove `mir::CastKind::Misc`ouz-a-2/+6
2022-09-26remove cfg(bootstrap)Pietro Albini-1/+0
2022-09-20Rollup merge of #101976 - RalfJung:mir-semantic-phases, r=oli-obkMichael Howell-3/+4
MirPhase: clarify that linting is not a semantic change r? ```@JakobDegen```
2022-09-18clarify that linting is not a semantic changeRalf Jung-3/+4
2022-09-16Revert "Revert "Rollup merge of #98582 - oli-obk:unconstrained_opaque_type, ↵Oli Scherer-0/+7
r=estebank"" This reverts commit 4a742a691e7dd2522bad68b86fe2fd5a199d5561.
2022-09-15derive TypeVisitable and TypeFoldable for mir typesOli Scherer-5/+6
2022-09-15Derive TypeFoldable and TypeVisitable for mir::PlaceElementOli Scherer-1/+1
2022-09-12dyn* through more typechecking and MIREric Holk-0/+2
2022-09-08Rollup merge of #101545 - TaKO8Ki:remove-unnecessary-partialord-ord, r=oli-obkDylan DPC-1/+1
Remove unnecessary `PartialOrd` and `Ord`