about summary refs log tree commit diff
path: root/src/test/mir-opt
AgeCommit message (Collapse)AuthorLines
2022-07-04Don't use match-destructuring for derived ops on structs.Nicholas Nethercote-66/+46
All derive ops currently use match-destructuring to access fields. This is reasonable for enums, but sub-optimal for structs. E.g.: ``` fn eq(&self, other: &Point) -> bool { match *other { Self { x: ref __self_1_0, y: ref __self_1_1 } => match *self { Self { x: ref __self_0_0, y: ref __self_0_1 } => (*__self_0_0) == (*__self_1_0) && (*__self_0_1) == (*__self_1_1), }, } } ``` This commit changes derive ops on structs to use field access instead, e.g.: ``` fn eq(&self, other: &Point) -> bool { self.x == other.x && self.y == other.y } ``` This is faster to compile, results in smaller binaries, and is simpler to generate. Unfortunately, we have to keep the old pattern generating code around for `repr(packed)` structs because something like `&self.x` (which doesn't show up in `PartialEq` ops, but does show up in `Debug` and `Hash` ops) isn't allowed. But this commit at least changes those cases to use let-destructuring instead of match-destructuring, e.g.: ``` fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { { let Self(ref __self_0_0) = *self; { ::core::hash::Hash::hash(&(*__self_0_0), state) } } } ``` There are some unnecessary blocks remaining in the generated code, but I will fix them in a follow-up PR.
2022-07-02Auto merge of #91743 - cjgillot:enable_mir_inlining_inline_all, r=oli-obkbors-11/+97
Enable MIR inlining Continuation of https://github.com/rust-lang/rust/pull/82280 by `@wesleywiser.` #82280 has shown nice compile time wins could be obtained by enabling MIR inlining. Most of the issues in https://github.com/rust-lang/rust/issues/81567 are now fixed, except the interaction with polymorphization which is worked around specifically. I believe we can proceed with enabling MIR inlining in the near future (preferably just after beta branching, in case we discover new issues). Steps before merging: - [x] figure out the interaction with polymorphization; - [x] figure out how miri should deal with extern types; - [x] silence the extra arithmetic overflow warnings; - [x] remove the codegen fulfilment ICE; - [x] remove the type normalization ICEs while compiling nalgebra; - [ ] tweak the inlining threshold.
2022-07-01Ignore test with panic=abort.Camille GILLOT-12/+14
2022-07-01Shorten def_span for more items.Camille GILLOT-20/+20
2022-06-30Skip inlining if there are normalization issues.Camille GILLOT-0/+57
2022-06-30Check history earlier.Camille GILLOT-11/+38
2022-06-30Change enum->int casts to not go through MIR casts.Oli Scherer-0/+143
Instead we generate a discriminant rvalue and cast the result of that.
2022-06-28emit Retag for compound types with reference fieldsRalf Jung-0/+2
2022-06-21Auto merge of #95576 - DrMeepster:box_erasure, r=oli-obkbors-42/+72
Remove dereferencing of Box from codegen Through #94043, #94414, #94873, and #95328, I've been fixing issues caused by Box being treated like a pointer when it is not a pointer. However, these PRs just introduced special cases for Box. This PR removes those special cases and instead transforms a deref of Box into a deref of the pointer it contains. Hopefully, this is the end of the Box<T, A> ICEs.
2022-06-20Auto merge of #97931 - xldenis:fix-if-let-source-scopes, r=nagisabors-165/+179
Fix `SourceScope` for `if let` bindings. Fixes #97799. I'm not sure how to test this properly, is there any way to observe the difference in behavior apart from `ui` tests? I'm worried that they would be overlooked in the case of a regression.
2022-06-15fix inline_into_box_place testDrMeepster-19/+23
2022-06-15remove box derefs from codgenDrMeepster-25/+51
2022-06-14Only create scopes for if letXavier Denis-846/+736
2022-06-14fix wrong evaluation in clippyb-naber-6/+6
2022-06-14address reviewb-naber-27/+27
2022-06-14manually bless 32-bit mir-opt testsb-naber-25/+25
2022-06-14implement valtrees as the type-system representation for constant valuesb-naber-47/+47
2022-06-14Rename the `ConstS::val` field as `kind`.Nicholas Nethercote-2/+2
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-10Actually fixXavier Denis-756/+872
2022-06-10Revert "More minimal changes"Xavier Denis-68/+76
This reverts commit fe0dedcb06947317d41a8570b7fff7f8690dcbff.
2022-06-10More minimal changesXavier Denis-76/+68
2022-06-10Fix `SourceScope` for `if let` bindings.Xavier Denis-85/+93
2022-06-07Preserve unused pointer to address castsTomasz Miąsko-0/+28
2022-06-03Fully stabilize NLLJack Huey-216/+214
2022-06-02add cast kind of from_exposed_addr (int-to-ptr casts)Ralf Jung-1/+1
2022-06-01rename PointerAddress → PointerExposeAddressRalf Jung-4/+4
2022-05-31Auto merge of #97582 - tmiasko:pointer-address-cast, r=oli-obkbors-4/+4
Add a pointer to address cast kind A pointer to address cast are often special-cased. Introduce a dedicated cast kind to make them easy distinguishable.
2022-05-31Auto merge of #97570 - JakobDegen:dse-test, r=tmiaskobors-326/+21
Fix TLS access mir opt test and remove stale files Thanks `@pietroalbini` for noticing that the TLS test was not doing what it was supposed to. Switched to `PreCodegen` because `SimplifyCfg` does not run on opt level 0. Also addresses the easy part of #97564 . r? rust-lang/mir-opt
2022-05-31Add a pointer to address cast kindTomasz Miąsko-4/+4
A pointer to address cast are often special-cased. Introduce a dedicated cast kind to make them easy distinguishable.
2022-05-30Fix TLS access mir opt test and remove stale filesJakob Degen-326/+21
2022-05-30validate derefer, run derefer inside generatorouz-a-3/+219
2022-05-24Fix/bless tests broken by DSEJakob Degen-289/+185
2022-05-24Add dead store elimination passJakob Degen-2/+167
2022-05-23Refactor call terminator to always hold a destination placeJakob Degen-74/+76
2022-05-21update mir dumpslcnr-38/+38
2022-05-18Add mir-opt test for asm_unwind + panic=abortLuqman Aden-0/+40
2022-05-13Rollup merge of #96989 - cjgillot:defpath-use, r=davidtwcoMatthias Krüger-18/+94
Be more precise than DefPathData::Misc. This variant was used for two unrelated things. Let's make this cleaner.
2022-05-12Bless mir-opt tests.Camille GILLOT-18/+94
2022-05-12Add mir-opt test.Camille GILLOT-0/+157
2022-05-09Use `FxIndexSet` to avoid sorting fake borrowsAaron Hill-4/+4
This fixes #96449, but I haven't yet been able to make the reproducer work using `#[cfg]` attributes, so we can't use the 'revision' infra to write a test The previous implementation relied on sorting by `PlaceRef`. This requires sorting by a `DefId`, which uses untracked state (see #93315)
2022-05-06bless mir-optRalf Jung-30/+30
2022-05-04Generate an intermediate temporary for `Drop` constants.Oli Scherer-4/+12
To limit the fallout from this, don't do this for the last (or only) operand in an rvalue.
2022-04-29exp-stuff-dirtyouz-a-136/+32
2022-04-25Auto merge of #96116 - ouz-a:mir-opt, r=oli-obkbors-215/+516
Make derefer work everwhere Follow up work on previous PR's #95649 and #95857. r? rust-lang/mir-opt _Co-Authored-By: `@oli-obk_`
2022-04-25Rollup merge of #96090 - JakobDegen:mir-tests, r=nagisaMatthias Krüger-33/+123
Implement MIR opt unit tests This implements rust-lang/compiler-team#502 . There's not much to say here, this implementation does everything as proposed. I also added the flag to a bunch of existing tests (mostly those to which I could add it without causing huge diffs due to changes in line numbers). Summarizing the changes to test outputs: - Every time an `MirPatch` is created, it adds a cleanup block to the body if it did not exist already. If this block is unused (as is usually the case), it usually gets removed soon after by some pass calling `SimplifyCFG` for unrelated reasons (in many cases this cycle happens quite a few times for a single body). We now run `SimplifyCFG` less often, so those blocks end up in some of our outputs. I looked at changing `MirPatch` to not do this, but that seemed too complicated for this PR. I may still do that in a follow-up. - The `InstCombine` test had set `-C opt-level=0` in its flags and so there were no storage markers. I don't really see a good motivation for doing this, so bringing it back in line with what everything else does seems correct. - One of the `EarlyOtherwiseBranch` tests had `UnreachableProp` running on it. Preventing that kind of thing is the goal of this feature, so this seems fine. For the remaining tests for which this feature might be useful, we can gradually migrate them as opportunities present themselves. In terms of documentation, I plan on submitting a PR to the rustc dev guide in the near future documenting this and other recent changes to MIR. If there's any other places to update, do let me know r? `@nagisa`
2022-04-21Rollup merge of #96236 - Aaron1011:constraint-debug, r=jackh726Dylan DPC-13/+13
Add an explicit `Span` field to `OutlivesConstraint` Previously, we would retrieve the span from the `Body` using the `locations` field. However, we may end up changing the `locations` field when moving a constraint from a promoted to a different body. We now store the original `Span` in a dedication field, so that changes to the `locations` do not affect the quality of our diagnostics.
2022-04-20Rollup merge of #93313 - tmiasko:uninhabited, r=tmandryDylan DPC-26/+25
Check if call return type is visibly uninhabited when building MIR The main motivation behind the change is to expose information about diverging calls to the generator transform and match the precision of drop range tracking which already understands that call expressions with visibly uninhabited types diverges. This change should also accept strictly more programs than before. That is programs that were previously rejected due to errors raised by control-flow sensitive checks in a code that is no longer considered reachable. Fixes #93161.
2022-04-19Add an explicit `Span` field to `OutlivesConstraint`Aaron Hill-13/+13
Previously, we would retrieve the span from the `Body` using the `locations` field. However, we may end up changing the `locations` field when moving a constraint from a promoted to a different body. We now store the original `Span` in a dedication field, so that changes to the `locations` do not affect the quality of our diagnostics.
2022-04-16Switch some tests over to new MIR opt unit testsJakob Degen-33/+123
2022-04-16fix CI errouz-a-1/+12