summary refs log tree commit diff
path: root/src/librustc_mir/transform
AgeCommit message (Collapse)AuthorLines
2016-05-15Auto merge of #33620 - eddyb:oops-static-is-not-fn, r=dotdashbors-3/+3
mir: always allow &mut [...] in static mut regardless of the array length.
2016-05-14Rollup merge of #33552 - dotdash:scfg, r=luqmanaManish Goregaokar-59/+124
[MIR] Enhance the SimplifyCfg pass to merge consecutive blocks Updated from #30238, including the changes suggested by @Aatch.
2016-05-14Rollup merge of #33544 - dotdash:baby_dont_break_me_no_more, r=AatchManish Goregaokar-118/+112
Only break critical edges where actually needed Currently, to prepare for MIR trans, we break _all_ critical edges, although we only actually need to do this for edges originating from a call that gets translated to an invoke instruction in LLVM. This has the unfortunate effect of undoing a bunch of the things that SimplifyCfg has done. A particularly bad case arises when you have a C-like enum with N variants and a derived PartialEq implementation. In that case, the match on the (&lhs, &rhs) tuple gets translated into nested matches with N arms each and a basic block each, resulting in N² basic blocks. SimplifyCfg reduces that to roughly 2*N basic blocks, but breaking the critical edges means that we go back to N². In nickel.rs, there is such an enum with roughly N=800. So we get about 640K basic blocks or 2.5M lines of LLVM IR. LLVM takes a while to reduce that to the final "disr_a == disr_b". So before this patch, we had 2.5M lines of IR with 640K basic blocks, which took about about 3.6s in LLVM to get optimized and translated. After this patch, we get about 650K lines with about 1.6K basic blocks and spent a little less than 0.2s in LLVM. cc #33111 r? @Aatch
2016-05-13mir: always allow &mut [...] in static mut regardless of the array length.Eduard Burtescu-3/+3
2016-05-13Auto merge of #33541 - eddyb:promote-only-temps, r=arielb1bors-6/+18
mir: don't attempt to promote Unpromotable constant temps. Fixes #33537. This was a non-problem in regular functions, but we also promote in `const fn`s. There we always qualify temps so you can't depend on `Unpromotable` temps being `NOT_CONST`.
2016-05-13[MIR] Enhance the SimplifyCfg pass to merge consecutive blocksBjörn Steinbrink-59/+124
2016-05-11Only break critical edges where actually neededBjörn Steinbrink-118/+112
Currently, to prepare for MIR trans, we break _all_ critical edges, although we only actually need to do this for edges originating from a call that gets translated to an invoke instruction in LLVM. This has the unfortunate effect of undoing a bunch of the things that SimplifyCfg has done. A particularly bad case arises when you have a C-like enum with N variants and a derived PartialEq implementation. In that case, the match on the (&lhs, &rhs) tuple gets translated into nested matches with N arms each and a basic block each, resulting in N² basic blocks. SimplifyCfg reduces that to roughly 2*N basic blocks, but breaking the critical edges means that we go back to N². In nickel.rs, there is such an enum with roughly N=800. So we get about 640K basic blocks or 2.5M lines of LLVM IR. LLVM takes a while to reduce that to the final "disr_a == disr_b". So before this patch, we had 2.5M lines of IR with 640K basic blocks, which took about about 3.6s in LLVM to get optimized and translated. After this patch, we get about 650K lines with about 1.6K basic blocks and spent a little less than 0.2s in LLVM. cc #33111
2016-05-11rustc: Split local type contexts interners from the global one.Eduard Burtescu-11/+10
2016-05-11rustc: More interning for data used in Ty<'tcx>.Eduard Burtescu-3/+3
2016-05-11rustc: Wrap users of InferCtxt in an anonymous scope.Eduard Burtescu-23/+23
2016-05-11rustc: Remove the TyCtxt field from ParameterEnvironment.Eduard Burtescu-13/+15
2016-05-11rustc: Split 'tcx into 'gcx and 'tcx for InferCtxt and its users.Eduard Burtescu-28/+34
2016-05-11rustc: Replace &'a TyCtxt<'tcx> with a TyCtxt<'a, 'tcx> wrapper.Eduard Burtescu-22/+22
2016-05-11rustc: Avoid free functions taking &TyCtxt and &InferCtxt.Eduard Burtescu-16/+14
2016-05-11infer: Use methods for creating an InferCtxt.Eduard Burtescu-9/+5
2016-05-10mir: don't attempt to promote Unpromotable constant temps.Eduard Burtescu-6/+18
2016-05-07Implement RFC 1440 "Allow Drop types in statics/const functions".Eduard Burtescu-5/+32
2016-05-07mir: qualify and promote constants.Eduard Burtescu-0/+1424
2016-05-07mir: prepare for rvalue promotion support.Eduard Burtescu-24/+21
2016-04-16MIR: Do not require END_BLOCK to always existSimonas Kazlauskas-2/+1
Once upon a time, along with START_BLOCK and END_BLOCK in the castle of important blocks also lived a RESUME_BLOCK (or was it UNWIND_BLOCK? Either works, I don’t remember anymore). This trinity of important blocks were required to always exist from the birth to death of the MIR-land they belonged to. Some time later, it was discovered that RESUME_BLOCK was just a lazy goon enjoying comfortable life in the light of fame of the other two. Needless to say, once found out, the RESUME_BLOCK was quickly slain and disposed of. Now, the all-seeing eye of ours discovers that END_BLOCK is actually the more evil and better disguised twin of the slain RESUME_BLOCK. Thus END_BLOCK gets slain and quickly disposed of. Glory to the START_BLOCK, one and only lord of the important blocks’ castle! --- Basically, all this does, is removing restriction for END_BLOCK to exist past the first invocation of RemoveDeadBlocks pass. This way for functions whose CFG does not reach the `END_BLOCK` end up not containing the block. As far as the implementation goes, I’m not entirely satisfied with the `BasicBlock::end_block`, I had hoped to make `new` a `const fn` and then just have a `const END_BLOCK` private to mir::build, but it turns out that constant functions don’t yet support conditionals nor a way to assert.
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