summary refs log tree commit diff
path: root/src/librustc_mir/transform
AgeCommit message (Collapse)AuthorLines
2017-01-30Merge ty::TyBox into ty::TyAdtVadim Petrochenkov-3/+4
2017-01-26rustc: rename TyCtxt's `map` field to `hir`.Eduard-Mihai Burtescu-9/+9
2017-01-11fix function arguments in constant promotionAriel Ben-Yehuda-13/+15
we can't create the target block until *after* we promote the arguments - otherwise the arguments will be promoted into the target block. oops. Fixes #38985.
2017-01-08Auto merge of #38837 - eddyb:issue-38074, r=nikomatsakisbors-13/+12
Allow projections to be promoted to constants in MIR. This employs the `LvalueContext` additions by @pcwalton to properly extend the MIR promotion of temporaries to allow projections (field accesses, indexing and dereferences) on said temporaries. It's needed both parity with the old constant qualification logic (for current borrowck) and it fixes #38074. The former is *required for soundness* if we accept the RFC for promoting rvalues to `'static` constants. That is, until we get MIR borrowck and the same source of truth will be used for both checks and codegen.
2017-01-06rustc: keep track of tables everywhere as if they were per-body.Eduard-Mihai Burtescu-2/+2
2017-01-05Allow projections to be promoted to constants in MIR.Eduard-Mihai Burtescu-13/+12
2017-01-05fix promotion of MIR terminatorsAriel Ben-Yehuda-79/+67
promotion of MIR terminators used to try to promote the destination it is trying to promote, leading to stack overflow. Fixes #37991.
2016-12-14Auto merge of #38332 - bluss:copy-prop-arguments, r=eddybbors-4/+6
Allow copy-propagation of function arguments Allow propagating function argument locals in copy propagation.
2016-12-12Auto merge of #38307 - bluss:mir-opt-level, r=eddybbors-13/+9
Simplify use of mir_opt_level Remove the unused top level option by the same name, and retain the debug option. Use -Zmir-opt-level=1 as default. One pass is enabled by default but wants to be optional: - Instcombine requires mir_opt_level > 0 Copy propagation is not used by default, but used to be activated by explicit -Zmir-opt-level=1. It must move one higher to be off by default: - CopyPropagation requires mir_opt_level > 1 Deaggregate is not used by default, and used to be on a different level than CopyPropagation: - Deaggreate requires mir_opt_level > 2
2016-12-11mir: Allow copy-propagation of function argumentsUlrik Sverdrup-4/+6
2016-12-11Simplify use of mir_opt_levelUlrik Sverdrup-13/+9
Remove the unused top level option by the same name, and retain the debug option. Use -Zmir-opt-level=1 as default. One pass is enabled by default but wants to be optional: - Instcombine requires mir_opt_level > 0 Copy propagation is not used by default, but used to be activated by explicit -Zmir-opt-level=1. It must move one higher to be off by default: - CopyPropagation requires mir_opt_level > 1 Deaggregate is not used by default, and used to be on a different level than CopyPropagation: - Deaggreate requires mir_opt_level > 2
2016-12-09mir: Reinstate while loop in deaggregator passUlrik Sverdrup-59/+58
A previous commit must have removed the `while let` loop here by mistake; for each basic block, it should find and deaggregate multiple statements in their index order, and the `curr` index tracks the progress through the block. This fixes both the case of deaggregating statements in separate basic blocks (preserving `curr` could prevent that) as well as multiple times in the same block (missing loop prevented that).
2016-12-05Refactor FnSig to contain a Slice for its inputs and outputs.Mark-Simulacrum-1/+1
2016-12-05Refactor ty::FnSig to privatize all fieldsMark-Simulacrum-8/+8
2016-11-29Auto merge of #37965 - Mark-Simulacrum:trait-obj-to-exis-predicate, r=eddybbors-1/+4
Refactor TraitObject to Slice<ExistentialPredicate> For reference, the primary types changes in this PR are shown below. They may add in the understanding of what is discussed below, though they should not be required. We change `TraitObject` into a list of `ExistentialPredicate`s to allow for a couple of things: - Principal (ExistentialPredicate::Trait) is now optional. - Region bounds are moved out of `TraitObject` into `TyDynamic`. This permits wrapping only the `ExistentialPredicate` list in `Binder`. - `BuiltinBounds` and `BuiltinBound` are removed entirely from the codebase, to permit future non-constrained auto traits. These are replaced with `ExistentialPredicate::AutoTrait`, which only requires a `DefId`. For the time being, only `Send` and `Sync` are supported; this constraint can be lifted in a future pull request. - Binder-related logic is extracted from `ExistentialPredicate` into the parent (`Binder<Slice<EP>>`), so `PolyX`s are inside `TraitObject` are replaced with `X`. The code requires a sorting order for `ExistentialPredicate`s in the interned `Slice`. The sort order is asserted to be correct during interning, but the slices are not sorted at that point. 1. `ExistentialPredicate::Trait` are defined as always equal; **This may be wrong; should we be comparing them and sorting them in some way?** 1. `ExistentialPredicate::Projection`: Compared by `ExistentialProjection::sort_key`. 1. `ExistentialPredicate::AutoTrait`: Compared by `TraitDef.def_path_hash`. Construction of `ExistentialPredicate`s is conducted through `TyCtxt::mk_existential_predicates`, which interns a passed iterator as a `Slice`. There are no convenience functions to construct from a set of separate iterators; callers must pass an iterator chain. The lack of convenience functions is primarily due to few uses and the relative difficulty in defining a nice API due to optional parts and difficulty in recognizing which argument goes where. It is also true that the current situation isn't significantly better than 4 arguments to a constructor function; but the extra work is deemed unnecessary as of this time. ```rust // before this PR struct TraitObject<'tcx> { pub principal: PolyExistentialTraitRef<'tcx>, pub region_bound: &'tcx ty::Region, pub builtin_bounds: BuiltinBounds, pub projection_bounds: Vec<PolyExistentialProjection<'tcx>>, } // after pub enum ExistentialPredicate<'tcx> { // e.g. Iterator Trait(ExistentialTraitRef<'tcx>), // e.g. Iterator::Item = T Projection(ExistentialProjection<'tcx>), // e.g. Send AutoTrait(DefId), } ```
2016-11-29Save bodies of functions for inlining into other cratesFlorian Diebold-10/+4
This is quite hacky and I hope to refactor it a bit, but at least it seems to work.
2016-11-28Adds TyCtxt::require_lang_item(LangItem) to simplify lang item requires.Mark-Simulacrum-3/+1
Replaces instances of tcx.lang_items.require(..) with fatal unwrap with this method.
2016-11-28Remove BuiltinBound and BuiltinBounds.Mark-Simulacrum-1/+6
2016-11-17Auto merge of #37660 - nikomatsakis:incremental-36349, r=eddybbors-2/+6
Separate impl items from the parent impl This change separates impl item bodies out of the impl itself. This gives incremental more resolution. In so doing, it refactors how the visitors work, and cleans up a bit of the collect/check logic (mostly by moving things out of collect that didn't really belong there, because they were just checking conditions). However, this is not as effective as I expected, for a kind of frustrating reason. In particular, when invoking `foo.bar()` you still wind up with dependencies on private items. The problem is that the method resolution code scans that list for methods with the name `bar` -- and this winds up touching *all* the methods, even private ones. I can imagine two obvious ways to fix this: - separating fn bodies from fn sigs (#35078, currently being pursued by @flodiebold) - a more aggressive model of incremental that @michaelwoerister has been advocating, in which we hash the intermediate results (e.g., the outputs of collect) so that we can see that the intermediate result hasn't changed, even if a particular impl item has changed. So all in all I'm not quite sure whether to land this or not. =) It still seems like it has to be a win in some cases, but not with the test cases we have just now. I can try to gin up some test cases, but I'm not sure if they will be totally realistic. On the other hand, some of the early refactorings to the visitor trait seem worthwhile to me regardless. cc #36349 -- well, this is basically a fix for that issue, I guess r? @michaelwoerister NB: Based atop of @eddyb's PR https://github.com/rust-lang/rust/pull/37402; don't land until that lands.
2016-11-17Auto merge of #37717 - nikomatsakis:region-obligations-pre, r=eddybbors-21/+32
Refactoring towards region obligation Two refactorings towards the intermediate goal of propagating region obligations through the `InferOk` structure (which in turn leads to the possibility of lazy normalization). 1. Remove `TypeOrigin` and add `ObligationCause` - as we converge subtyping and obligations and so forth, the ability to keep these types distinct gets harder 2. Propagate obligations from `InferOk` into the surrounding fulfillment context After these land, I have a separate branch (which still needs a bit of work) that can make the actual change to stop directly adding subregion edges and instead propagate obligations. (This should also make it easier to fix the unsoundness in specialization around lifetimes.) r? @eddyb
2016-11-16include a Name and Span for each item in the HIR of the implNiko Matsakis-6/+6
2016-11-16fallout from separating impl-items from implsNiko Matsakis-2/+6
Basically adding `visit_impl_item` in various places and so forth.
2016-11-15register `infer-ok` obligations properlyNiko Matsakis-16/+21
Or at least, more properly. I think I left one or two FIXMEs still in there. cc #32730
2016-11-15remove TypeOrigin and use ObligationCause insteadNiko Matsakis-6/+12
In general having all these different structs for "origins" is not great, since equating types can cause obligations and vice-versa. I think we should gradually collapse these things. We almost certainly also need to invest a big more energy into the `error_reporting` code to rationalize it: this PR does kind of the minimal effort in that direction.
2016-11-14Remove `scope_auxiliary`.Nicholas Nethercote-2/+1
This reduces the peak RSS for a cut-down version of the program in #36799 by 10%, from 951MB to 856MB.
2016-11-12rustc: move closure upvar types to the closure substsAriel Ben-Yehuda-3/+9
This moves closures to the (DefId, Substs) scheme like all other items, and saves a word from the size of TyS now that Substs is 2 words.
2016-11-10rustc: clean up lookup_item_type and remove TypeScheme.Eduard Burtescu-1/+1
2016-11-08Replace FnvHasher use with FxHasher.Nicholas Nethercote-2/+2
This speeds up compilation by 3--6% across most of rustc-benchmarks.
2016-11-03A way to remove otherwise unused locals from MIRSimonas Kazlauskas-15/+105
Replaces the hack where a similar thing is done within trans.
2016-10-28rustc: move the MIR map into TyCtxt.Eduard Burtescu-105/+74
2016-10-28rustc: move mir::repr::* to mir.Eduard Burtescu-15/+14
2016-10-06Rollup merge of #36959 - arielb1:simplify-cfg-fixes, r=eddybJonathan Turner-2/+13
fix pred_count accounting in SimplifyCfg r? @eddyb
2016-10-04Remove some unused methods from metadataVadim Petrochenkov-5/+1
Address comments + Fix rebase
2016-10-04Eliminate ty::VariantKind in favor of def::CtorKindVadim Petrochenkov-2/+2
2016-10-04SimplifyCfg: don't incref target when collapsing a goto with 1 predAriel Ben-Yehuda-2/+10
2016-10-04SimplifyCfg: simplify the start blockAriel Ben-Yehuda-0/+3
2016-09-26Fix tidyJonas Schievink-1/+4
2016-09-26promote_consts: make assign take a LocalJonas Schievink-4/+4
2016-09-26Rename MIR local iterators to match conventionJonas Schievink-2/+2
2016-09-26[WIP] Move MIR towards a single kind of localJonas Schievink-128/+141
2016-09-24librustc_mir: Propagate constants during copy propagation.Patrick Walton-59/+213
This optimization kicks in a lot when bootstrapping the compiler.
2016-09-21Auto merge of #36551 - eddyb:meta-games, r=nikomatsakisbors-1/+2
Refactor away RBML from rustc_metadata. RBML and `ty{en,de}code` have had their long-overdue purge. Summary of changes: * Metadata is now a tree encoded in post-order and with relative backward references pointing to children nodes. With auto-deriving and type safety, this makes maintenance and adding new information to metadata painless and bug-free by default. It's also more compact and cache-friendly (cache misses should be proportional to the depth of the node being accessed, not the number of siblings as in EBML/RBML). * Metadata sizes have been reduced, for `libcore` it went down 16% (`8.38MB` -> `7.05MB`) and for `libstd` 14% (`3.53MB` -> `3.03MB`), while encoding more or less the same information * Specialization is used in the bundled `libserialize` (crates.io `rustc_serialize` remains unaffected) to customize the encoding (and more importantly, decoding) of various types, most notably those interned in the `TyCtxt`. Some of this abuses a soundness hole pending a fix (cc @aturon), but when that fix arrives, we'll move to macros 1.1 `#[derive]` and custom `TyCtxt`-aware serialization traits. * Enumerating children of modules from other crates is now orthogonal to describing those items via `Def` - this is a step towards bridging crate-local HIR and cross-crate metadata * `CrateNum` has been moved to `rustc` and both it and `NodeId` are now newtypes instead of `u32` aliases, for specializing their decoding. This is `[syntax-breaking]` (cc @Manishearth ). cc @rust-lang/compiler
2016-09-20rustc_metadata: go only through rustc_serialize in astencode.Eduard Burtescu-1/+2
2016-09-19librustc: Implement def-use chains and trivial copy propagation on MIR.Patrick Walton-3/+186
This only supports trivial cases in which there is exactly one def and one use.
2016-09-19librustc: Add a new nop statement to the MIR.Patrick Walton-1/+3
This is useful when passes want to remove statements without affecting `Location`s.
2016-09-16librustc_mir: Remove `&*x` when `x` has a reference type.Patrick Walton-0/+112
This introduces a new `InstCombine` pass for us to place such peephole optimizations.
2016-09-08Refactor `TyStruct`/`TyEnum`/`TyUnion` into `TyAdt`Vadim Petrochenkov-9/+7
2016-09-06Count and report time taken by MIR passesSimonas Kazlauskas-4/+4
2016-09-04Auto merge of #36203 - petrochenkov:uvsdot, r=nrcbors-7/+7
Replace `_, _` with `..` in patterns This is how https://github.com/rust-lang/rust/issues/33627 looks in action. Looks especially nice in leftmost/rightmost positions `(first, ..)`/`(.., last)`. I haven't touched libsyntax intentionally because the feature is still unstable.
2016-09-04Rollup merge of #36212 - razielgn:updated-e0493-to-new-format, r=jonathandturnerManish Goregaokar-0/+33
Updated e0493 to new format (+ bonus). Part of #35233. Fixes #35999. r? @jonathandturner I'm not satisfied with the bonus part, there has to be an easier way to reach into the `Drop`'s span implementation. I'm all ears. :)