about summary refs log tree commit diff
path: root/src/librustc_mir/transform
AgeCommit message (Collapse)AuthorLines
2017-11-25avoid type-live-for-region obligations on dummy nodesAriel Ben-Yehuda-3/+10
Type-live-for-region obligations on DUMMY_NODE_ID cause an ICE, and it turns out that in the few cases they are needed, these obligations are not needed anyway because they are verified elsewhere. Fixes #46069.
2017-11-25InstCombine Len([_; N]) => const N in MIRScott McMurray-8/+25
2017-11-24Auto merge of #46093 - scottmcm:lower-128-mir, r=nagisabors-0/+243
Add a MIR pass to lower 128-bit operators to lang item calls Runs only with `-Z lower_128bit_ops` since it's not hooked into targets yet. This isn't really useful on its own, but the declarations for the lang items need to be in the compiler before compiler-builtins can be updated to define them, so this is part 1 of at least 3. cc https://github.com/rust-lang/rust/issues/45676 @est31 @nagisa
2017-11-22normalize types in ADT constructorNiko Matsakis-30/+4
Fixes #45940
2017-11-22handle the active field index in unionsNiko Matsakis-7/+9
2017-11-22avoid early returnNiko Matsakis-21/+18
2017-11-22only normalize operand types when in an ADT constructorNiko Matsakis-4/+25
2017-11-22Normalize LvalueTy for ops and format code to satisfy tidy checkPaul Daniel Faria-24/+39
2017-11-22Remove attributes and test comments accidentally left behind, add in ↵Paul Daniel Faria-9/+20
span_mirbugs
2017-11-22Check rvalue aggregates during check_stmt in tycheck, add initial, (not ↵Paul Daniel Faria-0/+86
passing) test
2017-11-21Auto merge of #45879 - nikomatsakis:nll-kill-cyclic-closures, r=arielb1bors-9/+44
move closure kind, signature into `ClosureSubsts` Instead of using side-tables, store the closure-kind and signature in the substitutions themselves. This has two key effects: - It means that the closure's type changes as inference finds out more things, which is very nice. - As a result, it avoids the need for the `freshen_closure_like` code (though we still use it for generators). - It avoids cyclic closures calls. - These were never meant to be supported, precisely because they make a lot of the fancy inference that we do much more complicated. However, due to an oversight, it was previously possible -- if challenging -- to create a setup where a closure *directly* called itself (see e.g. #21410). We have to see what the effect of this change is, though. Needs a crater run. Marking as [WIP] until that has been assessed. r? @arielb1
2017-11-20Handle shifts properlyScott McMurray-32/+86
* The overflow-checking shift items need to take a full 128-bit type, since they need to be able to detect idiocy like `1i128 << (1u128 << 127)` * The unchecked ones just take u32, like the `*_sh?` methods in core * Because shift-by-anything is allowed, cast into a new local for every shift
2017-11-20Add type checking for the lang itemScott McMurray-19/+45
As part of doing so, add more lang items instead of passing u128 to the i128 ones where it doesn't matter in twos-complement.
2017-11-19Auto merge of #45225 - eddyb:trans-abi, r=arielb1bors-6/+5
Refactor type memory layouts and ABIs, to be more general and easier to optimize. To combat combinatorial explosion, type layouts are now described through 3 orthogonal properties: * `Variants` describes the plurality of sum types (where applicable) * `Single` is for one inhabited/active variant, including all C `struct`s and `union`s * `Tagged` has its variants discriminated by an integer tag, including C `enum`s * `NicheFilling` uses otherwise-invalid values ("niches") for all but one of its inhabited variants * `FieldPlacement` describes the number and memory offsets of fields (if any) * `Union` has all its fields at offset `0` * `Array` has offsets that are a multiple of its `stride`; guarantees all fields have one type * `Arbitrary` records all the field offsets, which can be out-of-order * `Abi` describes how values of the type should be passed around, including for FFI * `Uninhabited` corresponds to no values, associated with unreachable control-flow * `Scalar` is ABI-identical to its only integer/floating-point/pointer "scalar component" * `ScalarPair` has two "scalar components", but only applies to the Rust ABI * `Vector` is for SIMD vectors, typically `#[repr(simd)]` `struct`s in Rust * `Aggregate` has arbitrary contents, including all non-transparent C `struct`s and `union`s Size optimizations implemented so far: * ignoring uninhabited variants (i.e. containing uninhabited fields), e.g.: * `Option<!>` is 0 bytes * `Result<T, !>` has the same size as `T` * using arbitrary niches, not just `0`, to represent a data-less variant, e.g.: * `Option<bool>`, `Option<Option<bool>>`, `Option<Ordering>` are all 1 byte * `Option<char>` is 4 bytes * using a range of niches to represent *multiple* data-less variants, e.g.: * `enum E { A(bool), B, C, D }` is 1 byte Code generation now takes advantage of `Scalar` and `ScalarPair` to, in more cases, pass around scalar components as immediates instead of indirectly, through pointers into temporary memory, while avoiding LLVM's "first-class aggregates", and there's more untapped potential here. Closes #44426, fixes #5977, fixes #14540, fixes #43278.
2017-11-19fix closure inlining by spilling arguments to a temporaryNiko Matsakis-8/+39
2017-11-18Add a MIR pass to lower 128-bit operators to lang item callsScott McMurray-0/+163
Runs only with `-Z lower_128bit_ops` since it's not hooked into targets yet.
2017-11-19rustc: move size, align & primitive_align from Abi::Aggregate to layout.Eduard-Mihai Burtescu-1/+1
2017-11-19rustc: remove Ty::layout and move everything to layout_of.Eduard-Mihai Burtescu-3/+2
2017-11-18rustc_mir: always downcast enums, even if univariant.Eduard-Mihai Burtescu-3/+3
2017-11-18remove `generator_interiors` mapNiko Matsakis-1/+5
2017-11-18Remove return_ty from Mirloomaclin-10/+7
https://github.com/rust-lang/rust/issues/46001
2017-11-16Auto merge of #45825 - nikomatsakis:nll-factor-region-inference, r=arielb1bors-627/+922
integrate MIR type-checker with NLL inference This branch refactors NLL type inference so that it uses the MIR type-checker to gather constraints. Along the way, it also refactors how region constraints are gathered in the normal inference context mildly. The new setup is like this: - What used to be `region_inference` is split into two parts: - `region_constraints`, which just collects up sets of constraints - `lexical_region_resolve`, which does the iterative, lexical region resolution - When `resolve_regions_and_report_errors` is invoked, the inference engine converts the constraints into final values. - In the MIR type checker, however, we do not invoke this method, but instead periodically take the region constraints and package them up for the NLL solver to use later. - This allows us to track when and where those constraints were incurred. - We also remove the central fulfillment context from the MIR type checker, instead instantiating new fulfillment contexts at each point. This allows us to capture the set of obligations that occurred at a particular point, and also to ensure that if the same obligation arises at two points, we will enforce the region constraints at both locations. - The MIR type checker is also enhanced to instantiate late-bound-regions with fresh variables and handle a few other corner cases that arose. - I also extracted some of the 'outlives' logic from the regionck, which will be needed later (see future work) to handle the type-outlives relationships. One concern I have with this branch: since the MIR type checker is used even without the `-Znll` switch, I'm not sure if it will impact performance. One simple fix here would be to only enable the MIR type-checker if debug-assertions are enabled, since it just serves to validate the MIR. Longer term I hope to address this by improving the interface to the trait solver to be more query-based (ongoing work). There is plenty of future work left. Here are two things that leap to mind: - **Type-region outlives.** Currently, the NLL solver will ICE if it is required to handle a constraint like `T: 'a`. Fixing this will require a small amount of refactoring to extract the implied bounds code. I plan to follow a file-up bug on this (hopefully with mentoring instructions). - **Testing.** It's a good idea to enumerate some of the tricky scenarios that need testing, but I think it'd be nice to try and parallelize some of the actual test writing (and resulting bug fixing): - Same obligation occurring at two points. - Well-formedness and trait obligations of various kinds (which are not all processed by the current MIR type-checker). - More tests for how subtyping and region inferencing interact. - More suggestions welcome! r? @arielb1
2017-11-16Nit: fix typoNiko Matsakis-1/+1
2017-11-16integrate NLL with MIR type-checkerNiko Matsakis-160/+154
2017-11-16region_infer: improved debug loggingNiko Matsakis-9/+35
2017-11-16renumber: debug logs, use `visit_region` rather than `visit_rvalue`Niko Matsakis-22/+29
2017-11-16renumber: handle ReturnTy betterNiko Matsakis-1/+9
2017-11-16formalize giving ownership of region vars to region inf. contextNiko Matsakis-70/+57
2017-11-16infer: extract total number of region variables from infcxNiko Matsakis-13/+6
We are heading towards deeper integration with the region inference system in infcx; in particular, prior to the creation of the `RegionInferenceContext`, it will be the "owner" of the set of region variables.
2017-11-16replace `RegionIndex` with `RegionVid` (which now impls Idx)Niko Matsakis-52/+42
2017-11-16replace `usize` with `RegionIndex` in indices mapNiko Matsakis-17/+19
2017-11-16MIR typeck: refactor to track region constraintsNiko Matsakis-72/+242
2017-11-16MIR typeck: rustfmtNiko Matsakis-10/+4
2017-11-16fix rename to block_data in type_check.rsNiko Matsakis-2/+2
2017-11-16Auto merge of #45985 - arielb1:unsafe-dedup, r=eddybbors-1/+0
check_unsafety: fix unused unsafe block duplication The duplicate error message is later removed by error message deduplication, but it still appears on beta and is still a bug. r? @eddyb
2017-11-15modify MIR type-checker to process obligations as they are incurredNiko Matsakis-44/+37
2017-11-15apply rustfmt to `type_check`Niko Matsakis-256/+364
2017-11-15thread location info through mir typeck (but do not use)Niko Matsakis-49/+72
2017-11-15Auto merge of #45913 - sinkuu:mir-inlining-closure, r=arielb1bors-28/+66
Handle closures correctly in MIR inlining Fixes #45894.
2017-11-14check_unsafety: fix unused unsafe block duplicationAriel Ben-Yehuda-1/+0
The duplicate error message is later removed by error message deduplication, but it still appears on beta and is still a bug
2017-11-14Add TyCtxt::is_closureShotaro Yamada-8/+6
2017-11-14Make create_temp_necessary a methodShotaro Yamada-46/+40
2017-11-14Handle closures correctly in MIR inliningShotaro Yamada-10/+56
2017-11-14rustc: split off BodyOwnerKind from MirSource.Eduard-Mihai Burtescu-111/+125
2017-11-14rustc: remove unused MirSource::GeneratorDrop.Eduard-Mihai Burtescu-2/+0
2017-11-14rustc_mir: drive passes directly with a macro.Eduard-Mihai Burtescu-216/+104
2017-11-14rustc: move the MIR pass infrastructure and list to rustc_mir.Eduard-Mihai Burtescu-23/+197
2017-11-14Auto merge of #45909 - sinkuu:issue-45885, r=arielb1bors-5/+33
Normalize inlined function in MIR inliner Fixes #45885 r? @arielb1
2017-11-13mir-borrowck: Move `is_static_mut()` to `ty/utils.rs`Basile Desloges-21/+2
2017-11-12Auto merge of #45753 - sinkuu:mir_copyprop_arg, r=arielb1bors-4/+46
Fix MIR CopyPropagation errneously propagating assignments to function args Compiling this code with MIR CopyPropagation activated will result in printing `5`, because CopyProp errneously propagates the assignment of `5` to all `x`: ```rust fn bar(mut x: u8) { println!("{}", x); x = 5; } fn main() { bar(123); } ``` If a local is propagated, it will result in an ICE at trans due to an use-before-def: ```rust fn dummy(x: u8) -> u8 { x } fn foo(mut x: u8) { x = dummy(x); // this will assign a local to `x` } ``` Currently CopyProp conservatively gives up if there are multiple assignments to a local, but it is not took into account that arguments are already assigned from the beginning. This PR fixes the problem by preventing propagation of assignments to function arguments.