summary refs log tree commit diff
path: root/src/librustc_mir/transform
AgeCommit message (Collapse)AuthorLines
2016-06-23Move errors from libsyntax to its own crateJonathan Turner-3/+3
2016-06-16fix MirSource::Promoted handlingAriel Ben-Yehuda-4/+1
2016-06-16stop having `'static` in dump-mir namesAriel Ben-Yehuda-0/+6
2016-06-09use the type name as the pass nameAriel Ben-Yehuda-19/+5
2016-06-09refactor simplify_cfg and split off simplify_branchesAriel Ben-Yehuda-133/+193
2016-06-09add hook infrastructure for automatically dumping MIR on every passAriel Ben-Yehuda-18/+91
2016-06-09introduce an `unreachable` terminatorAriel Ben-Yehuda-1/+5
Use it instead of a `panic` for inexhaustive matches and correct the comment. I think we trust our match-generation algorithm enough to generate these blocks, and not generating an `unreachable` means that LLVM won't optimize `match void() {}` to an `unreachable`.
2016-06-09add a cache for MIR predecessorsAriel Ben-Yehuda-20/+4
2016-06-09make the basic_blocks field privateAriel Ben-Yehuda-55/+52
2016-06-09introduce the type-safe IdxVec and use it instead of loose indexesAriel Ben-Yehuda-71/+73
2016-06-09merge the RemoveDeadBlocks pass into the SimplifyCfg passAriel Ben-Yehuda-98/+62
2016-06-09implement RFC495 semantics for slice patternsAriel Ben-Yehuda-1/+21
non-MIR translation is still not supported for these and will happily ICE. This is a [breaking-change] for many uses of slice_patterns.
2016-06-08remove the librustc_trans -> librustc_mir dependencyAriel Ben-Yehuda-7/+4
2016-06-07mir: group span + visibility scope under a new SourceInfo type.Eduard Burtescu-33/+37
2016-06-07mir: distinguish between variable visibility scopes and SEME scopes.Eduard Burtescu-3/+3
2016-06-05Add a new Assert terminator to MIR for bounds & arithmetic checks.Eduard Burtescu-65/+30
2016-06-05Check arithmetic in the MIRJames Miller-0/+1
Add, Sub, Mul, Shl, and Shr are checked using a new Rvalue: CheckedBinaryOp, while Div, Rem and Neg are handled with explicit checks in the MIR.
2016-06-05break critical edges only when neededAriel Ben-Yehuda-43/+56
the *only* place where critical edges need to be broken is on Call instructions, so only break them there.
2016-06-03check for is_cleanup violations in MIR typeckAriel Ben-Yehuda-3/+65
There weren't any in practice, but as these cause MSVC-only problems, the check looks like a good idea.
2016-06-03introduce DropAndReplace for translating assignmentsAriel Ben-Yehuda-5/+21
this introduces a DropAndReplace terminator as a fix to #30380. That terminator is suppsoed to be translated by desugaring during drop elaboration, which is not implemented in this commit, so this breaks `-Z orbit` temporarily.
2016-05-31normalize types in MIR typeck after erasing regionsAriel Ben-Yehuda-25/+24
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