about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform
AgeCommit message (Collapse)AuthorLines
2023-09-06Auto merge of #115252 - cjgillot:mir-composite, r=davidtwcobors-62/+36
Represent MIR composite debuginfo as projections instead of aggregates Composite debuginfo for MIR is currently represented as ``` debug name => Type { projection1 => place1, projection2 => place2 }; ``` ie. a single `VarDebugInfo` object with that name, and its value a `VarDebugInfoContents::Composite`. This PR proposes to reverse the representation to be ``` debug name.projection1 => place1; debug name.projection2 => place2; ``` ie. multiple `VarDebugInfo` objects with each their projection. This simplifies the handling of composite debuginfo by the compiler by avoiding weird nesting. Based on https://github.com/rust-lang/rust/pull/115139
2023-09-06Propagate PlaceElem::Index.Camille GILLOT-11/+33
2023-09-06Support array length.Camille GILLOT-0/+30
2023-09-06Implement algebraic simplifications.Camille GILLOT-4/+32
2023-09-06Support a few more rvalues.Camille GILLOT-33/+50
2023-09-06fix #115348mojave2-1/+1
2023-09-06Don't report any errors in `lower_intrinsics`. They should have been ↵Oli Scherer-20/+1
typecked before.
2023-09-05Support non-trivial scalars in ConstProp.Camille GILLOT-1/+1
2023-09-05Remove type from ScalarTy.Camille GILLOT-68/+62
2023-09-05Auto merge of #115507 - cjgillot:relative-source-file, r=oli-obkbors-19/+14
Use relative positions inside a SourceFile. This allows to remove the normalization of start positions for hashing, and simplify allocation of global address space. cc `@Zoxc`
2023-09-05Refactor how MIR represents composite debuginfo.Camille GILLOT-62/+36
2023-09-05Rollup merge of #115536 - RalfJung:interpreter-privacy, r=oli-obkMatthias Krüger-20/+24
interpret: make MemPlace, Place, Operand types private to the interpreter Outside the interpreter, only the typed versions should be used.
2023-09-05Auto merge of #115553 - matthiaskrgr:rollup-c0045hz, r=matthiaskrgrbors-5/+5
Rollup of 5 pull requests Successful merges: - #115353 (Emit error instead of ICE when optimized MIR is missing) - #115488 (Take `&mut Results` in `ResultsVisitor`) - #115492 (Allow `large_assignments` for Box/Arc/Rc initialization) - #115519 (Don't ICE on associated type projection without feature gate in new solver) - #115534 (Expose more information with DefId in smir) r? `@ghost` `@rustbot` modify labels: rollup
2023-09-04read_via_copy: don't prematurely optimize away the readRalf Jung-12/+11
2023-09-04interpret: make MemPlace, Place, Operand types private to the interpreterRalf Jung-20/+24
2023-09-03Use relative positions inside a SourceFile.Camille GILLOT-19/+14
2023-09-02Take `&mut Results` in `ResultsVisitor`Jason Newcomb-5/+5
2023-08-30Auto merge of #115194 - tmiasko:inline-always-encode-mir, r=compiler-errorsbors-8/+5
Fix inlining with -Zalways-encode-mir Only inline functions that are considered eligible for inlining by the reachability pass. This constraint was previously indirectly enforced by only exporting MIR of eligible functions, but that approach doesn't work with -Zalways-encode-mir enabled.
2023-08-30move marking-locals-live out of push_stack_frame, so it happens with ↵Ralf Jung-0/+20
argument passing this entirely avoids even creating unsized locals in Immediate::Uninitialized state
2023-08-30Rollup merge of #115272 - RalfJung:miri-error-print, r=saethlinMatthias Krüger-1/+2
miri/diagnostics: don't forget to print_backtrace when ICEing on unexpected errors This should fix the missing output encountered [here](https://github.com/rust-lang/rust/issues/115145#issuecomment-1694334410). r? `@saethlin`
2023-08-27Fix inlining with -Zalways-encode-mirTomasz Miąsko-8/+5
Only inline functions that are considered eligible for inlining by the reachability pass. This constraint was previously indirectly enforced by only exporting MIR of eligible functions, but that approach doesn't work with -Zalways-encode-mir enabled.
2023-08-27miri/diagnostics: don't forget to print_backtrace when ICEing on unexpected ↵Ralf Jung-1/+2
errors then also use the new helper in a few other places
2023-08-25Auto merge of #115138 - cjgillot:dse-move-packed, r=compiler-errorsbors-0/+6
Do not convert copies of packed projections to moves. This code path was introduced in https://github.com/rust-lang/rust/pull/113758 After seeing https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/Packed.20fields.20and.20in-place.20function.20argument.2Freturn.20passing, this may be UB, so should be disallowed. This should not appear in normally-built MIR, which introduces temporary copies for packed projections.
2023-08-24Only check packed ADT.Camille GILLOT-4/+6
2023-08-24when terminating during unwinding, show the reason whyRalf Jung-25/+33
2023-08-23Do not convert copies of packed projections to moves.Camille GILLOT-0/+4
2023-08-22Auto merge of #115005 - compiler-errors:passes, r=cjgillotbors-1/+5
Don't do intra-pass validation on MIR shims Fixes #114375 In the test that was committed, we end up generating the drop shim for `struct Foo` that looks like: ``` fn std::ptr::drop_in_place(_1: *mut Foo) -> () { let mut _0: (); bb0: { goto -> bb5; } bb1: { return; } bb2 (cleanup): { resume; } bb3: { goto -> bb1; } bb4 (cleanup): { drop(((*_1).0: foo::WrapperWithDrop<()>)) -> [return: bb2, unwind terminate]; } bb5: { drop(((*_1).0: foo::WrapperWithDrop<()>)) -> [return: bb3, unwind: bb2]; } } ``` In `bb4` and `bb5`, we assert that `(*_1).0` has type `WrapperWithDrop<()>`. However, In a user-facing param env, the type is actually `WrapperWithDrop<Tait>`. These types are not equal in a user-facing param-env (and can't be made equal even if we use `DefiningAnchor::Bubble`, since it's a non-local TAIT).
2023-08-20Auto merge of #114993 - RalfJung:panic-nounwind, r=fee1-deadbors-32/+43
interpret/miri: call the panic_nounwind machinery the same way codegen does
2023-08-20interpret: have assert_* intrinsics call the panic machinery instead of a ↵Ralf Jung-0/+11
direct abort
2023-08-20give some unwind-related terminators a more clear nameRalf Jung-32/+32
2023-08-20Auto merge of #114791 - Zalathar:bcb-counter, r=cjgillotbors-87/+146
coverage: Give the instrumentor its own counter type, separate from MIR Within the MIR representation of coverage data, `CoverageKind` is an important part of `StatementKind::Coverage`, but the `InstrumentCoverage` pass also uses it heavily as an internal data structure. This means that any change to `CoverageKind` also needs to update all of the internal parts of `InstrumentCoverage` that manipulate it directly, making the MIR representation difficult to modify. --- This change fixes that by giving the instrumentor its own `BcbCounter` type for internal use, which is then converted to a `CoverageKind` when injecting coverage information into MIR. The main change is mostly mechanical, because the initial `BcbCounter` is drop-in compatible with `CoverageKind`, minus the unnecessary `CoverageKind::Unreachable` variant. I've then removed the `function_source_hash` field from `BcbCounter::Counter`, as a small example of how the two types can now usefully differ from each other. Every counter in a MIR-level function should have the same source hash, so we can supply the hash during the conversion to `CoverageKind::Counter` instead. --- *Background:* BCB stands for “basic coverage block”, which is a node in the simplified control-flow graph used by coverage instrumentation. The instrumentor pass uses the function's actual MIR control-flow graph to build a simplified BCB graph, then assigns coverage counters and counter expressions to various nodes/edges in that simplified graph, and then finally injects corresponding coverage information into the underlying MIR.
2023-08-20Auto merge of #113124 - nbdd0121:eh_frame, r=cjgillotbors-4/+46
Add MIR validation for unwind out from nounwind functions + fixes to make validation pass `@Nilstrieb` This is the MIR validation you asked in https://github.com/rust-lang/rust/pull/112403#discussion_r1222739722. Two passes need to be fixed to get the validation to pass: * `RemoveNoopLandingPads` currently unconditionally introduce a resume block (even there is none to begin with!), changed to not do that * Generator state transform introduces a `assert` which may unwind, and its drop elaboration also introduces many new `UnwindAction`s, so in this case run the AbortUnwindingCalls after the transformation. I believe this PR should also fix Rust-for-Linux/linux#1016, cc `@ojeda` r? `@Nilstrieb`
2023-08-20coverage: Don't store `function_source_hash` in `BcbCounter::Counter`Zalathar-12/+9
This shows one small benefit of separating `BcbCounter` from `CoverageKind`. The function source hash will be the same for all counters within a function, so instead of passing it through `CoverageCounters` and storing it in every counter, we can just supply it during the final conversion to `CoverageKind`.
2023-08-20coverage: Give the instrumentor its own counter type, separate from MIRZalathar-70/+129
This splits off `BcbCounter` from MIR's `CoverageKind`, allowing the two types to evolve in different directions as necessary.
2023-08-20coverage: Move a debug print into `make_code_region`Zalathar-8/+11
2023-08-20coverage: Remove a useless `let () =`Zalathar-1/+1
2023-08-19Don't do intra-pass validation on MIR shimsMichael Goulet-1/+5
2023-08-19use static arrays instead of vectorsMatthias Krüger-2/+2
2023-08-18Change generator_drop's instance to that of generator for dump_mirGary Guo-1/+8
Otherwise the file name generated for generator_drop will become core.ptr-drop_in_place.[generator@<FILEPATH>_<NUMBERS>].generator_drop.0.mir instead of main-{closure#0}.generator_drop.0.mir which breaks a mir-opt test.
2023-08-18Perform MIR validation on drop glue of generatorGary Guo-1/+10
2023-08-18Run `AbortUnwindingCalls` after generator transformGary Guo-0/+16
2023-08-18Do not create new resume block if there isn't one alreadyGary Guo-3/+13
2023-08-18Auto merge of #114948 - compiler-errors:normalize-before-freeze, r=lcnrbors-1/+6
Normalize before checking if local is freeze in `deduced_param_attrs` Not normalizing the local type eagerly results in possibly exponential amounts of normalization happening downstream in `is_freeze_raw`. Fixes #113372
2023-08-17Normalize before checking if local is freeze in deduced_param_attrsMichael Goulet-1/+6
2023-08-17Revert "Implement references VarDebugInfo."Camille GILLOT-8/+0
This reverts commit 2ec007191348ef7cc13eb55e44e007b02cf75cf3.
2023-08-16Do not pre-compute reachable blocks.Camille GILLOT-20/+0
2023-08-16Update doc comment.Camille GILLOT-1/+1
2023-08-16Make dataflow const-prop handle_switch_int monotonic.Camille GILLOT-8/+11
2023-08-16Make TerminatorEdge plural.Camille GILLOT-3/+3
2023-08-16Rename MaybeUnreachable.Camille GILLOT-2/+2