summary refs log tree commit diff
path: root/src/librustc_mir/transform
AgeCommit message (Collapse)AuthorLines
2016-04-06break dep-graph into modules, parameterize DepNodeNiko Matsakis-1/+2
it is useful later to customize how change the type we use for reference items away from DefId
2016-04-05Rollup merge of #32596 - soltanmm:lazy, r=nikomatsakisManish Goregaokar-1/+5
Plumb obligations through librustc/infer Like #32542, but more like #31867. TODO before merge: make an issue for the propagation of obligations through... uh, everywhere... then replace the `#????`s with the actual issue number. cc @jroesch r? @nikomatsakis
2016-04-04Address nitsMasood Malekghassemi-2/+2
2016-04-03Auto merge of #32210 - Aatch:mir-traversal, r=nikomatsakisbors-0/+118
rBreak Critical Edges and other MIR work This PR is built on top of #32080. This adds the basic depth-first traversals for MIR, preorder, postorder and reverse postorder. The MIR blocks are now translated using reverse postorder. There is also a transform for breaking critical edges, which includes the edges from `invoke`d calls (`Drop` and `Call`), to account for the fact that we can't add code after an `invoke`. It also stops generating the intermediate block (since the transform essentially does it if necessary already). The kinds of cases this deals with are difficult to produce, so the test is the one I managed to get. However, it seems to bootstrap with `-Z orbit`, which it didn't before my changes.
2016-04-03Use a BitVector instead of Vec<bool> for recording cleanup blocksJames Miller-1/+8
Also adds a FromIterator impl for BitVector to allow construction of a BitVector from an iterator yeilding bools.
2016-03-31Turn break critical edges into a MIR passJames Miller-9/+23
Also adds a new set of passes to run just before translation that "prepare" the MIR for codegen. Removal of landing pads, region erasure and break critical edges are run in this pass. Also fixes some merge/rebase errors.
2016-03-30move `const_eval` and `check_match` out of `librustc`Oliver Schneider-1/+1
2016-03-29Plumb obligations through librustc/inferMasood Malekghassemi-1/+5
2016-03-30Don't build a map of predecessors, just count them insteadJames Miller-88/+4
2016-03-30Add and use a break critical edges transformJames Miller-0/+181
This is a fairly standard transform that inserts blocks along critical edges so code can be inserted along the edge without it affecting other edges. The main difference is that it considers a Drop or Call terminator that would require an `invoke` instruction in LLVM a critical edge. This is because we can't actually insert code after an invoke, so it ends up looking similar to a critical edge anyway. The transform is run just before translation right now.
2016-03-27rustc: move cfg, infer, traits and ty from middle to top-level.Eduard Burtescu-9/+9
2016-03-25use new visitor to erase regionsNiko Matsakis-84/+7
2016-03-23fix bug in `simplify_cfg` with inf. loopsNiko Matsakis-8/+18
2016-03-23allow dumping intermediate IR with -Z dump-mirNiko Matsakis-0/+3
2016-03-23extend Terminator into a struct so it can have additional fieldsNiko Matsakis-37/+37
2016-03-17hir, mir: Separate HIR expressions / MIR operands from InlineAsm.Eduard Burtescu-1/+1
2016-03-14Fixes after rebaseAaron Turon-2/+5
2016-03-13Auto merge of #31916 - nagisa:mir-passmgr-2, r=arielb1bors-104/+80
Add Pass manager for MIR A new PR, since rebasing the original one (https://github.com/rust-lang/rust/pull/31448) properly was a pain. Since then there has been several changes most notable of which: 1. Removed the pretty-printing with `#[rustc_mir(graphviz/pretty)]`, mostly because we now have `--unpretty=mir`, IMHO that’s the direction we should expand this functionality into; 2. Reverted the infercx change done for typeck, because typeck can make an infercx for itself by being a `MirMapPass` r? @nikomatsakis
2016-03-09Track fn type and lifetime parameters in TyFnDef.Eduard Burtescu-1/+1
2016-03-09Split TyBareFn into TyFnDef and TyFnPtr.Eli Friedman-1/+1
There's a lot of stuff wrong with the representation of these types: TyFnDef doesn't actually uniquely identify a function, TyFnPtr is used to represent method calls, TyFnDef in the sub-expression of a cast isn't correctly reified, and probably some other stuff I haven't discovered yet. Splitting them seems like the right first step, though.
2016-03-07Change MirPass to also take NodeIdSimonas Kazlauskas-26/+27
2016-03-04Address commentsSimonas Kazlauskas-0/+2
2016-03-04Add Pass manager for MIRSimonas Kazlauskas-109/+82
2016-03-03Rename middle::ty::ctxt to TyCtxtJeffrey Seyfried-7/+7
2016-02-23[MIR] Change SimplifyCfg pass to use bitvecSimonas Kazlauskas-63/+34
BitVector is much more space efficient.
2016-02-20address review commentsAriel Ben-Yehuda-15/+37
2016-02-20use the FulfillmentContext and InferCtxt more correctlyAriel Ben-Yehuda-64/+101
2016-02-20type-check lvaluesAriel Ben-Yehuda-10/+217
2016-02-20fix a few remaining bugs - make check runs!Ariel Ben-Yehuda-0/+8
2016-02-20store the normalized types of field accessesAriel Ben-Yehuda-0/+1
Fixes #31504
2016-02-20introduce an early pass to clear dead blocksAriel Ben-Yehuda-8/+63
this makes the the MIR assignment pass complete successfully
2016-02-19begin implementing mir-typeckAriel Ben-Yehuda-0/+342
2016-02-17MSVC SEH in MIR is implemented hereSimonas Kazlauskas-1/+3
2016-02-11Add a no-landing-pads MIR passSimonas Kazlauskas-0/+48
The pass removes the unwind branch of each terminator, thus moving the responsibility of handling the -Z no-landing-pads flag to a small self-contained pass… instead of polluting the translator.
2016-02-09refactor `MirPass` to always require a tcxOliver Schneider-20/+16
2016-02-09make `MirMap` a struct instead of a type alias for `NodeMap`Oliver Schneider-2/+2
2016-02-06Reuse MIR visitors for EraseRegions passSimonas Kazlauskas-157/+67
2016-02-04Convert Drop statement into terminatorSimonas Kazlauskas-3/+3
The structure of the old translator as well as MIR assumed that drop glue cannot possibly panic and translated the drops accordingly. However, in presence of `Drop::drop` this assumption can be trivially shown to be untrue. As such, the Rust code like the following would never print number 2: ```rust struct Droppable(u32); impl Drop for Droppable { fn drop(&mut self) { if self.0 == 1 { panic!("Droppable(1)") } else { println!("{}", self.0) } } } fn main() { let x = Droppable(2); let y = Droppable(1); } ``` While the behaviour is allowed according to the language rules (we allow drops to not run), that’s a very counter-intuitive behaviour. We fix this in MIR by allowing `Drop` to have a target to take on divergence and connect the drops in such a way so the leftover drops are executed when some drop unwinds. Note, that this commit still does not implement the translator part of changes necessary for the grand scheme of things to fully work, so the actual observed behaviour does not change yet. Coming soon™. See #14875.
2016-02-04Remove the CallKindSimonas Kazlauskas-2/+2
We used to have CallKind only because there was a requirement to have all successors in a contiguous memory block. Now that the requirement is gone, remove the CallKind and instead just have the necessary information inline. Awesome!
2016-02-04Change successor{,_mut} to return a VecSimonas Kazlauskas-1/+1
This helps to avoid the unpleasant restriction of being unable to have multiple successors in non-contiguous block of memory.
2016-02-04Synthesize calls to box_free language itemSimonas Kazlauskas-1/+1
This gets rid of Drop(Free, _) MIR construct by synthesizing a call to language item which takes care of dropping instead.
2016-01-21Add Debug impl and erase region for TypedConstValFlorian Hahn-1/+2
2016-01-21Introduce and use TypedConstVal for RepeatFlorian Hahn-2/+1
2016-01-08Change destination accessor to return referencesSimonas Kazlauskas-1/+1
Previously it was returning a value, mostly for the two reasons: * Cloning Lvalue is very cheap most of the time (i.e. when Lvalue is not a Projection); * There’s users who want &mut lvalue and there’s users who want &lvalue. Returning a value allows to make either one easier when pattern matching (i.e. Some(ref dest) or Some(ref mut dest)). However, I’m now convinced this is an invalid approach. Namely the users which want a mutable reference may modify the Lvalue in-place, but the changes won’t be reflected in the final MIR, since the Lvalue modified is merely a clone. Instead, we have two accessors `destination` and `destination_mut` which return a reference to the destination in desired mode.
2016-01-06Merge Call and DivergingCall diffs into CallKindSimonas Kazlauskas-7/+3
This merges two separate Call terminators and uses a separate CallKind sub-enum instead. A little bit unrelatedly, copying into destination value for a certain kind of invoke, is also implemented here. See the associated comment in code for various details that arise with this implementation.
2016-01-06Remove diverge terminatorSimonas Kazlauskas-19/+12
Unreachable terminator can be contained all within the trans.
2016-01-06Remove the Panic block terminatorSimonas Kazlauskas-2/+1
2016-01-06Add Resume Terminator which corresponds to resumeSimonas Kazlauskas-0/+1
Diverge should eventually go away
2016-01-06Split Call into Call and DivergingCallSimonas Kazlauskas-13/+8
DivergingCall is different enough from the regular converging Call to warrant the split. This also inlines CallData struct and creates a new CallTargets enum in order to have a way to differentiate between calls that do not have an associated cleanup block. Note, that this patch still does not produce DivergingCall terminator anywhere. Look for that in the next patches.
2015-12-10MIR: Refactor mir::Terminator to use tuples instead of a fixed-size arrays.Michael Woerister-4/+7