summary refs log tree commit diff
path: root/src/librustc_codegen_llvm/back
AgeCommit message (Collapse)AuthorLines
2018-07-30Auto merge of #52805 - ljedrz:format_str_literal, r=petrochenkovbors-17/+17
Don't format!() string literals Prefer `to_string()` to `format!()` take 2, this time targetting string literals. In some cases (`&format!("...")` -> `"..."`) also removes allocations. Occurences of `format!("")` are changed to `String::new()`.
2018-07-29Auto merge of #52738 - ljedrz:push_to_extend, r=eddybbors-3/+1
Replace push loops with extend() where possible Or set the vector capacity where I couldn't do it. According to my [simple benchmark](https://gist.github.com/ljedrz/568e97621b749849684c1da71c27dceb) `extend`ing a vector can be over **10 times** faster than `push`ing to it in a loop: 10 elements (6.1 times faster): ``` test bench_extension ... bench: 75 ns/iter (+/- 23) test bench_push_loop ... bench: 458 ns/iter (+/- 142) ``` 100 elements (11.12 times faster): ``` test bench_extension ... bench: 87 ns/iter (+/- 26) test bench_push_loop ... bench: 968 ns/iter (+/- 3,528) ``` 1000 elements (11.04 times faster): ``` test bench_extension ... bench: 311 ns/iter (+/- 9) test bench_push_loop ... bench: 3,436 ns/iter (+/- 233) ``` Seems like a good idea to use `extend` as much as possible.
2018-07-29Replace push loops with collect() and extend() where possibleljedrz-3/+1
2018-07-29Auto merge of #52767 - ljedrz:avoid_format, r=petrochenkovbors-2/+2
Prefer to_string() to format!() Simple benchmarks suggest in some cases it can be faster by even 37%: ``` test converting_f64_long ... bench: 339 ns/iter (+/- 199) test converting_f64_short ... bench: 136 ns/iter (+/- 34) test converting_i32_long ... bench: 87 ns/iter (+/- 16) test converting_i32_short ... bench: 87 ns/iter (+/- 49) test converting_str ... bench: 54 ns/iter (+/- 15) test formatting_f64_long ... bench: 349 ns/iter (+/- 176) test formatting_f64_short ... bench: 145 ns/iter (+/- 14) test formatting_i32_long ... bench: 98 ns/iter (+/- 14) test formatting_i32_short ... bench: 93 ns/iter (+/- 15) test formatting_str ... bench: 86 ns/iter (+/- 23) ```
2018-07-29Auto merge of #52764 - sinkuu:cleanup, r=nikomatsakisbors-3/+2
Misc cleanups
2018-07-28Don't format!() string literalsljedrz-17/+17
2018-07-28Rollup merge of #52703 - ljedrz:vec_improvements, r=nikomatsakiskennytm-2/+3
Improve a few vectors - calculate capacity or build from iterators Collecting from iterators improves readability and tailoring vector capacities should be beneficial in terms of performance.
2018-07-27Unnecessary `to_string`Shotaro Yamada-3/+2
2018-07-27Prefer to_string() to format!()ljedrz-2/+2
2018-07-26Improve a few vectors - calculate capacity or build from iteratorsljedrz-2/+3
2018-07-26Rollup merge of #52654 - alecmocatta:master, r=alexcrichtonMark Rousskov-17/+19
Format linker args in a way that works for gcc and ld Pass multiple linker arguments rather than concatenate with commas (fixes #52634). `-l library` -> `-llibrary` to work with apple's ld. To build with apple's ld I'm currently also passing `-C link-args="-arch x86_64 -macosx_version_min 10.13.0"`. I'll try and understand the latter flag better before PRing that. This PR currently works for me. Hopefully CI will pick up any grievous ramifications in other toolchains? Thanks to @alexcrichton for the pointer to the relevant code!
2018-07-24break --subsystem=x into 2 args; closer to former presumably known-good ↵alecmocatta-1/+2
incantation
2018-07-24Pass multiple linker arguments rather than concatenate with commas; -l ↵alecmocatta-17/+18
library -> -llibrary to work with apple's ld
2018-07-23Replace a few expect+format combos with unwrap_or_else+panicljedrz-2/+2
2018-07-21Rollup merge of #52505 - alexcrichton:remove-thinlto-hack, r=nikomatsakiskennytm-14/+0
rustc: Remove a workaround in ThinLTO fixed upstream This commit removes a hack in our ThinLTO passes which removes available externally functions manually. The [upstream bug][1] has long since been fixed, so we should be able to rely on LLVM natively for this now! [1]: https://bugs.llvm.org/show_bug.cgi?id=35736
2018-07-18rustc: Remove a workaroudn in ThinLTO fixed upstreamAlex Crichton-14/+0
This commit removes a hack in our ThinLTO passes which removes available externally functions manually. The [upstream bug][1] has long since been fixed, so we should be able to rely on LLVM natively for this now! [1]: https://bugs.llvm.org/show_bug.cgi?id=35736
2018-07-18rustc: Stabilize #[wasm_import_module] as #[link(...)]Alex Crichton-26/+39
This commit stabilizes the `#[wasm_import_module]` attribute as `#[link(wasm_import_module = "...")]`. Tracked by #52090 this new directive in the `#[link]` attribute is used to configured the module name that the imports are listed with. The WebAssembly specification indicates two utf-8 names are associated with all imported items, one for the module the item comes from and one for the item itself. The item itself is configurable in Rust via its identifier or `#[link_name = "..."]`, but the module name was previously not configurable and defaulted to `"env"`. This commit ensures that this is also configurable. Closes #52090
2018-07-16ItemKindcsmoe-2/+2
2018-07-16Revert "Provide a way of accessing the ThinLTO module import map in rustc."Michael Woerister-68/+1
This reverts commit 9df56ca0eea1a8f5af945df25ce23e276b1d48a7.
2018-07-16Revert "Persist ThinLTO import data in incr. comp. session directory."Michael Woerister-81/+2
This reverts commit 8dc7ddb9763f28b83de7bf3b3025f8042ea9e830.
2018-07-16Revert "Clean up LLVM module naming (just use CodegenUnit names)."Michael Woerister-6/+15
This reverts commit f6894ebe664d111259a91a2b5fcc1236ca413436.
2018-07-16Revert "Use callback-based interface to load ThinLTO import data into rustc."Michael Woerister-31/+43
This reverts commit e045a6cd8c0235a26ef11e6cd9a13ebd817f1265.
2018-07-15Auto merge of #52381 - oli-obk:ty_to_def_id, r=eddybbors-11/+9
Remove `ty_to_def_id` fixes https://github.com/rust-lang/rust/issues/52341 The uses were mostly convenience and generally "too powerful" (would also have worked for types that weren't interesting at the use site) r? @eddyb
2018-07-15Ubsan this newly discovered dead codeOliver Schneider-14/+9
2018-07-14Expose a self-referential objectOliver Schneider-0/+3
2018-07-13Auto merge of #52266 - michaelwoerister:incr-thinlto-preliminaries, ↵bors-18/+143
r=alexcrichton Preliminary work for incremental ThinLTO. Since implementing incremental ThinLTO is a bit more involved than I initially thought, I'm splitting out some of the things that already work. This PR (1) adds a way accessing some ThinLTO information in `rustc` and (2) does some cleanup around CGU/object file naming (which makes things quite a bit nicer). This is probably best reviewed one commit at a time.
2018-07-13Use callback-based interface to load ThinLTO import data into rustc.Michael Woerister-43/+31
2018-07-11Clean up LLVM module naming (just use CodegenUnit names).Michael Woerister-15/+6
2018-07-11Rollup merge of #52252 - ljedrz:dyn_librustc_codegen_llvm, r=varkorMark Rousskov-24/+24
Deny bare trait objects in in src/librustc_codegen_llvm Enforce `#![deny(bare_trait_objects)]` in `src/librustc_codegen_llvm`.
2018-07-11Persist ThinLTO import data in incr. comp. session directory.Michael Woerister-2/+81
2018-07-11Provide a way of accessing the ThinLTO module import map in rustc.Michael Woerister-1/+68
2018-07-11Auto merge of #51230 - nikic:no-verify-lto, r=pnkfelixbors-10/+15
Disable LLVM verification by default Currently -Z no-verify only controls IR verification prior to LLVM codegen, while verification is performed unconditionally both before and after linking with (Thin)LTO. Also wondering what the sentiment is on disabling verification by default (and e.g. only enabling it on ALT builds with assertions). This does not seem terribly useful outside of rustc development and it does seem to show up in profiles (at something like 3%). **EDIT:** A table showing the various configurations and what is enabled when. | Configuration | Dynamic verification performed | LLVM static assertions compiled in | | --- | --- | --- | | alt builds | | yes | | nightly builds | | no | | stable builds | | no | | CI builds | | | | dev builds in a checkout | | |
2018-07-11Deny bare trait objects in in src/librustc_codegen_llvmljedrz-24/+24
2018-07-10Upgrade to LLVM's master branch (LLVM 7)Alex Crichton-47/+38
This commit upgrades the main LLVM submodule to LLVM's current master branch. The LLD submodule is updated in tandem as well as compiler-builtins. Along the way support was also added for LLVM 7's new features. This primarily includes the support for custom section concatenation natively in LLD so we now add wasm custom sections in LLVM IR rather than having custom support in rustc itself for doing so. Some other miscellaneous changes are: * We now pass `--gc-sections` to `wasm-ld` * The optimization level is now passed to `wasm-ld` * A `--stack-first` option is passed to LLD to have stack overflow always cause a trap instead of corrupting static data * The wasm target for LLVM switched to `wasm32-unknown-unknown`. * The syntax for aligned pointers has changed in LLVM IR and tests are updated to reflect this. * The `thumbv6m-none-eabi` target is disabled due to an [LLVM bug][llbug] Nowadays we've been mostly only upgrading whenever there's a major release of LLVM but enough changes have been happening on the wasm target that there's been growing motivation for quite some time now to upgrade out version of LLD. To upgrade LLD, however, we need to upgrade LLVM to avoid needing to build yet another version of LLVM on the builders. The revision of LLVM in use here is arbitrarily chosen. We will likely need to continue to update it over time if and when we discover bugs. Once LLVM 7 is fully released we can switch to that channel as well. [llbug]: https://bugs.llvm.org/show_bug.cgi?id=37382
2018-07-07Auto merge of #52109 - michaelwoerister:ir-objs, r=alexcrichtonbors-6/+5
When doing linker-plugin based LTO, write LLVM bitcode obj-files instead of embedding the bitcode into the regular object file. This PR makes the compiler emit LLVM bitcode object files instead of regular object files with the IR embed when compiling for linker-plugin-based LTO. The reasoning for switching the strategy is this: - Embedding bitcode in a section of the object file actually makes us save bitcode twice in rlibs and Rust dylibs, once for linker-based LTO and once for rustc-based LTO. That's a waste of space. - When compiling for plugin-based LTO, one usually has no use for the machine code also present in the object file. Generating it is a waste of time. - When compiling for plugin-based LTO, `rustc` will skip running ThinLTO because the linker will do that anyway. This has the side effect of then generating poorly optimized machine code, which makes it even less useful (and may lead to users not knowing why their code is slow instead of getting an error). - Not having machine code available makes it impossible for the linker to silently fall back to not inlining stuff across language boundaries. - This is what Clang does and according to [the documentation](https://llvm.org/docs/BitCodeFormat.html#native-object-file-wrapper-format) is the better supported option. - The current behavior (minus the runtime performance problems) is still available via `-Z embed-bitcode` (we might want to do this for `libstd` at some point). r? @alexcrichton
2018-07-06Remove CrossLangLto::NoLink which does not have a use case anymore.Michael Woerister-2/+1
2018-07-06When doing linker-plugin based LTO, write LLVM bitcode obj-filesMichael Woerister-4/+4
instead of embedding the bitcode into the regular object file.
2018-07-06Rollup merge of #52055 - crlf0710:patch-3, r=Mark-Simulacrumkennytm-2/+2
Include VS 2017 in error message. Update error prompt message to indicate that VS 2017 is supported (for a while now).
2018-07-04Shorten the lineCrLF0710-2/+2
Shorten the line to make tidy happy.
2018-07-04Include VS 2017 in error message.CrLF0710-1/+1
Update error prompt message to indicate that VS 2017 is supported (for a while now).
2018-07-03Allow the linker to choose the LTO-plugin (which is useful when using LLD)Michael Woerister-25/+36
2018-06-27Make opaque::Encoder append-only and make it infallibleJohn Kåre Alsaker-2/+1
2018-06-20Fix tidyBastien Orivel-1/+4
2018-06-20Replace tempdir by tempfile in librustc_transBastien Orivel-3/+3
2018-06-14rustc: rename ty::maps to ty::query.Eduard-Mihai Burtescu-1/+1
2018-06-12Rename -Z no-verify to -Z verify-llvm-irNikita Popov-6/+6
This disables IR verification by default.
2018-06-12Respect -Z no-verify during LTONikita Popov-7/+12
Currently -Z no-verify only controls IR verification prior to LLVM codegen, while verification is performed unconditionally both before and after linking with (Thin)LTO.
2018-05-31musl: don't use the included startfiles with -crt-staticJohannes Nixdorf-0/+16
This fixes (only for -crt-static) #36710.
2018-05-22Add -Z no-parallel-llvm flagNikita Popov-2/+6
Codegen issues commonly only manifest under specific circumstances, e.g. if multiple codegen units are used and ThinLTO is enabled. However, these configuration are threaded, making the use of LLVM debugging facilities hard, as output is interleaved. This patch adds a -Z no-parallel-llvm flag, which allows disabling parallelization of codegen and linking, while otherwise preserving behavior with regard to codegen units and LTO.
2018-05-17Revert "musl: don't use the included startfiles with -crt-static"Alex Crichton-16/+0
This reverts commit a5a875d17b34b61326d803eb2edea526d3bd6914.