summary refs log tree commit diff
path: root/src/librustc_mir/transform
AgeCommit message (Collapse)AuthorLines
2017-08-23make `for_all_relevant_impls` O(1) againAriel Ben-Yehuda-2/+1
A change in #41911 had made `for_all_relevant_impls` do a linear scan over all impls, instead of using an HashMap. Use an HashMap again to avoid quadratic blowup when there is a large number of structs with impls. I think this fixes #43141 completely, but I want better measurements in order to be sure. As a perf patch, please don't roll this up.
2017-07-12overload the mir ty methods to make them more ergonomic to useRalf Jung-31/+31
2017-07-11Refactor: {Lvalue,Rvalue,Operand}::ty only need the locals' types, not the ↵Ralf Jung-31/+31
full &Mir
2017-06-30Auto merge of #42924 - pnkfelix:mir-dataflow, r=arielb1bors-0/+869
Shift mir-dataflow from `rustc_borrowck` to `rustc_mir` crate. Shift mir-dataflow from `rustc_borrowck` to `rustc_mir` crate. Turn `elaborate_drops` and `rustc_peek` implementations into MIR passes that also live in `rustc_mir` crate. Rewire things so `rustc_driver` uses the `ElaborateDrops` from `rustc_mir` crate. (This PR is another baby step for mir-borrowck; it is a piece of work that other people want to rebase their stuff on top of, namely developers who are doing other dataflow analyses on top of MIR.) I have deliberately architected this PR in an attempt to minimize the number of actual code changes. The majority of the diff should be little more than changes to mod and use declarations, as well as a few visibility promotions to pub(crate) when a declaration was moved downward in the module hierarchy. (I have no problem with other PR's that move declarations around to try to clean this up; my goal was to ensure that the diff here was as small as possible, to make the review nearly trivial.)
2017-06-28rustc_typeck: use body-id of type-checking item in need_type_infoVenkata Giri Reddy-1/+1
2017-06-28Shift mir-dataflow from `rustc_borrowck` to `rustc_mir` crate.Felix S. Klock II-0/+869
Turn `elaborate_drops` and `rustc_peek` implementations into MIR passes that also live in `rustc_mir` crate. Rewire things so `rustc_driver` uses the `ElaborateDrops` from `rustc_mir` crate.
2017-06-28Auto merge of #42931 - arielb1:statement-visitor, r=eddybbors-2/+3
re-add the call to `super_statement` in EraseRegions The move gathering code is sensitive to type-equality - that is rather un-robust and I plan to fix it eventually, but that's a more invasive change. And we want to fix the visitor anyway. Fixes #42903. r? @eddyb
2017-06-28re-add the call to `super_statement` in EraseRegionsAriel Ben-Yehuda-2/+3
The move gathering code is sensitive to type-equality - that is rather un-robust and I plan to fix it eventually, but that's a more invasive change. And we want to fix the visitor anyway. Fixes #42903.
2017-06-27rustc: move the PolyFnSig out of TyFnDef.Eduard-Mihai Burtescu-6/+7
2017-06-19Auto merge of #39409 - pnkfelix:mir-borrowck2, r=nikomatsakisbors-0/+96
MIR EndRegion Statements (was MIR dataflow for Borrows) This PR adds an `EndRegion` statement to MIR (where the `EndRegion` statement is what terminates a borrow). An earlier version of the PR implemented a dataflow analysis on borrow expressions, but I am now factoring that into a follow-up PR so that reviewing this one is easier. (And also because there are some revisions I want to make to that dataflow code, but I want this PR to get out of WIP status...) This is a baby step towards MIR borrowck. I just want to get the review process going while I independently work on the remaining steps.
2017-06-13On-demand is_const_fnTaylor Cramer-17/+3
2017-06-12Add post-pass to remove EndRegions of unborrowed extents.Felix S. Klock II-0/+85
2017-06-12Add `EndRegion` statement kind to MIR.Felix S. Klock II-0/+11
* Emit `EndRegion` for every code-extent for which we observe a borrow. To do this, we needed to thread source info back through to `fn in_scope`, which makes this commit a bit more painful than one might have expected. * There is `end_region` emission in `Builder::pop_scope` and in `Builder::exit_scope`; the first handles falling out of a scope normally, the second handles e.g. `break`. * Remove `EndRegion` statements during the erase_regions mir transformation. * Preallocate the terminator block, and throw an `Unreachable` marker on it from the outset. Then overwrite that Terminator as necessary on demand. * Instead of marking the scope as needs_cleanup after seeing a borrow, just treat every scope in the chain as being part of the diverge_block (after any *one* of them has separately signalled that it needs cleanup, e.g. due to having a destructor to run). * Allow for resume terminators to be patched when looking up drop flags. (In particular, `MirPatch::new` has an explicit code path, presumably previously unreachable, that patches up such resume terminators.) * Make `Scope` implement `Debug` trait. * Expanded a stray comment: we do not emit StorageDead on diverging paths, but that end behavior might not be desirable.
2017-06-10rustc: make the comon case of tcx.infer_ctxt(()) nicer.Eduard-Mihai Burtescu-2/+2
2017-06-07Changing error message for interior mutability, adding ui testgaurikholkar-1/+1
2017-06-01ergonomic improvements to the methods in infcxNiko Matsakis-5/+7
2017-06-01strip param-env from infcxNiko Matsakis-10/+18
2017-06-01rewrite layout to take a (param-env, ty) pair instead of infcxNiko Matsakis-4/+2
2017-06-01move projection mode into parameter environmentNiko Matsakis-6/+6
2017-05-28fix RUST_LOG ICE caused by printing a default impl's DefIdAriel Ben-Yehuda-2/+2
2017-05-28add NullOp::SizeOf and BinOp::OffsetAriel Ben-Yehuda-4/+7
2017-05-22rename `parameter_environment` to `param_env`Niko Matsakis-4/+4
2017-05-22rename `ParameterEnvironment` to `ParamEnv`Niko Matsakis-4/+4
2017-05-22centralize the caching for is-copy, is-sized, and is-freezeNiko Matsakis-4/+4
Use the trait-environment+type as the key. Note that these are only invoked on types that live for the entire compilation (no inference artifacts). We no longer need the various special-case bits and caches that were in place before.
2017-05-13rustc: uniformly compute ParameterEnvironment's "free outlive scope".Eduard-Mihai Burtescu-5/+5
2017-05-12box large variants in MIRAriel Ben-Yehuda-12/+11
Operand: 72 -> 24 B Statement: 192 -> 96 B Terminator: 256 -> 112 B librustc translation memory usage: 1795 -> 1669 MB next step would be interning lvalues, I suppose?
2017-05-08Remove need for &format!(...) or &&"" dances in `span_label` callsOliver Schneider-8/+8
2017-05-02update comment about heuristicsNiko Matsakis-1/+3
2017-05-02move queries code into transformNiko Matsakis-6/+99
2017-05-02rename from `item_mir` to `optimized_mir`Niko Matsakis-1/+1
2017-05-02delete dead codeNiko Matsakis-89/+0
2017-05-02support inlining by asking for optimizer mir for calleesNiko Matsakis-139/+62
I tested this with it enabled 100% of the time, and we were able to run mir-opt tests successfully.
2017-05-02simplify down to one query per pass suiteNiko Matsakis-71/+30
2017-05-02rip out everything but `MirPass`, move the logic into suitesNiko Matsakis-166/+80
2017-05-02remove `Pass` and (temporarily) drop `Inline`Niko Matsakis-7/+8
2017-05-02use `force` to ensure const-qualif has been done, not readNiko Matsakis-2/+3
2017-05-02convert the `inline` pass to use the new multi resultNiko Matsakis-60/+185
This involves changing various details about that system, though the basic shape remains the same.
2017-05-02introduce idea of "stealable" MIRNiko Matsakis-26/+25
This is a more principled version of the `RefCell` we were using before. We now allocate a `Steal<Mir<'tcx>>` for each intermediate MIR pass; when the next pass steals the entry, any later attempts to use it will panic (there is no way to *test* if MIR is stolen, you're just supposed to *know*).
2017-05-02rename `MirPassSet` to `MirSuite`Niko Matsakis-19/+19
This seems like a better noun.
2017-05-02retool MIR passes completelyNiko Matsakis-50/+169
The new setup is as follows. There is a pipeline of MIR passes that each run **per def-id** to optimize a particular function. You are intended to request MIR at whatever stage you need it. At the moment, there is only one stage you can request: - `optimized_mir(def_id)` This yields the final product. Internally, it pulls the MIR for the given def-id through a series of steps. Right now, these are still using an "interned ref-cell" but they are intended to "steal" from one another: - `mir_build` -- performs the initial construction for local MIR - `mir_pass_set` -- performs a suite of optimizations and transformations - `mir_pass` -- an individual optimization within a suite So, to construct the optimized MIR, we invoke: mir_pass_set((MIR_OPTIMIZED, def_id)) which will build up the final MIR.
2017-05-02move to only def-id passesNiko Matsakis-2/+2
this temporary disables `inline`
2017-05-02introduce `DefIdPass` and remove all impls of `Pass` but `Inline`Niko Matsakis-21/+20
2017-05-02simplify the MirPass traits and passes dramaticallyNiko Matsakis-159/+134
Overall goal: reduce the amount of context a mir pass needs so that it resembles a query. - The hooks are no longer "threaded down" to the pass, but rather run automatically from the top-level (we also thread down the current pass number, so that the files are sorted better). - The hook now receives a *single* callback, rather than a callback per-MIR. - The traits are no longer lifetime parameters, which moved to the methods -- given that we required `for<'tcx>` objecs, there wasn't much point to that. - Several passes now store a `String` instead of a `&'l str` (again, no point).
2017-05-02rework `MirPass` API to be stateless and extract helper fnsNiko Matsakis-54/+28
2017-05-02introduce `mir_keys()`Niko Matsakis-38/+13
Each MIR key is a DefId that has MIR associated with it
2017-04-24rustc: use tcx.at(span) to set the location of a query.Eduard-Mihai Burtescu-3/+1
2017-04-24rustc: expose the common DUMMY_SP query case as tcx methods.Eduard-Mihai Burtescu-1/+1
2017-04-24rustc: rename some of the queries to match tcx methods.Eduard-Mihai Burtescu-2/+2
2017-04-22avoid calling `mk_region` unnecessarilyAriel Ben-Yehuda-4/+4
this improves typeck & trans performance by 1%. This looked hotter on callgrind than it is on a CPU.
2017-04-22remove cleanup branches to the resume blockAriel Ben-Yehuda-0/+34
This improves LLVM performance by 10% lost during the shimmir transition.