about summary refs log tree commit diff
path: root/src/librustc_mir/transform
AgeCommit message (Collapse)AuthorLines
2019-10-07Auto merge of #61430 - matthewjasper:drop-on-into-panic, r=oli-obkbors-4/+1
Make `into` schedule drop for the destination closes #47949
2019-10-05Rollup merge of #65116 - spastorino:remove-unneeded-fn, r=oli-obkTyler Mandry-6/+0
Remove unneeded visit_statement definition r? @oli-obk
2019-10-04Remove unneeded visit_statement definitionSantiago Pastorino-6/+0
visit_statement default definition does just this, there's no need to redefine it.
2019-10-04clean up GeneratorSubstscsmoe-0/+1
2019-10-03Rollup merge of #65056 - spastorino:place-mut-visitor-adjusts, r=oli-obkTyler Mandry-67/+72
Make visit projection iterative r? @oli-obk /cc @nikomatsakis
2019-10-03Make visit_projection iterativeSantiago Pastorino-67/+72
2019-10-02Do not mark unitinitialized locals as requiring storageMatthew Jasper-4/+1
2019-10-02Rollup merge of #64991 - wesleywiser:fix_too_eager_const_prop, r=oli-obkMazdak Farrokhzad-29/+5
[const-prop] Correctly handle locals that can't be propagated `const_prop()` now handles writing the Rvalue into the Place in the stack frame for us. So if we're not supposed to propagate that value, we need to clear it. r? @oli-obk Fixes #64970
2019-10-02Rollup merge of #64980 - ecstatic-morse:better-rustc-peek, r=oli-obkMazdak Farrokhzad-130/+184
Enable support for `IndirectlyMutableLocals` in `rustc_peek` This PR allows `rustc_peek` tests to be written for the `IndirectlyMutableLocals` analysis implemented in #64470. See any of the tests in [`test/ui/mir-dataflow`](https://github.com/rust-lang/rust/blob/master/src/test/ui/mir-dataflow/inits-1.rs) for an example. Included in this PR is a major rewrite of the `rustc_peek` module. This was motivated by the differences between the `IndirectlyMutableLocals` analysis and the initialized places ones. To properly test `IndirectlyMutableLocals`, we must pass locals by-value to `rustc_peek`, since any local that is not `Freeze` will be marked as indirectly mutable as soon as a reference to it is taken. Unfortunately, `UnsafeCell` is not `Copy`, so we can only do one `rustc_peek` on each value with interior mutability inside a test. I'm not sure how to deal with this restriction; perhaps I need to special case borrows preceding a call to `rustc_peek` in the analysis itself? `rustc_peek` also assumed that the analysis was done on move paths and that its transfer function only needed to be applied at assignment statements. This PR removes both of those restrictions by adding a trait, `RustcPeekAt`, that controls how the peeked at `Place` maps to the current dataflow state and using a dataflow cursor to retrieve the state itself. Finally, this PR adds a test which demonstrates some unsoundness in the `IndirectlyMutableLocals` analysis by converting a reference to a `Freeze` field to a reference to a `!Freeze` field by offsetting a pointer (or in this case transmuting a pointer to a ZST field with the same address as a `!Freeze` field). This does not represent a hole in the language proper, since this analysis is only used to validate `const` bodies, in which the unsound code will only compile with `-Zunleash-the-miri-inside-of-you`. Nevertheless, this should get fixed. r? @oli-obk
2019-10-02[const-prop] Correctly handle locals that can't be propagatedWesley Wiser-29/+5
`const_prop()` now handles writing the Rvalue into the Place in the stack frame for us. So if we're not supported to propagate that value, we need to clear it.
2019-10-01Add `rustc_peek` support for `IndirectlyMutableLocals`Dylan MacKenzie-0/+32
2019-10-01Refactor `rustc_peek`Dylan MacKenzie-131/+153
We now use `DataflowResultsCursor` to get the dataflow state before calls to `rustc_peek`. The original version used a custom implementation that only looked at assignment statements. This also extends `rustc_peek` to take arguments by-value as well as by-reference, and allows *all* dataflow analyses, not just those dependent on `MoveData`, to be inspected.
2019-10-01Pass attrs to `do_dataflow` in new const checkerDylan MacKenzie-1/+1
This is needed to dump graphviz results for the `IndirectlyMutableLocals` analysis.
2019-09-30Stop printing `Qualif` results in debug logsDylan MacKenzie-4/+0
Now we can use the dataflow graphviz debugging.
2019-09-30Use separate files for debugging `Qualif` dataflow resultsDylan MacKenzie-1/+6
2019-09-30Update consumers of `generic::Engine` APIDylan MacKenzie-1/+2
2019-09-29remove indexed_vec re-export from rustc_data_structurescsmoe-14/+14
2019-09-29remove bit_set re-export from rustc_data_structurescsmoe-7/+7
2019-09-29Auto merge of #64470 - ecstatic-morse:split-promotion-and-validation, ↵bors-28/+1743
r=eddyb,oli-obk Implement dataflow-based const validation This PR adds a separate, dataflow-enabled pass that checks the bodies of `const`s, `static`s and `const fn`s for [const safety](https://github.com/rust-rfcs/const-eval/blob/master/const.md). This is based on my work in #63860, which tried to integrate into the existing pass in [`qualify_consts.rs`](https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/qualify_consts.rs). However, the resulting pass was even more unwieldy than the original. Unlike its predecessor, this PR is designed to be combined with #63812 to replace the existing pass completely. The new checker lives in [`librustc_mir/transform/check_consts`](https://github.com/ecstatic-morse/rust/tree/split-promotion-and-validation/src/librustc_mir/transform/check_consts). [`qualifs.rs`](https://github.com/ecstatic-morse/rust/blob/split-promotion-and-validation/src/librustc_mir/transform/check_consts/qualifs.rs) contains small modifications to the existing `Qualif` trait and its implementors, but is mostly unchanged except for the removal of `IsNotPromotable` and `IsNotImplicitlyPromotable`, which are only necessary for promotion. [`resolver.rs`](https://github.com/ecstatic-morse/rust/blob/split-promotion-and-validation/src/librustc_mir/transform/check_consts/resolver.rs) contains the dataflow analysis used to propagate qualifs between locals. Finally, [`validation.rs`](https://github.com/ecstatic-morse/rust/blob/split-promotion-and-validation/src/librustc_mir/transform/check_consts/validation.rs) contains a refactored version of the existing [`Visitor`](https://github.com/rust-lang/rust/blob/ca3766e2e58f462a20922e42c821a37eaf0e13db/src/librustc_mir/transform/qualify_consts.rs#L1024) in `qualfy_consts.rs`. All errors have been associated with a `struct` to make [comparison with the existing pass](https://github.com/ecstatic-morse/rust/blob/1c19f2d540ca0a964900449d79a5d5181b43146d/src/librustc_mir/transform/qualify_consts.rs#L1006) simple. The existing validation logic in [`qualify_consts`](https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/qualify_consts.rs) has been modified to allow it to run in parallel with the new validator. If [`use_new_validator`](https://github.com/rust-lang/rust/pull/64470/files#diff-c2552a106550d05b69d5e07612f0f812R950) is not set, the old validation will be responsible for actually generating the errors, but those errors can be compared with the ones from the new validator.
2019-09-28Auto merge of #64419 - wesleywiser:const_prop_use_ecx, r=oli-obkbors-218/+292
Deduplicate some code between miri and const prop r? @oli-obk
2019-09-28Rename `sty` to `kind`Dylan MacKenzie-6/+6
Picks up changes made in #64513
2019-09-28Revert "Use conservative, type-based qualifcation for statics"Dylan MacKenzie-2/+3
This reverts commit ac7a343cef8287427a98b9210cdb1a772486be10.
2019-09-28Mask results from flow-sensitive resolver with `in_any_value_of_ty`Dylan MacKenzie-1/+19
We relied previously on the caller (e.g. `Q::in_operand`) to ignore `Local`s that were indirectly mutable (and thus assumed to be qualified). However, it's much clearer (and more efficient) to do this in the resolver itself. This does not yet remove the masking done in `Q::in_operand` and others for safety's sake, although I believe that should now be possible.
2019-09-28Add description for every module in `check_consts`Dylan MacKenzie-0/+17
2019-09-28Share `IndirectlyMutableLocals` results via referenceDylan MacKenzie-26/+35
2019-09-28Require `fmt::Debug` to implement `NonConstOp`Dylan MacKenzie-4/+4
2019-09-28Use conservative, type-based qualifcation for staticsDylan MacKenzie-3/+2
2019-09-28Return a `bool` from `in_any_value_of_ty`Dylan MacKenzie-20/+12
The `Option` was only used for the promotion qualifiers, so we can use a simpler API for validation.
2019-09-28Trigger ICE on nightly if validators disagreeDylan MacKenzie-2/+19
Also adds an unstable flag to disable the ICE (`-Zsuppress-const-validation-back-compat-ice`) so that nightly users do not have to revert to a previous nightly if their code causes disagreement between the validators.
2019-09-28Move non-const ops into their own moduleDylan MacKenzie-337/+342
2019-09-28Remember to replace ICE with some form of warningDylan MacKenzie-1/+3
2019-09-28Add rationale for `suppress_errors` flagDylan MacKenzie-1/+3
2019-09-28Correct list of miri-supported operationsDylan MacKenzie-2/+2
Heap allocations are out, indirect `fn` calls are in!
2019-09-28Run new validator in compare modeDylan MacKenzie-28/+97
2019-09-28Add dataflow-based const validationDylan MacKenzie-0/+1292
2019-09-28Pass current qualification state in a separate parameterDylan MacKenzie-25/+36
2019-09-28Control whether a `Qualif` is cleared on moveDylan MacKenzie-0/+4
2019-09-28Remove reference to `Mode::NonConstFn` in qualifsDylan MacKenzie-16/+12
This should have no effect on behavior since the validator is never run in const contexts.
2019-09-28Add requisite imports and bitset to hold qualifsDylan MacKenzie-1/+19
2019-09-28Make new qualifs publicDylan MacKenzie-3/+3
2019-09-28Remove unnecessary methodDylan MacKenzie-10/+0
2019-09-28Copy `Qualif` to start work on new const validatorDylan MacKenzie-0/+271
This is an exact copy of the `Qualif` trait from `qualify_consts.rs` and its first two implementers, `HasMutInterior` and `NeedsDrop`.
2019-09-28Silence "skipping const checks" if outside a const contextDylan MacKenzie-1/+3
2019-09-28Allow reading non-mutable statics in const propWesley Wiser-5/+11
2019-09-27Introduce a `ConstPropMachine`Wesley Wiser-8/+149
This allows us to avoid changing things directly in the miri engine just for const prop.
2019-09-27Move Ref-from-arg checking from `step.rs` to `const_prop.rs`Wesley Wiser-80/+93
2019-09-27Respond to code review feedback and fix tidyWesley Wiser-13/+20
2019-09-27Don't run the ConstProp MIR pass on generatorsWesley Wiser-0/+8
This can cause cycles as `ConstProp` uses `layout_of` which, for generators, uses `optimized_mir` which runs `ConstProp`.
2019-09-27[const-prop] Replace `Ref` handling with use of `InterpCx`Wesley Wiser-6/+2
2019-09-27[const-prop] Replace some `Binaryp` handling with use of `InterpCx`Wesley Wiser-38/+24