about summary refs log tree commit diff
path: root/src/librustc_trans
AgeCommit message (Collapse)AuthorLines
2017-12-18Rename more functions from trans to monoMaik Klein-1/+1
2017-12-18Rename TransItemExt to MonoItemExtMaik Klein-7/+7
2017-12-18Rename TransItemCollectionMode to MonoItemCollectionModeMaik Klein-4/+4
2017-12-18Rename TransItem to MonoItemMaik Klein-54/+54
2017-12-18Move trans_item and monomorphize to rustc_mirMaik Klein-4/+4
2017-12-18Move collector to monomorphizeMaik Klein-3/+4
2017-12-18Fix the wrong subtraction in align_offset intrinsic.kennytm-2/+2
2017-12-18incr.comp.: Add -Cincremental in addition to -ZincrementalMichael Woerister-1/+1
2017-12-17Auto merge of #46436 - eddyb:unpacked, r=arielb1,oli-obkbors-200/+167
Detect unaligned fields via `aggregate.align < field.align`, instead of a `packed` flag. Closes #46423. cc @oli-obk
2017-12-17rustc_trans: always require alignment for load/store/memcpy.Eduard-Mihai Burtescu-61/+56
2017-12-17rustc_trans: always keep track of the Align in LvalueRef.Eduard-Mihai Burtescu-124/+86
2017-12-17rustc: don't track whether layouts are "packed".Eduard-Mihai Burtescu-43/+53
2017-12-17Add sync module to rustc_data_structuresJohn Kåre Alsaker-3/+1
2017-12-16Auto merge of #46750 - varkor:imp-llmod, r=estebankbors-1/+4
Improve error messages on LLVM bitcode parsing failure The LLVM error causing the parse failure is now printed, in the style of the other thin LTO error messages. This prevents a flood of assertion failure messages if the bitcode can’t be parsed.
2017-12-15Improve error messages on LLVM bitcode parsing failurevarkor-1/+4
The LLVM error causing the parse failure is now printed, in the style of the other thin LTO error messages. This prevents a flood of assertion failure messages if the bitcode can’t be parsed.
2017-12-15rustc_trans: approximate ABI alignment for padding/union fillers.Eduard-Mihai Burtescu-11/+23
2017-12-15Auto merge of #46701 - eddyb:vector-newtypes, r=nagisabors-73/+70
rustc: unpack newtyped of #[repr(simd)] vector types. Prerequisite for a `#[repr(transparent)]` implementation that works with SIMD vectors. cc @rkruppe
2017-12-14Use PathBuf instead of String where applicableOliver Schneider-21/+23
2017-12-13rustc: unpack newtyped of #[repr(simd)] vector types.Eduard-Mihai Burtescu-73/+70
2017-12-10rustc_trans: Fix indentation in trans_set_discr.Emilio Cobos Álvarez-4/+4
Just noticed this while reading through #46521, which introduced this weird alignment.
2017-12-09Use Try syntax for Option in place of macros or matchMatt Brubeck-4/+1
2017-12-08Auto merge of #46563 - michaelwoerister:make-anon-globals-private, ↵bors-1/+1
r=alexcrichton Make CGU-local globals private so they don't show up in the local symbol table. Should reduce binary sizes. Great find, @eddyb! r? @alexcrichton (I have not tested this locally. Better wait for travis to turn green before approving)
2017-12-07Make CGU-local globals private so they don't show up in the local symbol table.Michael Woerister-1/+1
2017-12-07make `fn_sig().subst()` ICE when used with a closureNiko Matsakis-5/+4
It's inefficient, and the substitution there doesn't account for the extra regions used by NLL inference, so it's a bad thing to encourage. As it happens all callers already know if they have a closure or not, from what I can tell.
2017-12-05rustc_trans: don't write discriminants for uninhabited variantsSimon Sapin-7/+5
Fixes #46519. Patch as suggested by eddyb: https://github.com/rust-lang/rust/issues/46519#issuecomment-349443519
2017-12-05Auto merge of #46305 - irinagpopa:backstory, r=alexcrichton,eddybbors-1/+3
Move rustc_back modules where they belong.
2017-12-04rustc_back: replace tempdir with crates.io version.Irina-Gabriela Popa-1/+3
2017-12-04introduce `closure_env_ty` helper to compute ty of closure env argNiko Matsakis-8/+2
Previously the code was somewhat duplicated.
2017-12-02Auto merge of #46382 - alexcrichton:thinlto-default, r=michaelwoeristerbors-3/+4
rustc: Prepare to enable ThinLTO by default This commit *almost* enables ThinLTO and multiple codegen units in release mode by default but is blocked on #46346 now before pulling the trigger.
2017-12-01MIR: s/lv(al(ue)?)?/place in function/variable/module names.Eduard-Mihai Burtescu-173/+173
2017-12-01MIR: s/Lvalue/Place in type names.Eduard-Mihai Burtescu-139/+139
2017-12-01Auto merge of #46370 - michaelwoerister:rm-metadata-hashing, r=eddybbors-21/+11
incr.comp.: Remove ability to produce incr. comp. hashes during metadata export. This functionality has been superseded by on-import hashing, which can be less conservative and does not require extra infrastructure. r? @nikomatsakis
2017-11-30rustc: Prepare to enable ThinLTO by defaultAlex Crichton-3/+4
This commit prepares to enable ThinLTO and multiple codegen units in release mode by default. We've still got a debuginfo bug or two to sort out before actually turning it on by default.
2017-11-29incr.comp.: Remove on-export crate metadata hashing.Michael Woerister-21/+11
2017-11-29Rollup merge of #46322 - gnzlbg:mmx, r=alexcrichtonkennytm-1/+4
white list MMX and MSA target features r? @alexcrichton
2017-11-29Rollup merge of #46287 - SimonSapin:stable-constness, r=aturonkennytm-3/+0
Stabilize const-calling existing const-fns in std Fixes #46038
2017-11-28white list MMX and MSA target featuresgnzlbg-1/+4
2017-11-28MIR: split Operand::Consume into Copy and Move.Eduard-Mihai Burtescu-15/+27
2017-11-26Stabilize const-calling existing const-fns in stdSimon Sapin-3/+0
Fixes #46038
2017-11-26Auto merge of #46253 - eddyb:return-aliasing, r=nagisabors-1/+2
rustc_trans: don't apply noalias on returned references. In #45225 frozen returned `&T` were accidentally maked `noalias`, unlike `&mut T`. Return value `noalias` is only sound for functions that return dynamic allocations, e.g. `Box`, and using it on anything else can lead to miscompilation, as LLVM assumes certain usage patterns. Fixes #46239.
2017-11-25rustc: Add support for some more x86 SIMD opsAlex Crichton-4/+62
This commit adds compiler support for two basic operations needed for binding SIMD on x86 platforms: * First, a `nontemporal_store` intrinsic was added for the `_mm_stream_ps`, seen in rust-lang-nursery/stdsimd#114. This was relatively straightforward and is quite similar to the volatile store intrinsic. * Next, and much more intrusively, a new type to the backend was added. The `x86_mmx` type is used in LLVM for a 64-bit vector register and is used in various intrinsics like `_mm_abs_pi8` as seen in rust-lang-nursery/stdsimd#74. This new type was added as a new layout option as well as having support added to the trans backend. The type is enabled with the `#[repr(x86_mmx)]` attribute which is intended to just be an implementation detail of SIMD in Rust. I'm not 100% certain about how the `x86_mmx` type was added, so any extra eyes or thoughts on that would be greatly appreciated!
2017-11-25rustc_trans: don't apply noalias on returned references.Eduard-Mihai Burtescu-1/+2
2017-11-21Auto merge of #45879 - nikomatsakis:nll-kill-cyclic-closures, r=arielb1bors-2/+2
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-20Auto merge of #45905 - alexcrichton:add-wasm-target, r=aturonbors-29/+162
std: Add a new wasm32-unknown-unknown target This commit adds a new target to the compiler: wasm32-unknown-unknown. This target is a reimagining of what it looks like to generate WebAssembly code from Rust. Instead of using Emscripten which can bring with it a weighty runtime this instead is a target which uses only the LLVM backend for WebAssembly and a "custom linker" for now which will hopefully one day be direct calls to lld. Notable features of this target include: * There is zero runtime footprint. The target assumes nothing exists other than the wasm32 instruction set. * There is zero toolchain footprint beyond adding the target. No custom linker is needed, rustc contains everything. * Very small wasm modules can be generated directly from Rust code using this target. * Most of the standard library is stubbed out to return an error, but anything related to allocation works (aka `HashMap`, `Vec`, etc). * Naturally, any `#[no_std]` crate should be 100% compatible with this new target. This target is currently somewhat janky due to how linking works. The "linking" is currently unconditional whole program LTO (aka LLVM is being used as a linker). Naturally that means compiling programs is pretty slow! Eventually though this target should have a linker. This target is also intended to be quite experimental. I'm hoping that this can act as a catalyst for further experimentation in Rust with WebAssembly. Breaking changes are very likely to land to this target, so it's not recommended to rely on it in any critical capacity yet. We'll let you know when it's "production ready". ### Building yourself First you'll need to configure the build of LLVM and enable this target ``` $ ./configure --target=wasm32-unknown-unknown --set llvm.experimental-targets=WebAssembly ``` Next you'll want to remove any previously compiled LLVM as it needs to be rebuilt with WebAssembly support. You can do that with: ``` $ rm -rf build ``` And then you're good to go! A `./x.py build` should give you a rustc with the appropriate libstd target. ### Test support Currently testing-wise this target is looking pretty good but isn't complete. I've got almost the entire `run-pass` test suite working with this target (lots of tests ignored, but many passing as well). The `core` test suite is [still getting LLVM bugs fixed](https://reviews.llvm.org/D39866) to get that working and will take some time. Relatively simple programs all seem to work though! In general I've only tested this with a local fork that makes use of LLVM 5 rather than our current LLVM 4 on master. The LLVM 4 WebAssembly backend AFAIK isn't broken per se but is likely missing bug fixes available on LLVM 5. I'm hoping though that we can decouple the LLVM 5 upgrade and adding this wasm target! ### But the modules generated are huge! It's worth nothing that you may not immediately see the "smallest possible wasm module" for the input you feed to rustc. For various reasons it's very difficult to get rid of the final "bloat" in vanilla rustc (again, a real linker should fix all this). For now what you'll have to do is: cargo install --git https://github.com/alexcrichton/wasm-gc wasm-gc foo.wasm bar.wasm And then `bar.wasm` should be the smallest we can get it! --- In any case for now I'd love feedback on this, particularly on the various integration points if you've got better ideas of how to approach them!
2017-11-19std: Add a new wasm32-unknown-unknown targetAlex Crichton-29/+162
This commit adds a new target to the compiler: wasm32-unknown-unknown. This target is a reimagining of what it looks like to generate WebAssembly code from Rust. Instead of using Emscripten which can bring with it a weighty runtime this instead is a target which uses only the LLVM backend for WebAssembly and a "custom linker" for now which will hopefully one day be direct calls to lld. Notable features of this target include: * There is zero runtime footprint. The target assumes nothing exists other than the wasm32 instruction set. * There is zero toolchain footprint beyond adding the target. No custom linker is needed, rustc contains everything. * Very small wasm modules can be generated directly from Rust code using this target. * Most of the standard library is stubbed out to return an error, but anything related to allocation works (aka `HashMap`, `Vec`, etc). * Naturally, any `#[no_std]` crate should be 100% compatible with this new target. This target is currently somewhat janky due to how linking works. The "linking" is currently unconditional whole program LTO (aka LLVM is being used as a linker). Naturally that means compiling programs is pretty slow! Eventually though this target should have a linker. This target is also intended to be quite experimental. I'm hoping that this can act as a catalyst for further experimentation in Rust with WebAssembly. Breaking changes are very likely to land to this target, so it's not recommended to rely on it in any critical capacity yet. We'll let you know when it's "production ready". --- Currently testing-wise this target is looking pretty good but isn't complete. I've got almost the entire `run-pass` test suite working with this target (lots of tests ignored, but many passing as well). The `core` test suite is still getting LLVM bugs fixed to get that working and will take some time. Relatively simple programs all seem to work though! --- It's worth nothing that you may not immediately see the "smallest possible wasm module" for the input you feed to rustc. For various reasons it's very difficult to get rid of the final "bloat" in vanilla rustc (again, a real linker should fix all this). For now what you'll have to do is: cargo install --git https://github.com/alexcrichton/wasm-gc wasm-gc foo.wasm bar.wasm And then `bar.wasm` should be the smallest we can get it! --- In any case for now I'd love feedback on this, particularly on the various integration points if you've got better ideas of how to approach them!
2017-11-19Auto merge of #45225 - eddyb:trans-abi, r=arielb1bors-4030/+3248
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-19rustc_trans: remove primitive_align optimization.Eduard-Mihai Burtescu-18/+6
2017-11-19rustc_trans: work around i686-pc-windows-msvc byval align LLVM bug.Eduard-Mihai Burtescu-1/+3
2017-11-19rustc_trans: (hack) use preferred alignment for atomic loads/stores.Eduard-Mihai Burtescu-2/+7
2017-11-19rustc: extend the niche-filling enum optimization past 2 variants.Eduard-Mihai Burtescu-18/+44