summary refs log tree commit diff
path: root/src/librustc_trans
AgeCommit message (Collapse)AuthorLines
2018-04-25Only warn on erroneous promoted constantsOliver Schneider-1/+8
2018-04-20Use InternedString instead of Symbol for type parameters.Michael Woerister-3/+3
2018-04-20Fix ICE with `main`'s return type containing lifetimesShotaro Yamada-4/+8
2018-04-20Rollup merge of #50046 - michaelwoerister:backport-no-debug, r=alexcrichtonkennytm-7/+15
Backport of #49904 See #49904.
2018-04-18Clean up attribute handling in create_function_debug_context().Michael Woerister-4/+5
2018-04-18Support #[no_debug] for global variables.Michael Woerister-3/+10
2018-04-17Stop referring to statics' AllocIds directlyOliver Schneider-8/+7
2018-03-29rustc: Group linked libraries where neededAlex Crichton-0/+91
This commit fixes a longstanding issue with the compiler with circular dependencies between libcore and libstd. The `core` crate requires at least one symbol, the ability to unwind. The `std` crate is the crate which actually defines this symbol, but the `std` crate also depends on the `core` crate. This circular dependency is in general disallowed in Rust as crates cannot have cycles amongst them. A special exception is made just for core/std, but this is also unfortunately incompatible with how GNU linkers work. GNU linkers will process undefined symbols in a left-to-right fashion, only actually linking an rlib like libstd if there are any symbols used from it. This strategy is incompatible with circular dependencies because if we otherwise don't use symbols from libstd we don't discover that we needed it until we're later processing libcore's symbols! To fix this GNU linkers support the `--start-group` and `--end-group` options which indicate "libraries between these markers may have circular dependencies amongst them. The linker invocation has been updated to automatically pass these arguments when we're invoking a GNU linker and automatically calculate where the arguments need to go (around libstd and libcore) Closes #18807 Closes #47074
2018-03-28Rollup merge of #49329 - canarysnort01:fix-no-pie, r=pnkfelixkennytm-2/+4
don't pass -no-pie to gnu ld fixes #48884
2018-03-28Auto merge of #49019 - phil-opp:target-spec, r=pnkfelixbors-7/+9
Introduce a TargetTriple enum to support absolute target paths This PR replaces target triple strings with a `TargetTriple` enum, which represents either a target triple or a path to a JSON target file. The path variant is used if the `--target` argument has a `.json` extension, else the target triple variant is used. The motivation of this PR is support for absolute target paths to avoid the need for setting the `RUST_TARGET_PATH` environment variable (see rust-lang/cargo#4905 for more information). For places where some kind of triple is needed (e.g. in the sysroot folder), we use the file name (without extension). For compatibility, we keep the old behavior of searching for a file named `$(target_triple).json` in `RUST_TARGET_PATH` for non-official target triples.
2018-03-27Auto merge of #49249 - gnzlbg:simd_minmax, r=alexcrichtonbors-0/+23
implement minmax intrinsics This adds the `simd_{fmin,fmax}` intrinsics, which do a vertical (lane-wise) `min`/`max` for floating point vectors that's equivalent to Rust's `min`/`max` for `f32`/`f64`. It might make sense to make `{f32,f64}::{min,max}` use the `minnum` and `minmax` intrinsics as well. --- ~~HELP: I need some help with these. Either I should go to sleep or there must be something that I must be missing. AFAICT I am calling the `maxnum` builder correctly, yet rustc/LLVM seem to insert a call to `llvm.minnum` there instead...~~ EDIT: Rust's LLVM version is too old :/
2018-03-26Auto merge of #49101 - mark-i-m:stabilize_i128, r=nagisabors-2/+1
Stabilize 128-bit integers :tada: cc #35118 EDIT: This should be merged only after the following have been merged: - [x] https://github.com/rust-lang-nursery/compiler-builtins/pull/236 - [x] https://github.com/rust-lang/book/pull/1230
2018-03-26Introduce a TargetTriple enum to support absolute target pathsPhilipp Oppermann-7/+9
2018-03-26Stabilize i128 feature tooMark Mansi-2/+1
2018-03-26Stabilize i128_typeMark Mansi-1/+1
2018-03-26Auto merge of #48346 - emilio:pgo, r=alexcrichtonbors-7/+102
Add basic PGO support. This PR adds two mutually exclusive options for profile usage and generation using LLVM's instruction profile generation (the same as clang uses), `-C pgo-use` and `-C pgo-gen`. See each commit for details.
2018-03-26Stabilize conservative_impl_traitTaylor Cramer-1/+1
2018-03-26properly handle the case when LLVM does not have min/maxnumgnzlbg-2/+6
2018-03-26require llvm 6gnzlbg-2/+6
2018-03-26implement minmax intrinsicsgnzlbg-0/+15
2018-03-26Auto merge of #49297 - scottmcm:offset-from, r=dtolnaybors-1/+14
Introduce unsafe offset_from on pointers Adds intrinsics::exact_div to take advantage of the unsafe, which reduces the implementation from ```asm sub rcx, rdx mov rax, rcx sar rax, 63 shr rax, 62 lea rax, [rax + rcx] sar rax, 2 ret ``` down to ```asm sub rcx, rdx sar rcx, 2 mov rax, rcx ret ``` (for `*const i32`) See discussion on the `offset_to` tracking issue https://github.com/rust-lang/rust/issues/41079 Some open questions - Would you rather I split the intrinsic PR from the library PR? - Do we even want the safe version of the API? https://github.com/rust-lang/rust/issues/41079#issuecomment-374426786 I've added some text to its documentation that even if it's not UB, it's useless to use it between pointers into different objects. and todos - [x] ~~I need to make a codegen test~~ Done - [x] ~~Can the subtraction use nsw/nuw?~~ No, it can't https://github.com/rust-lang/rust/pull/49297#discussion_r176697574 - [x] ~~Should there be `usize` variants of this, like there are now `add` and `sub` that you almost always want over `offset`? For example, I imagine `sub_ptr` that returns `usize` and where it's UB if the distance is negative.~~ Can wait for later; C gives a signed result https://github.com/rust-lang/rust/issues/41079#issuecomment-375842235, so we might as well, and this existing to go with `offset` makes sense.
2018-03-25Auto merge of #49212 - kyrias:strip-debug-no-debuginfo, r=michaelwoeristerbors-1/+12
Pass --strip-debug to GccLinker when building without debuginfo C.f. #46034 --- This brings a hello-world built by passing rustc no command line options from 2.9M to 592K on Linux. (This might need to special case MacOS or Windows, not sure if the linkers there support `--strip-debug`, and there is an annoying lack of dependable docs for the linkers there.)
2018-03-25Move linker code to the Linker trait instead.Emilio Cobos Álvarez-14/+32
2018-03-25try to fix the build on older LLVM versions.Emilio Cobos Álvarez-0/+7
2018-03-25librustc_trans: Mark some profiler symbols as exported to avoid LTO removing ↵Emilio Cobos Álvarez-0/+14
them.
2018-03-25librustc_trans: Turn PGO diagnostics into warnings.Emilio Cobos Álvarez-1/+1
They should at least be that, they usually warn about control flow mismatches, and or the profile being useless, which looks like at least a warning to me. Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2018-03-25librustc_trans: Gate the preinliner with another -Z flag.Emilio Cobos Álvarez-1/+3
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2018-03-25librustc: Convert -C pgo-gen and -C pgo-use into -Z flags.Emilio Cobos Álvarez-4/+6
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2018-03-25librustc_trans: disable profiling pre-inlining.Emilio Cobos Álvarez-0/+1
It destroys performance actually. Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2018-03-25librustc_llvm: Show PGO diagnostics properly.Emilio Cobos Álvarez-2/+7
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2018-03-25rustc_trans: Fix PGO generation linking on Linux by adding the relevant ↵Emilio Cobos Álvarez-0/+14
linker commands. See the linked LLVM reviews for the clang counter-parts. Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2018-03-25rustc_trans: disable probestack when using pgo-gen.Emilio Cobos Álvarez-0/+5
Executables crash in the probestack function otherwise... I haven't debugged much further than that. Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2018-03-25rustc_llvm: rustc_trans: Thread the PGO config down to the pass manager builder.Emilio Cobos Álvarez-5/+32
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2018-03-25Auto merge of #49141 - gnzlbg:simd_select, r=alexcrichtonbors-0/+21
adds simd_select intrinsic The select SIMD intrinsic is used to select elements from two SIMD vectors using a mask: ```rust let mask = b8x4::new(true, false, false, true); let a = f32x4::new(1., 2., 3., 4.); let b = f32x4::new(5., 6., 7., 8.); assert_eq!(simd_select(mask, a, b), f32x4::new(1., 6., 7., 4.)); ``` The number of lanes between the mask and the vectors must match, but the vector width of the mask does not need to match that of the vectors. The mask is required to be a vector of signed integers. Note: this intrinsic will be exposed via `std::simd`'s vector masks - users are not expected to use it directly.
2018-03-24Add flag for telling the linker to strip debuginfo when building without itJohannes Löthberg-1/+12
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
2018-03-25Rollup merge of #49122 - scottmcm:z-align-attr, r=cramertjkennytm-1/+1
Add a -Z flag for LLVM align attributes on arguments LLVM seems to still put the assume calls in when inlining, so this probably isn't in a place where it can be turned on by default, but it's interesting to experiment with. For example, this makes `mem::swap::<u64x8>` be 8x `vmovaps ymm` instead of 16x `vmovups xmm`, on my cpu.
2018-03-24don't pass -no-pie to gnu ldJimmy Brush-2/+4
fixes #48884
2018-03-24Auto merge of #48482 - davidtwco:issue-47184, r=nikomatsakisbors-0/+1
NLL should identify and respect the lifetime annotations that the user wrote Part of #47184. r? @nikomatsakis
2018-03-23Introduce unsafe offset_from on pointersScott McMurray-1/+14
Adds intrinsics::exact_div to take advantage of the unsafe, which reduces the implementation from ```asm sub rcx, rdx mov rax, rcx sar rax, 63 shr rax, 62 lea rax, [rax + rcx] sar rax, 2 ret ``` down to ```asm sub rcx, rdx sar rcx, 2 mov rax, rcx ret ``` (for `*const i32`)
2018-03-22Added UserAssertTy statement.David Wood-0/+1
2018-03-22rustc: Add a `#[wasm_import_module]` attributeAlex Crichton-20/+331
This commit adds a new attribute to the Rust compiler specific to the wasm target (and no other targets). The `#[wasm_import_module]` attribute is used to specify the module that a name is imported from, and is used like so: #[wasm_import_module = "./foo.js"] extern { fn some_js_function(); } Here the import of the symbol `some_js_function` is tagged with the `./foo.js` module in the wasm output file. Wasm-the-format includes two fields on all imports, a module and a field. The field is the symbol name (`some_js_function` above) and the module has historically unconditionally been `"env"`. I'm not sure if this `"env"` convention has asm.js or LLVM roots, but regardless we'd like the ability to configure it! The proposed ES module integration with wasm (aka a wasm module is "just another ES module") requires that the import module of wasm imports is interpreted as an ES module import, meaning that you'll need to encode paths, NPM packages, etc. As a result, we'll need this to be something other than `"env"`! Unfortunately neither our version of LLVM nor LLD supports custom import modules (aka anything not `"env"`). My hope is that by the time LLVM 7 is released both will have support, but in the meantime this commit adds some primitive encoding/decoding of wasm files to the compiler. This way rustc postprocesses the wasm module that LLVM emits to ensure it's got all the imports we'd like to have in it. Eventually I'd ideally like to unconditionally require this attribute to be placed on all `extern { ... }` blocks. For now though it seemed prudent to add it as an unstable attribute, so for now it's not required (as that'd force usage of a feature gate). Hopefully it doesn't take too long to "stabilize" this! cc rust-lang-nursery/rust-wasm#29
2018-03-22rustc: Add a `#[wasm_custom_section]` attributeAlex Crichton-1/+150
This commit is an implementation of adding custom sections to wasm artifacts in rustc. The intention here is to expose the ability of the wasm binary format to contain custom sections with arbitrary user-defined data. Currently neither our version of LLVM nor LLD supports this so the implementation is currently custom to rustc itself. The implementation here is to attach a `#[wasm_custom_section = "foo"]` attribute to any `const` which has a type like `[u8; N]`. Other types of constants aren't supported yet but may be added one day! This should hopefully be enough to get off the ground with *some* custom section support. The current semantics are that any constant tagged with `#[wasm_custom_section]` section will be *appended* to the corresponding section in the final output wasm artifact (and this affects dependencies linked in as well, not just the final crate). This means that whatever is interpreting the contents must be able to interpret binary-concatenated sections (or each constant needs to be in its own custom section). To test this change the existing `run-make` test suite was moved to a `run-make-fulldeps` folder and a new `run-make` test suite was added which applies to all targets by default. This test suite currently only has one test which only runs for the wasm target (using a node.js script to use `WebAssembly` in JS to parse the wasm output).
2018-03-22Rollup merge of #49231 - gnzlbg:fix_vec_fminmax, r=rkruppekennytm-4/+4
fix vector fmin/fmax non-fast/fast intrinsics NaN handling This bugs shows up in release mode tests of `stdsimd`: https://github.com/rust-lang-nursery/stdsimd/pull/391 . The intrinsics are thoroughly tested there for roundoff errors, NaN, and overflow behavior. The problem was that the non-fast intrinsics where specifying `NoNaNs == true`, which meant that they don't support NaNs. This is incorrect, the non-fast intrinsics should handle NaNs properly. Also, the "fast" intrinsics where specifying `NoNaNs == false` which meant that they support NaNs and then fast-math, which probably disables this support. This was not intended either. I've added a comment specifying what the boolean flags do.
2018-03-22Rollup merge of #49225 - QuietMisdreavus:all-the-features-all-the-time, ↵kennytm-4/+26
r=alexcrichton whitelist every target feature for rustdoc When https://github.com/rust-lang-nursery/stdsimd/pull/367 was attempted to be upstreamed, it failed to document on non-x86 targets because it made every intrinsic visible, even the ones on foreign arches. This change makes it so that whenever rustdoc asks for the target feature whitelist, it gets a list of every feature known to every arch in `rustc_trans/llvm_util.rs`. Before pushing, i temporarily updated the `stdsimd` submodule to include the `doc(cfg)` change, generated documentation for `aarch64-unknown-linux-gnu`, and it completed without a problem. The generated `core::arch` docs contained complete submodules for all main arches.
2018-03-21fix vector fmin/fmax non-fast/fast intrinsics NaN handlinggnzlbg-4/+4
2018-03-20whitelist every target feature for rustdocQuietMisdreavus-4/+26
2018-03-20Auto merge of #49190 - kennytm:rollup, r=kennytmbors-4/+4
Rollup of 17 pull requests - Successful merges: #46518, #48810, #48834, #48902, #49004, #49092, #49096, #49099, #49104, #49125, #49139, #49152, #49157, #49161, #49166, #49176, #49184 - Failed merges:
2018-03-20Stabilize slice patterns without `..`Vadim Petrochenkov-1/+1
Merge `feature(advanced_slice_patterns)` into `feature(slice_patterns)`
2018-03-20Rollup merge of #49092 - mark-i-m:deptrack_readme, r=nikomatsakiskennytm-4/+4
Replace many of the last references to readmes In particular, this removes the dep track readme, so it should not be merged before https://github.com/rust-lang-nursery/rustc-guide/pull/92 Fix #47935 cc #48478 r? @nikomatsakis
2018-03-18add simd_select intrinsicgnzlbg-0/+21