summary refs log tree commit diff
path: root/src/librustc_mir/dataflow/impls
AgeCommit message (Collapse)AuthorLines
2020-04-09Make `MaybeStorageLive` correct for all kinds of MIR bodiesDylan MacKenzie-5/+17
Before, it ignored the first argument and marked all variables without `Storage*` annotations as dead.
2020-04-02nix rustc_target::abi::* reexport in ty::layoutMazdak Farrokhzad-1/+1
2020-03-31Use Place directly on Operand::place and friends, it's CopySantiago Pastorino-10/+10
2020-03-31Use Place directly, it's Copy even more use casesSantiago Pastorino-9/+9
2020-03-31Use Place directly, it's CopySantiago Pastorino-6/+6
2020-03-30Use if let instead of match when only matching a single variant ↵Matthias Krüger-12/+9
(clippy::single_match) Makes code more compact and reduces nestig.
2020-03-30rustc -> rustc_middle part 3 (rustfmt)Mazdak Farrokhzad-2/+2
2020-03-30rustc -> rustc_middle part 2Mazdak Farrokhzad-11/+11
2020-03-29Use `&` to do deref coercion for `ReadOnlyBodyAndCache`Dylan MacKenzie-2/+2
2020-03-29Make `Visitor::visit_body` take a simple `Body`Dylan MacKenzie-1/+1
2020-03-27Auto merge of #68404 - Amanieu:llvm-asm, r=estebankbors-2/+2
Rename asm! to llvm_asm! As per https://github.com/rust-lang/rfcs/pull/2843, this PR renames `asm!` to `llvm_asm!`. It also renames the compiler's internal `InlineAsm` data structures to `LlvmInlineAsm` in preparation for the new `asm!` functionality specified in https://github.com/rust-lang/rfcs/pull/2850. This PR doesn't actually deprecate `asm!` yet, it just makes it redirect to `llvm_asm!`. This is necessary because we first need to update the submodules (in particular stdarch) to use `llvm_asm!`.
2020-03-26Update imports from `dataflow::generic` to `dataflow`Dylan MacKenzie-7/+6
2020-03-26Rename asm! to llvm_asm!Amanieu d'Antras-2/+2
asm! is left as a wrapper around llvm_asm! to maintain compatibility.
2020-03-06Model generator resumption in dataflowJonas Schievink-2/+16
We now have a way to apply an effect only *after* a `yield` resumes, similar to calls (which can either return or unwind).
2020-03-01Auto merge of #69295 - ecstatic-morse:unified-dataflow-generators, r=tmandrybors-88/+105
Use new dataflow framework for generators #65672 introduced a new dataflow framework that can handle arbitrarily complex transfer functions as well as ones expressed as a series of gen/kill operations. This PR ports the analyses used to implement generators to the new framework so that we can remove the old one. See #68241 for a prior example of this. The new framework has some superficial API changes, but this shouldn't alter the generator passes in any way. r? @tmandry
2020-02-29use .iter() instead of .into_iter() on references.Matthias Krüger-1/+1
2020-02-27Rename `RequiresStorage` to `MaybeRequiresStorage`Dylan MacKenzie-7/+7
...to be consistent with the naming of other dataflow analyses.
2020-02-27Port `RequiresStorage` to new dataflow frameworkDylan MacKenzie-51/+70
2020-02-27Port `MaybeStorageLive` to new dataflow frameworkDylan MacKenzie-33/+31
2020-02-27Auto merge of #68528 - ecstatic-morse:maybe-init-variants, r=oli-obkbors-2/+35
Mark other variants as uninitialized after switch on discriminant During drop elaboration, which builds the drop ladder that handles destruction during stack unwinding, we attempt to remove MIR `Drop` terminators that will never be reached in practice. This reduces the number of basic blocks that are passed to LLVM, which should improve performance. In #66753, a user pointed out that unreachable `Drop` terminators are common in functions like `Option::unwrap`, which move out of an `enum`. While discussing possible remedies for that issue, @eddyb suggested moving const-checking after drop elaboration. This would allow the former, which looks for `Drop` terminators and replicates a small amount of drop elaboration to determine whether a dropped local has been moved out, leverage the work done by the latter. However, it turns out that drop elaboration is not as precise as it could be when it comes to eliminating useless drop terminators. For example, let's look at the code for `unwrap_or`. ```rust fn unwrap_or<T>(opt: Option<T>, default: T) -> T { match opt { Some(inner) => inner, None => default, } } ``` `opt` never needs to be dropped, since it is either moved out of (if it is `Some`) or has no drop glue (if it is `None`), and `default` only needs to be dropped if `opt` is `Some`. This is not reflected in the MIR we currently pass to codegen. ![pasted_image](https://user-images.githubusercontent.com/29463364/73384403-109a0d80-4280-11ea-8500-0637b368f2dc.png) @eddyb also suggested the solution to this problem. When we switch on an enum discriminant, we should be marking all fields in other variants as definitely uninitialized. I implemented this on top of alongside a small optimization (split out into #68943) that suppresses drop terminators for enum variants with no fields (e.g. `Option::None`). This is the resulting MIR for `unwrap_or`. ![after](https://user-images.githubusercontent.com/29463364/73384823-e432c100-4280-11ea-84bd-d0bcc3b777b4.png) In concert with #68943, this change speeds up many [optimized and debug builds](https://perf.rust-lang.org/compare.html?start=d55f3e9f1da631c636b54a7c22c1caccbe4bf0db&end=0077a7aa11ebc2462851676f9f464d5221b17d6a). We need to carefully investigate whether I have introduced any miscompilations before merging this. Code that never drops anything would be very fast indeed until memory is exhausted.
2020-02-19Handle resume args in `RequiresStorage` analysisJonas Schievink-11/+46
2020-02-19Use match ergonomics to simplify matchJonas Schievink-5/+5
2020-02-19Match MIR statements exhaustivelyJonas Schievink-1/+8
2020-02-17Fix typo in commentDylan MacKenzie-1/+1
2020-02-17Use doc comment for explanation of `shared_borrow_allows_mutation`Dylan MacKenzie-9/+9
2020-02-13Kill move paths of dead variantsDylan MacKenzie-2/+35
2020-02-13Ignore mut borrow from drop terminator in const-evalDylan MacKenzie-12/+33
2020-02-13Rename `MaybeBorrowedLocals` constructorsDylan MacKenzie-2/+5
2020-02-12Use `MaybeBorrowedLocals` for generator analysesDylan MacKenzie-26/+20
It should have the same semantics as `HaveBeenBorrowedLocals`
2020-02-12Remove outdated `IndirectlyMutableLocals`Dylan MacKenzie-138/+0
`MaybeMutBorrowedLocals` serves the same purpose and has a better name.
2020-02-12Implement `Maybe{Mut,}BorrowedLocals` analysesDylan MacKenzie-60/+208
2020-02-11Use new dataflow framework for drop elaboration and borrow checkingDylan MacKenzie-7/+1
2020-02-10Use new dataflow interface for initialization/borrows analysesDylan MacKenzie-108/+195
2020-02-02Add a resume type parameter to `Generator`Jonas Schievink-8/+12
2020-01-10Remove PlaceBase enum and make Place base field be local: LocalSantiago Pastorino-56/+37
2020-01-10Remove Static from PlaceBaseSantiago Pastorino-36/+38
2020-01-10Remove unused param_env parameterSantiago Pastorino-5/+1
2020-01-06Improve hygiene of `newtype_index`Matthew Jasper-1/+1
Also add unit tests
2020-01-01Rename `syntax_pos` to `rustc_span` in source codeVadim Petrochenkov-1/+1
2019-12-22Format the worldMark Rousskov-275/+232
2019-12-11more privateMark Mansi-8/+4
2019-12-11fix importsMark Mansi-6/+8
2019-12-05rustc: Apply clearer naming to BodyAndCache, fix Deref impl, remove unneeded ↵Paul Daniel Faria-3/+3
Index impl, remove body fn rustc_codegen_ssa: Fix BodyAndCache reborrow to Body and change instances of body() call to derefence rustc_mir: Fix BodyAndCache reborrow to Body and change intances of body() call to derefence
2019-12-02Remove HasLocalDecls impl from BodyCache's, properly reborrow to Body, ↵Paul Daniel Faria-17/+17
rename all body_cache back to body
2019-12-02Fix tidy errorsPaul Daniel Faria-1/+3
2019-12-02Simplify BodyCache impl and fix all remaining type errors in librustc_mir ↵Paul Daniel Faria-4/+4
(lifetime errors still exist)
2019-12-02Add predecessors fn to ReadOnlyBodyCache, fix more Body -> ↵Paul Daniel Faria-11/+11
(ReadOnly)BodyCache type errors
2019-12-02Stop invalidating predecessors cache when accessing unique basic block, ↵Paul Daniel Faria-1/+1
invalidate cache when accessing unique terminator
2019-11-21Track pointers to statics in MIRMatthew Jasper-1/+3
2019-10-22Pattern match over PlaceRef rather than PlaceSantiago Pastorino-2/+4
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.