about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/util
AgeCommit message (Collapse)AuthorLines
2021-09-07Rename rustc_mir to rustc_const_eval.Camille GILLOT-225/+0
2021-09-07Move the dataflow framework to its own crate.Camille GILLOT-3392/+0
2021-09-07Move rustc_mir::transform to rustc_mir_transform.Camille GILLOT-3/+3
2021-09-07Move rustc_mir::borrow_check to new crate rustc_borrowck.Camille GILLOT-491/+3
2021-08-26Auto merge of #87280 - lcnr:lazy-anon-const-default-substs, r=nikomatsakisbors-1/+7
lazily "compute" anon const default substs Continuing the work of #83086, this implements the discussed solution for the [unused substs problem](https://github.com/rust-lang/project-const-generics/blob/master/design-docs/anon-const-substs.md#unused-substs). As of now, anonymous constants inherit all of their parents generics, even if they do not use them, e.g. in `fn foo<T, const N: usize>() -> [T; N + 1]`, the array length has `T` as a generic parameter even though it doesn't use it. These *unused substs* cause some backwards incompatible, and imo incorrect behavior, e.g. #78369. --- We do not actually filter any generic parameters here and the `default_anon_const_substs` query still a dummy which only checks that - we now prevent the previously existing query cycles and are able to call `predicates_of(parent)` when computing the substs of anonymous constants - the default anon consts substs only include the typeflags we assume it does. Implementing that filtering will be left as future work. --- The idea of this PR is to delay the creation of the anon const substs until after we've computed `predicates_of` for the parent of the anon const. As the predicates of the parent can however contain the anon const we still have to create a `ty::Const` for it. We do this by changing the substs field of `ty::Unevaluated` to an option and modifying accesses to instead call the method `unevaluated.substs(tcx)` which returns the substs as before. If the substs - now `substs_` - of `ty::Unevaluated` are `None`, it means that the anon const currently has its default substs, i.e. the substs it has when first constructed, which are the generic parameters it has available. To be able to call `unevaluated.substs(tcx)` in a `TypeVisitor`, we add the non-defaulted method `fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>>`. In case `tcx_for_anon_const_substs` returns `None`, unknown anon const default substs are skipped entirely. Even when `substs_` is `None` we still have to treat the constant as if it has its default substs. To do this, `TypeFlags` are modified so that it is clear whether they can still change when *exposing* any anon const default substs. A new flag, `HAS_UNKNOWN_DEFAULT_CONST_SUBSTS`, is added in case some default flags are missing. The rest of this PR are some smaller changes to either not cause cycles by trying to access the default anon const substs too early or to be able to access the `tcx` in previously unused locations. cc `@rust-lang/project-const-generics` r? `@nikomatsakis`
2021-08-26make unevaluated const substs optionallcnr-3/+5
2021-08-26require a `tcx` for `TypeVisitor`lcnr-0/+4
2021-08-24Morph `layout_raw` query into `layout_of`.Eduard-Mihai Burtescu-1/+1
2021-08-18Rollup merge of #88129 - willcrichton:expose-graphviz-modules, r=ecstatic-morseGuillaume Gomez-1/+1
Fix dataflow graphviz bug, make dataflow graphviz modules public I'm working on a rustc plugin that uses the dataflow framework for MIR analysis. I've found the graphviz utilities extremely helpful for debugging. However, I had to fork the compiler to expose them since they're currently private. I would appreciate if they could be made public so I can build against a nightly instead of a custom fork. Specifically, this PR: * Makes public the `rustc_mir::dataflow::framework::graphviz` module. * Makes public the `rustc_mir::util::pretty::write_mir_fn` function. Here's a concrete example of how I'm using the graphviz module: https://github.com/willcrichton/flowistry/blob/97b843b8b06b4004fbb79b5fcfca3e33c7143bc0/src/slicing/mod.rs#L186-L203 Additionally, this PR fixes a small bug in the diff code that incorrectly shows the updated object as the old object. r? `@ecstatic-morse`
2021-08-18Remove box syntax from rustc_mirest31-11/+20
2021-08-17Expose graphviz modulesWill Crichton-1/+1
2021-07-25clippy::useless_formatMatthias Krüger-1/+1
2021-07-14consistently treat None-tagged pointers as ints; get rid of some deprecated ↵Ralf Jung-1/+1
Scalar methods
2021-07-14CTFE/Miri engine Pointer type overhaul: make Scalar-to-Pointer conversion ↵Ralf Jung-9/+9
infallible This resolves all the problems we had around "normalizing" the representation of a Scalar in case it carries a Pointer value: we can just use Pointer if we want to have a value taht we are sure is already normalized.
2021-07-01Auto merge of #86304 - klensy:hex-length, r=jackh726bors-1/+21
rustc_mir: calc hex number length without string allocation
2021-07-01rustc_mir: calc hex number length without string allocationklensy-1/+21
2021-06-23Use `use_verbose` for mir::ConstantDeadbeef-27/+19
2021-06-17Rollup merge of #85870 - ptrojahn:mir_dump_whitespace, r=davidtwcoYuki Okushi-1/+4
Allow whitespace in dump_mir filter At least on my system this is necessary to get more complex filters with spaces like in https://rustc-dev-guide.rust-lang.org/mir/debugging.html working.
2021-06-01Allow whitespace in dump_mir filterPaul Trojahn-1/+4
2021-05-30Remove CrateNum::ReservedForIncrCompCachebjorn3-1/+0
2021-05-17remove size field from AllocationRalf Jung-6/+6
2021-05-17Auto merge of #85178 - cjgillot:local-crate, r=oli-obkbors-2/+2
Remove CrateNum parameter for queries that only work on local crate The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea. Using `()` as query key in those cases avoids having to worry about the validity of the query key.
2021-05-12Spanview needs the relevant body_span used for coverageRich Kadel-7/+7
The coverage body_span doesn't always match the function body_span.
2021-05-12Use () for mir_keys.Camille GILLOT-2/+2
2021-05-11Split span_to_string into span_to_diagnostic/embeddable_stringAndy Wang-5/+8
2021-04-28spanview debug output caused ICE when a function had no bodyRich Kadel-9/+10
2021-04-19fix few typosklensy-1/+1
2021-04-02Auto merge of #83207 - oli-obk:valtree2, r=lcnrbors-2/+20
normalize mir::Constant differently from ty::Const in preparation for valtrees Valtrees are unable to represent many kind of constant values (this is on purpose). For constants that are used at runtime, we do not need a valtree representation and can thus use a different form of evaluation. In order to make this explicit and less fragile, I added a `fold_constant` method to `TypeFolder` and implemented it for normalization. Normalization can now, when it wants to eagerly evaluate a constant, normalize `mir::Constant` directly into a `mir::ConstantKind::Val` instead of relying on the `ty::Const` evaluation. In the future we can get rid of the `ty::Const` in there entirely and add our own `Unevaluated` variant to `mir::ConstantKind`. This would allow us to remove the `promoted` field from `ty::ConstKind::Unevaluated`, as promoteds can never occur in the type system. cc `@rust-lang/wg-const-eval` r? `@lcnr`
2021-03-31Add a new normalization query just for mir constantsOli Scherer-1/+5
2021-03-31Make unevaluated DefId rendering deterministicOli Scherer-1/+15
2021-03-29Auto merge of #83185 - jyn514:remove-dead-code, r=oli-obkbors-26/+0
Remove (lots of) dead code Builds on - [ ] https://github.com/rust-lang/rust/pull/83161 - [x] https://github.com/rust-lang/rust/pull/83230 - [x] https://github.com/rust-lang/rust/pull/83197. Found with https://github.com/est31/warnalyzer. See https://github.com/rust-lang/rust/pull/77739 for a similar change in the past. Dubious changes: - Maybe some of the dead code in rustc_data_structures should be kept, in case someone wants to use it in the future? TODO: - [ ] check if any of the comments on the deleted code should be kept. - [x] update the compiler documentation; right now it fails to build - [x] finish moving `cfg(test)` changes into https://github.com/rust-lang/rust/pull/83197 cc `@est31`
2021-03-28unaligned_references: align(N) fields in packed(N) structs are fineRalf Jung-11/+24
2021-03-27Address review commentsJoshua Nelson-6/+0
- Add back `HirIdVec`, with a comment that it will soon be used. - Add back `*_region` functions, with a comment they may soon be used. - Remove `-Z borrowck_stats` completely. It didn't do anything. - Remove `make_nop` completely. - Add back `current_loc`, which is used by an out-of-tree tool. - Fix style nits - Remove `AtomicCell` with `cfg(parallel_compiler)` for consistency.
2021-03-27Remove (lots of) dead codeJoshua Nelson-20/+0
Found with https://github.com/est31/warnalyzer. Dubious changes: - Is anyone else using rustc_apfloat? I feel weird completely deleting x87 support. - Maybe some of the dead code in rustc_data_structures, in case someone wants to use it in the future? - Don't change rustc_serialize I plan to scrap most of the json module in the near future (see https://github.com/rust-lang/compiler-team/issues/418) and fixing the tests needed more work than I expected. TODO: check if any of the comments on the deleted code should be kept.
2021-03-15s/ConstantSource/ConstantKind/Oli Scherer-2/+2
2021-03-12Prepare mir::Constant for ty::Const only supporting valtreesOli Scherer-5/+10
2021-03-09Update match brancheskadmin-0/+1
This updates all places where match branches check on StatementKind or UseContext. This doesn't properly implement them, but adds TODOs where they are, and also adds some best guesses to what they should be in some cases.
2021-03-08Auto merge of #82727 - oli-obk:shrinkmem, r=pnkfelixbors-4/+10
Test the effect of shrinking the size of Rvalue by 16 bytes r? `@ghost`
2021-03-05Shrink the size of Rvalue by 16 bytesOli Scherer-4/+10
2021-03-01Box generator-related Body fieldsDániel Buga-2/+2
2021-02-26Miscellaneous inlining improvementsTomasz Miąsko-0/+1
Inline a few small and hot functions.
2021-02-22Fix mir-cfg dumpsÖmer Sinan Ağacan-5/+18
Fixes #81918 Fixes #82326 (duplicate) Fixes #82325
2021-02-17Remove redundant rustc_data_structures path componentest31-4/+4
2021-02-13Fix MIR pretty printer for non-local DefIdsÖmer Sinan Ağacan-13/+13
2021-01-27Visit only statements in always live localsTomasz Miąsko-19/+12
No functional changes intended.
2021-01-16Use PlaceRef more consistently in rustc_mirOlivia Crain-5/+2
2021-01-11--emit=mir now emits both `mir_for_ctfe` and `optimized_mir` for `const fn`oli-11/+21
2021-01-05Remove a FIXME and explain the decisionoli-1/+2
2021-01-04Keep an unoptimized duplicate of `const fn` aroundoli-1/+5
This allows CTFE to reliably detect UB, as otherwise optimizations may hide UB.
2020-12-25Rollup merge of #79999 - hencrice:yenlinc/79799, r=oli-obkDylan DPC-11/+17
Refactored verbose print into a function Also handle Tuple and Array separately, which was not explicitly checked. Fixes #79799.