about summary refs log tree commit diff
path: root/src/librustc_trans
AgeCommit message (Collapse)AuthorLines
2018-02-11iterator instead loopАртём Павлов [Artyom Pavlov]-10/+8
2018-02-11added conversion from Rust feature to LLVM featureАртём Павлов [Artyom Pavlov]-35/+42
2018-02-10typo fixArtyom Pavlov-1/+1
2018-02-10Whitelist pclmul x86 feature flagArtyom Pavlov-1/+1
Relevant `stdsimd` [issue](https://github.com/rust-lang-nursery/stdsimd/issues/318).
2018-02-10Rollup merge of #48078 - alexcrichton:fix-required-const-and-proc-macro, r=eddybkennytm-0/+8
Disallow function pointers to #[rustc_args_required_const] This commit disallows acquiring a function pointer to functions tagged as `#[rustc_args_required_const]`. This is intended to be used as future-proofing for the stdsimd crate to avoid taking a function pointer to any intrinsic which has a hard requirement that one of the arguments is a constant value. Note that the first commit here isn't related specifically to this feature, but was necessary to get this working in stdsimd!
2018-02-09Auto merge of #47802 - bobtwinkles:loop_false_edge, r=nikomatsakisbors-3/+5
[NLL] Add false edges out of infinite loops Resolves #46036 by adding a `cleanup` member to the `FalseEdges` terminator kind. There's also a small doc fix to one of the other comments in `into.rs` which I can pull out in to another PR if desired =) This PR should pass CI but the test suite has been relatively unstable on my system so I'm not 100% sure. r? @nikomatsakis
2018-02-09Auto merge of #47489 - pnkfelix:limit-2pb-issue-46747, r=nikomatsakisbors-1/+1
NLL: Limit two-phase borrows to autoref-introduced borrows This imposes a restriction on two-phase borrows so that it only applies to autoref-introduced borrows. The goal is to ensure that our initial deployment of two-phase borrows is very conservative. We want it to still cover the `v.push(v.len());` example, but we do not want it to cover cases like `let imm = &v; let mu = &mut v; mu.push(imm.len());` (Why do we want it to be conservative? Because when you are not conservative, then the results you get, at least with the current analysis, are tightly coupled to details of the MIR construction that we would rather remain invisible to the end user.) Fix #46747 I decided, for this PR, to add a debug-flag `-Z two-phase-beyond-autoref`, to re-enable the more general approach. But my intention here is *not* that we would eventually turn on that debugflag by default; the main reason I added it was that I thought it was useful for writing tests to be able to write source that looks like desugared MIR.
2018-02-08Disallow function pointers to #[rustc_args_required_const]Alex Crichton-0/+8
This commit disallows acquiring a function pointer to functions tagged as `#[rustc_args_required_const]`. This is intended to be used as future-proofing for the stdsimd crate to avoid taking a function pointer to any intrinsic which has a hard requirement that one of the arguments is a constant value.
2018-02-08Fix oversized loads on x86_64 SysV FFI callsBjörn Steinbrink-6/+7
The x86_64 SysV ABI should use exact sizes for small structs passed in registers, i.e. a struct that occupies 3 bytes should use an i24, instead of the i32 it currently uses. Refs #45543
2018-02-08Encode (in MIR) whether borrows are explicit in source or arise due to autoref.Felix S. Klock II-1/+1
This is foundation for issue 46747 (limit two-phase borrows to method-call autorefs).
2018-02-07Rollup merge of #47883 - yurydelendik:wasm-map, r=alexcrichtonManish Goregaokar-3/+15
Export wasm source map when debug information is enabled We use binaryen's linker to produce a wasm file (via s2wasm). The wasm writer has capabilities to export source maps. The pilot support for source maps is added to Firefox. The produced source map contains references to the original file, that might require additional source map file processing to include / package original files with it. /cc @alexcrichton
2018-02-05mir: Add TerminatorKind::FalseUnwindbobtwinkles-3/+5
Sometimes a simple goto misses the cleanup/unwind edges. Specifically, in the case of infinite loops such as those introduced by a loop statement without any other out edges. Analogous to TerminatorKind::FalseEdges; this new terminator kind is used when we want borrowck to consider an unwind path, but real control flow should never actually take it.
2018-02-05Rollup merge of #47892 - Badel2:const_type_id_of, r=oli-obkkennytm-0/+5
Turn `type_id` into a constant intrinsic https://github.com/rust-lang/rust/issues/27745 The method `get_type_id` in `Any` is intended to support reflection. It's currently unstable in favor of using an associated constant instead. This PR makes the `type_id` intrinsic a constant intrinsic, the same as `size_of` and `align_of`, allowing `TypeId::of` to be a `const fn`, which will allow using an associated constant in `Any`.
2018-02-04Auto merge of #47915 - eddyb:layout-of, r=nikomatsakisbors-2/+1
rustc: prefer ParamEnvAnd and LayoutCx over tuples for LayoutOf. This PR provides `tcx.layout_of(param_env.and(ty))` as the idiomatic replacement for the existing `(tcx, param_env).layout_of(ty)` and removes fragile (coherence-wise) layout-related tuple impls. r? @nikomatsakis
2018-02-02Auto merge of #47102 - Diggsey:wasm-syscall, r=alexcrichtonbors-4/+2
Implement extensible syscall interface for wasm Currently it's possible to run tests with the native wasm target, but it's not possible to tell whether they pass or to capture the output, because libstd throws away stdout, stderr and the exit code. While advanced libstd features should probably require more specific targets (eg. wasm-unknown-web) I think even the unknown target should at least support basic I/O. Any solution is constrained by these factors: - It must not be javascript specific - There must not be too strong coupling between libstd and the host environment (because it's an "unknown" target) - WebAssembly does not allow "optional" imports - all imports *must* be resolved. - WebAssembly does not support calling the host environment through any channel *other* than imports. The best solution I could find to these constraints was to give libstd a single required import, and implement a syscall-style interface through that import. Each syscall is designed such that a no-op implementation gives the most reasonable fallback behaviour. This means that the following import table would be perfectly valid: ```javascript imports.env = { rust_wasm_syscall: function(index, data) {} } ``` Currently I have implemented these system calls: - Read from stdin - Write to stdout/stderr - Set the exit code - Get command line arguments - Get environment variable - Set environment variable - Get time It need not be extended beyond this set if being able to run tests for this target is the only goal. edit: As part of this PR I had to make a further change. Previously, the rust entry point would be automatically called when the webassembly module was instantiated. This was problematic because from the javascript side it was impossible to call exported functions, access program memory or get a reference to the instance. To solve this, ~I changed the default behaviour to not automatically call the entry point, and added a crate-level attribute to regain the old behaviour. (`#![wasm_auto_run]`)~ I disabled this behaviour when building tests.
2018-02-01Turn `type_id` into a constant intrinsicBadel2-0/+5
Add rustc_const_unstable attribute for `any::TypeId::of` Add test for `const fn TypeId::of`
2018-02-01rustc: prefer ParamEnvAnd and LayoutCx over tuples for LayoutOf.Eduard-Mihai Burtescu-2/+1
2018-01-31Rollup merge of #47891 - eddyb:issue-47638, r=nikomatsakiskennytm-1/+3
rustc_trans: keep LLVM types for trait objects anonymous. Fixes #47638 by reverting the addition of readable LLVM trait object type names. r? @nikomatsakis
2018-01-31Rollup merge of #47889 - alexcrichton:wasm-hidden-by-default, r=cramertjkennytm-0/+7
rustc: Add an option to default hidden visibility This commit adds a new option to target specifictions to specify that symbols should be "hidden" visibility by default in LLVM. While there are no existing targets that take advantage of this the `wasm32-unknown-unknown` target will soon start to use this visibility. The LLD linker currently interprets `hidden` as "don't export this from the wasm module" which is what we want for 90% of our functions. While the LLD linker does have a "export this symbol" argument which is what we use for other linkers, it was also somewhat easier to do this change instead which'll involve less arguments flying around. Additionally there's no need for non-`hidden` visibility for most of our symbols! This change should not immediately impact the wasm targets as-is, but rather this is laying the foundations for soon integrating LLD as a linker for wasm code.
2018-01-31Rollup merge of #47875 - jcowgill:mips-clobber-at, r=rkruppekennytm-2/+3
rustc_trans: clobber $1 (aka $at) on mips This copies what clang does. There is a long explanation as to why this is needed in the clang source (tools/clang/lib/Basic/Targets/Mips.h).
2018-01-30Export wasm source map when debug information is enabledYury Delendik-3/+15
We use binaryen's linker to produce a wasm file (via s2wasm). The wasm writer has capabilities to export source maps. The produced source map contains references to the original file, that might require additional source map file processing to include / package original files with it.
2018-01-30Implement extensible syscall interface for wasmDiggory Blake-4/+2
2018-01-31rustc_trans: keep LLVM types for trait objects anonymous.Eduard-Mihai Burtescu-1/+3
2018-01-30rustc: Add an option to default hidden visibilityAlex Crichton-0/+7
This commit adds a new option to target specifictions to specify that symbols should be "hidden" visibility by default in LLVM. While there are no existing targets that take advantage of this the `wasm32-unknown-unknown` target will soon start to use this visibility. The LLD linker currently interprets `hidden` as "don't export this from the wasm module" which is what we want for 90% of our functions. While the LLD linker does have a "export this symbol" argument which is what we use for other linkers, it was also somewhat easier to do this change instead which'll involve less arguments flying around. Additionally there's no need for non-`hidden` visibility for most of our symbols! This change should not immediately impact the wasm targets as-is, but rather this is laying the foundations for soon integrating LLD as a linker for wasm code.
2018-01-30rustc_trans: clobber $1 (aka $at) on mipsJames Cowgill-2/+3
This copies what clang does. There is a long explanation as to why this is needed in the clang source (tools/clang/lib/Basic/Targets/Mips.h).
2018-01-30Rollup merge of #47826 - gnzlbg:patch-2, r=alexcrichtonkennytm-2/+2
Whitelist v7 feature for ARM and AARCH64. Needed for `v7` features in `coresimd`. See https://github.com/rust-lang-nursery/stdsimd/blob/b2f7be24d5043a88427f9a5258ca9a51ede6d029/coresimd/src/arm/v7.rs#L40 which used to work but doesn't anymore. r? alexcrichton
2018-01-30Rollup merge of #47822 - gnzlbg:patch-1, r=alexcrichtonkennytm-1/+1
Whitelist aes x86 feature flag Required to fix https://github.com/rust-lang-nursery/stdsimd/issues/295 in stdsimd. Closes #44544 . r? @alexcrichton
2018-01-29Auto merge of #47837 - eddyb:going-places, r=nikomatsakisbors-7/+6
Replace "lvalue" terminology with "place". See #46425 for the previous PR (which only changed MIR-related code). r? @nikomatsakis
2018-01-28rustc: Split Emscripten to a separate codegen backendAlex Crichton-0/+7
This commit introduces a separately compiled backend for Emscripten, avoiding compiling the `JSBackend` target in the main LLVM codegen backend. This builds on the foundation provided by #47671 to create a new codegen backend dedicated solely to Emscripten, removing the `JSBackend` of the main codegen backend in the process. A new field was added to each target for this commit which specifies the backend to use for translation, the default being `llvm` which is the main backend that we use. The Emscripten targets specify an `emscripten` backend instead of the main `llvm` one. There's a whole bunch of consequences of this change, but I'll try to enumerate them here: * A *second* LLVM submodule was added in this commit. The main LLVM submodule will soon start to drift from the Emscripten submodule, but currently they're both at the same revision. * Logic was added to rustbuild to *not* build the Emscripten backend by default. This is gated behind a `--enable-emscripten` flag to the configure script. By default users should neither check out the emscripten submodule nor compile it. * The `init_repo.sh` script was updated to fetch the Emscripten submodule from GitHub the same way we do the main LLVM submodule (a tarball fetch). * The Emscripten backend, turned off by default, is still turned on for a number of targets on CI. We'll only be shipping an Emscripten backend with Tier 1 platforms, though. All cross-compiled platforms will not be receiving an Emscripten backend yet. This commit means that when you download the `rustc` package in Rustup for Tier 1 platforms you'll be receiving two trans backends, one for Emscripten and one that's the general LLVM backend. If you never compile for Emscripten you'll never use the Emscripten backend, so we may update this one day to only download the Emscripten backend when you add the Emscripten target. For now though it's just an extra 10MB gzip'd. Closes #46819
2018-01-29rustc: replace "lvalue" terminology with "place" in the code.Eduard-Mihai Burtescu-2/+2
2018-01-29rustc: remove `LvaluePreference` argument from `Ty::builtin_deref`.Eduard-Mihai Burtescu-5/+4
2018-01-28Whitelist v7 feature for ARM and AARCH64.gnzlbg-2/+2
Needed for `v7` features in `coresimd`. See https://github.com/rust-lang-nursery/stdsimd/blob/b2f7be24d5043a88427f9a5258ca9a51ede6d029/coresimd/src/arm/v7.rs#L40 which used to work but doesn't anymore. r? alexcrichton
2018-01-28Auto merge of #47794 - etaoins:fix-ice-on-const-eval-of-union-field, r=eddybbors-1/+4
Fix ICE on const eval of union field MIR's `Const::get_field()` attempts to retrieve the value for a given field in a constant. In the case of a union constant it was falling through to a generic `const_get_elt` based on the field index. As union fields don't have an index this caused an ICE in `llvm_field_index`. Fix by simply returning the current value when accessing any field in a union. This works because all union fields start at byte offset 0. The added test uses `const_fn` it ensure the field is extracted using MIR's const evaluation. The crash is reproducible without it, however. Fixes #47788 r? @eddyb
2018-01-28Whitelist aes x86 feature flaggnzlbg-1/+1
Required to fix https://github.com/rust-lang-nursery/stdsimd/issues/295 in stdsimd. r? @alexcrichton
2018-01-27rustc: Load the `rustc_trans` crate at runtimeAlex Crichton-5/+25
Building on the work of # 45684 this commit updates the compiler to unconditionally load the `rustc_trans` crate at runtime instead of linking to it at compile time. The end goal of this work is to implement # 46819 where rustc will have multiple backends available to it to load. This commit starts off by removing the `extern crate rustc_trans` from the driver. This involved moving some miscellaneous functionality into the `TransCrate` trait and also required an implementation of how to locate and load the trans backend. This ended up being a little tricky because the sysroot isn't always the right location (for example `--sysroot` arguments) so some extra code was added as well to probe a directory relative to the current dll (the rustc_driver dll). Rustbuild has been updated accordingly as well to have a separate compilation invocation for the `rustc_trans` crate and assembly it accordingly into the sysroot. Finally, the distribution logic for the `rustc` package was also updated to slurp up the trans backends folder. A number of assorted fallout changes were included here as well to ensure tests pass and such, and they should all be commented inline.
2018-01-27Fix ICE on const eval of union fieldRyan Cumming-1/+4
MIR's `Const::get_field()` attempts to retrieve the value for a given field in a constant. In the case of a union constant it was falling through to a generic `const_get_elt` based on the field index. As union fields don't have an index this caused an ICE in `llvm_field_index`. Fix by simply returning the current value when accessing any field in a union. This works because all union fields start at byte offset 0. The added test uses `const_fn` it ensure the field is extracted using MIR's const evaluation. The crash is reproducible without it, however. Fixes #47788
2018-01-26Merge branch 'simd-always-mem' of https://github.com/alexcrichton/rust into ↵Alex Crichton-0/+25
rollup
2018-01-26Merge branch 'llvm5-indirect-deref' of https://github.com/cuviper/rust into ↵Alex Crichton-7/+9
rollup
2018-01-26Merge branch 'no-stderr-sink' of https://github.com/Zoxc/rust into rollupAlex Crichton-2/+2
2018-01-26Do not capture stderr in the compiler. Instead just panic silently for fatal ↵John Kåre Alsaker-2/+2
errors
2018-01-25Merge branch 'configure-lto' of https://github.com/alexcrichton/rust into rollupAlex Crichton-66/+80
2018-01-25Rollup merge of #47710 - alexcrichton:llvm-6-compat, r=nikomatsakisAlex Crichton-17/+19
First round of LLVM 6.0.0 compatibility This includes a number of commits for the first round of upgrading to LLVM 6. There are still [lingering bugs](https://github.com/rust-lang/rust/issues/47683) but I believe all of this will nonetheless be necessary!
2018-01-25Rollup merge of #47626 - eddyb:one-less-unwrap, r=nagisaAlex Crichton-26/+30
rustc_trans: remove an unwrap by replacing a bool with Result. Prompted by @shepmaster. r? @nagisa
2018-01-25Rollup merge of #47618 - mrhota:dw_at_noreturn, r=michaelwoeristerAlex Crichton-0/+3
Teach rustc about DW_AT_noreturn and a few more DIFlags We achieve two small things with this PR: 1. We provide definitions for a few additional llvm debuginfo flags 1. We _use_ one of these new flags, `FlagNoReturn`, and add it to debuginfo for functions with the never return type (`!`).
2018-01-25rustc: SIMD types use pointers in Rust's ABIAlex Crichton-0/+25
This commit changes the ABI of SIMD types in the "Rust" ABI to unconditionally be passed via pointers instead of being passed as immediates. This should fix a longstanding issue, #44367, where SIMD-using programs ended up showing very odd behavior at runtime because the ABI between functions was mismatched. As a bit of a recap, this is sort of an LLVM bug and sort of an LLVM feature (today's behavior). LLVM will generate code for a function solely looking at the function it's generating, including calls to other functions. Let's then say you've got something that looks like: ```llvm define void @foo() { ; no target features enabled call void @bar(<i64 x 4> zeroinitializer) ret void } define void @bar(<i64 x 4>) #0 { ; enables the AVX feature ... } ``` LLVM will codegen the call to `bar` *without* using AVX registers becauase `foo` doesn't have access to these registers. Instead it's generated with emulation that uses two 128-bit registers. The `bar` function, on the other hand, will expect its argument in an AVX register (as it has AVX enabled). This means we've got a codegen problem! Comments on #44367 have some more contexutal information but the crux of the issue is that if we want SIMD to work in general we'll need to ensure that whenever a function calls another they ABI of the arguments being passed is in agreement. One possible solution to this would be to insert "shim functions" where whenever a `target_feature` mismatch is detected the compiler inserts a shim function where you pass arguments via memory to the shim and then the shim loads the values and calls the target function (where the shim and the target have the same target features enabled). This unfortunately is quite nontrivial to implement in rustc today (especially when accounting for function pointers and such). This commit takes a different solution, *always* passing SIMD arguments through memory instead of passing as immediates. This strategy solves the problem at the LLVM layer because the ABI between two functions never uses SIMD registers. This also shouldn't be a hit to performance because SIMD performance is thought to often rely on inlining anyway, where a `call` instruction, even if using SIMD registers, would be disastrous to performance regardless. LLVM should then be more than capable of fixing all our memory usage to use registers instead after enough inlining has been performed. Note that there's a few caveats to this commit though: * The "platform intrinsic" ABI is omitted from "always pass via memory". This ABI is used to define intrinsics like `simd_shuffle4` where LLVM and rustc need to have the arguments as an immediate. * Additionally this commit does *not* fix the `extern` ("C") ABI. This means that the bug in #44367 can still happen when using non-Rust-ABI functions. My hope is that before stabilization we can ban and/or warn about SIMD types in these functions (as AFAIK there's not much motivation to belong there anyway), but I'll leave that for a later commit and if this is merged I'll file a follow-up issue. All in all this... Closes #44367
2018-01-25Rollup merge of #47453 - pftbest:nointas, r=alexcrichtonAlex Crichton-52/+57
Fix no_integrated_as option to work with new codegen architecture. Old implementation called the assembler once per crate, but we need to call it for each object file instead, because a single crate can now have more than one object file. This patch fixes issue #45836 (Can't compile core for msp430 in release mode) This change can be tested on x86_64 using ```sh export RUSTFLAGS="-C no_integrated_as -C save_temps" ``` r? @alexcrichton cc @japaric
2018-01-25Rollup merge of #47439 - eddyb:issue-45662, r=nagisaAlex Crichton-6/+6
rustc_trans: ignore trailing padding larger than 8 bytes. Fixes #45662 by ignoring a missing second register component, as it could be entirely padding.
2018-01-25Rollup merge of #47437 - eddyb:issue-38763, r=nagisaAlex Crichton-55/+43
rustc_trans: take into account primitives larger than 8 bytes. Fixes #38763 by marking all "eightbytes" covered by a primitive appropriately, not just the first.
2018-01-25Rollup merge of #47415 - varkor:cgu-partition-heuristic, r=michaelwoeristerAlex Crichton-5/+3
Add CGU size heuristic for partitioning This addresses the concern of #47316 by estimating CGU size based on the size of its MIR. Looking at the size estimate differences for a small selection of crates, this heuristic produces different orderings, which should more accurately reflect optimisation time. (Fixes #47316.) r? @michaelwoerister
2018-01-24llvm6: Don't clone LLVM modules on wasmAlex Crichton-2/+2
The comment for why cloning exists doesn't actually apply for wasm today and apparently cloning is causing subtle bugs in LLVM, so let's just avoid it altogether. More specifically after we emit the assembly for the wasm target we don't actually use the module again, so there's no need to keep both around. This seemed to be causing some scary verifier assertions in LLVM which seemed to be uncovered by presumably (?) buggy behavior. Let's just avoid it for now and make the wasm target slightly more lean in the process.