about summary refs log tree commit diff
path: root/src/librustc_mir/transform
AgeCommit message (Collapse)AuthorLines
2019-11-03Don't extend lifetime of temp in `Repeat` expressionsDylan MacKenzie-18/+11
2019-11-03Mark entire local as promoted even if only part is usedDylan MacKenzie-18/+16
2019-11-02Auto merge of #63810 - oli-obk:const_offset_from, r=RalfJung,nikicbors-0/+1
Make <*const/mut T>::offset_from `const fn` This reenables offset_of cc @mjbshaw after https://github.com/rust-lang/rust/pull/63075 broke it
2019-11-02Don't double-count `simd_shuffle` promotion candidatesDylan MacKenzie-0/+2
The proper attribute was added to `simd_shuffle*` in rust-lang/stdarch#825. This caused `promote_consts` to double-count its second argument when recording promotion candidates, which caused the promotion candidate compatibility check to fail.
2019-11-02Simplify various `Symbol` use points.Nicholas Nethercote-9/+9
Including removing a bunch of unnecessary `.as_str()` calls, and a bunch of unnecessary sigils.
2019-11-01Rollup merge of #65946 - ecstatic-morse:refactor-promotion2, r=eddybTyler Mandry-17/+26
Make `promote_consts` emit the errors when required promotion fails A very minimal version of #65942. This will cause a generic "argument X is required to be a constant" message for `simd_shuffle` LLVM intrinsics instead of the [custom one](https://github.com/rust-lang/rust/blob/caa1f8d7b3b021c86a70ff62d23a07d97acff4c4/src/librustc_mir/transform/qualify_consts.rs#L1616). It may be possible to remove this special-casing altogether after rust-lang/stdarch#825. r? @eddyb
2019-10-29Stop emitting error in `qualify_consts` if promotion failsDylan MacKenzie-11/+3
2019-10-29Emit errors in `promote_consts` when required promotion failsDylan MacKenzie-1/+11
2019-10-29Add method to `Candidate` that determines its promotability rulesDylan MacKenzie-5/+12
2019-10-28suggest `const_in_array_repeat_expression` flagDavid Wood-7/+39
This commit adds a suggestion to add the `#![feature(const_in_array_repeat_expression)]` attribute to the crate when a promotable expression is used in a repeat expression. Signed-off-by: David Wood <david@davidtw.co>
2019-10-28Rollup merge of #65664 - anp:panic-location, r=eddybMazdak Farrokhzad-0/+1
`std::panic::Location` is a lang_item, add `core::intrinsics::caller_location` (RFC 2091 3/N) [Tracking issue](https://github.com/rust-lang/rust/issues/47809) [RFC text](https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md) @eddyb suggested doing this intrinsic implementation ahead of actually implementing the `#[track_caller]` attribute so that there's an easily tested intermediate step between adding the shim and wiring up the attribute.
2019-10-27Implementation of const caller_location.Adam Perry-0/+1
2019-10-25Remove `QualifResolver` abstractionDylan MacKenzie-206/+112
This is a relic from earlier attempts at dataflow-based const validation that attempted to do promotion at the same time. #63812 takes a different approach: `IsNotPromotable` is no longer a `Qualif` and is computed lazily instead of eagerly. As a result, there's no need for an eager `TempPromotionResolver`, and we can use the only implementer of `QualifResolver` directly instead of through a trait.
2019-10-25Use `is_lang_panic_fn` from `check_consts` in `promote_consts`Dylan MacKenzie-8/+4
2019-10-25Deduplicate `promote_consts::Validator` and `check_consts::Item`Dylan MacKenzie-48/+30
2019-10-25Make `Item` fields pubDylan MacKenzie-5/+5
2019-10-25Make `check_consts::Item` work on non-const fnsDylan MacKenzie-120/+105
This was originally only needed for validation, which is never run on non-const `fn`s. The new promotion pass wants to use it, however.
2019-10-26rustc_mir: use the new validator's Qualif in promotion.Eduard-Mihai Burtescu-49/+120
2019-10-26rustc_mir: double-check const-promotion candidates for sanity.Eduard-Mihai Burtescu-30/+691
2019-10-25Don't cast directly from `&[T; N]` to `*const T`Matthew Jasper-1/+2
Instead coerce to `*const [T; N]` and then cast.
2019-10-25Rollup merge of #65315 - spastorino:intern-place-projection, r=oli-obkMazdak Farrokhzad-354/+419
Intern place projection This should sit on top of https://github.com/rust-lang/rust/pull/65197. After that one merged, I'm gonna rebase on top of it. The important commits are the last three and there's a bunch of code repetition that I'm going to remove but for that I need to refactor some things that probably need to be added before this PR. Anyway this work helps as is because we can run perf tests :). r? @oli-obk /cc @nikomatsakis
2019-10-23Rollup merge of #65657 - nnethercote:rm-InternedString-properly, r=eddybMazdak Farrokhzad-14/+13
Remove `InternedString` This PR removes `InternedString` by converting all occurrences to `Symbol`. There are a handful of places that need to use the symbol chars instead of the symbol index, e.g. for stable sorting; local conversions `LocalInternedString` is used in those places. r? @eddyb
2019-10-22Move Place::elem methods and friends to TyCtxtSantiago Pastorino-4/+4
2019-10-22Intern place projectionSantiago Pastorino-82/+166
2019-10-22Pattern match over PlaceRef rather than PlaceSantiago Pastorino-275/+256
This prepares the code base for when projection is interned. Place's projection field is going to be `&List<PlaceElem<'tcx>>` so we won't be able to pattern match against it.
2019-10-20Improve SimplifyLocals pass so it can remove unused constsWesley Wiser-29/+54
The `ConstProp` can cause many locals to be initialized to a constant value and then never read from. `ConstProp` can also evaluate ZSTs into constant values. Previously, many of these would be removed by other parts of the MIR optimization pipeline. However, evaluating ZSTs (especially `()`) into constant values defeated those parts of the optimizer and so in a2e3ed5c054b544df6ceeb9e612d39af819f4aae, I added a hack to `ConstProp` that skips evaluating ZSTs to avoid that regression. This commit changes `SimplifyLocals` so that it doesn't consider writes of const values to a local to be a use of that local. In doing so, `SimplifyLocals` is able to remove otherwise unused locals left behind by other optimization passes (`ConstProp` in particular).
2019-10-20Cleanup `ConstProp::visit_statement()`Wesley Wiser-10/+9
2019-10-21Convert `InternedString`s to `Symbols` in `UnsafetyViolation`.Nicholas Nethercote-14/+13
2019-10-20skip all refs-to-uninit-local, not just argumentsRalf Jung-5/+6
2019-10-19clarify const_prop ICE protection commentRalf Jung-8/+10
2019-10-19Auto merge of #64890 - wesleywiser:const_prop_rvalue, r=oli-obkbors-74/+84
[const-prop] Handle remaining MIR Rvalue cases r? @oli-obk
2019-10-19Rollup merge of #65485 - ecstatic-morse:const-validation-mismatch-ugliness, ↵Mazdak Farrokhzad-17/+58
r=eddyb Suppress ICE when validators disagree on `LiveDrop`s in presence of `&mut` Resolves #65394. This hack disables the validator mismatch ICE in cases where a `MutBorrow` error has been emitted by both validators, but they don't agree on the number of `LiveDrop` errors. The new validator is more conservative about whether a value is moved from in the presence of mutable borrows. For example, the new validator will emit a `LiveDrop` error on the following code. ```rust const _: Vec<i32> = { let mut x = Vec::new(); let px = &mut x as *mut _; let y = x; unsafe { ptr::write(px, Vec::new()); } y }; ``` This code is not UB AFAIK (it passes MIRI at least). The current validator does not emit a `LiveDrop` error for `x` upon exit from the initializer. `x` is not actually dropped, so I think this is correct? A proper fix for this would require a new `MaybeInitializedLocals` dataflow analysis or maybe a relaxation of the existing `IndirectlyMutableLocals` one. r? @RalfJung
2019-10-18Improve comments and structure of `ConstProp::const_prop()`Wesley Wiser-32/+50
Per code review feedback
2019-10-18Cleanup const_prop() someWesley Wiser-72/+75
2019-10-18[const-prop] Handle MIR Rvalue::BoxWesley Wiser-18/+1
2019-10-18Rollup merge of #65535 - eddyb:sliced-predicates, r=nikomatsakisTyler Mandry-1/+1
rustc: arena-allocate the slice in `ty::GenericsPredicate`, not the whole struct. While rebasing #59789 I noticed we can do this now. However, it doesn't help much without changing `inferred_outlives_of` to the same type, which I might try next.
2019-10-18Use Cow to handle modifications of projection in preparation for interningSantiago Pastorino-31/+34
2019-10-18[const-prop] Handle MIR Rvalue::DiscriminantWesley Wiser-2/+2
2019-10-18[const-prop] Handle MIR Rvalue::AggregatesWesley Wiser-1/+7
2019-10-18[const-prop] Handle MIR Rvalue::RepeatWesley Wiser-1/+1
2019-10-17Add process_* place hooks to improve code reutilizationSantiago Pastorino-60/+37
2019-10-17Prepare erase_regions MutVisitor to have projections internedSantiago Pastorino-1/+20
2019-10-17Prepare generator MutVisitor to have projections internedSantiago Pastorino-7/+45
2019-10-17Prepare inline MutVisitor to have projections internedSantiago Pastorino-16/+35
2019-10-17Prepare simplify MutVisitor to have projections internedSantiago Pastorino-0/+20
2019-10-17Prepare promote_consts MutVisitor to have projections internedSantiago Pastorino-1/+25
2019-10-17super_ty on MutVisitor is empty so avoid the callSantiago Pastorino-1/+0
2019-10-18rustc: arena-allocate the slice in `ty::GenericsPredicate`, not the whole ↵Eduard-Mihai Burtescu-1/+1
struct.
2019-10-16Suppress validation mismatch ICE in the presence of mut borrowsDylan MacKenzie-17/+58
2019-10-11Make <*const/mut T>::offset_from `const fn`Oliver Scherer-0/+1