about summary refs log tree commit diff
path: root/src/rustllvm/PassWrapper.cpp
AgeCommit message (Collapse)AuthorLines
2019-07-20Don't link mcjit/interpreter LLVM componentsNikita Popov-2/+0
2019-07-15Don't add extra passes into the function pass managerNikita Popov-0/+17
Exception for specific cases like linting, additional passes should be going into the module pass manager (even if they are function passes). The separate function pass manager is only used for very early optimization passes. Rather than apparending passes to the MPM, use the OptimizerLast and EnabledOnOptLevel0 pass manager builder extension hooks, which allow adding passes directly before finalization (alias canonicalization and name-anon-globals). The main effect and purpose of this change is to add sanitizer passes at the end of the pipeline, which is where they belong. In LLVM 9 the address sanitizer can't be used as a pass in the early function pass manager, because it has a dependence on a module-level analysis pass.
2019-07-13Update CPU printing for SubtargetSubTypeKVNikita Popov-4/+4
CPUs now use SubtargetSubTypeKV rather than SubtargetFeatureKV and no longer have a description.
2019-07-09Pass GUIDPreservedSymbols to thinLTOResolvePrevailingInIndex()Nikita Popov-1/+4
2019-04-26Limit internalization in LLVM 8 ThinLTOJosh Stone-1/+4
2019-04-05Show better errors for LLVM IR outputJosh Stone-2/+9
I was trying to output LLVM IR directly to the console: $ rustc hello.rs --emit=llvm-ir -o /dev/stdout LLVM ERROR: IO failure on output stream: Bad file descriptor Now `LLVMRustPrintModule` returns an error, and we print: error: failed to write LLVM IR to /dev/stdout.hello.7rcbfp3g-cgu.0.rcgu.ll: Permission denied ... which is more informative.
2019-02-12rustc: Implement incremental "fat" LTOAlex Crichton-4/+4
Currently the compiler will produce an error if both incremental compilation and full fat LTO is requested. With recent changes and the advent of incremental ThinLTO, however, all the hard work is already done for us and it's actually not too bad to remove this error! This commit updates the codegen backend to allow incremental full fat LTO. The semantics are that the input modules to LTO are all produce incrementally, but the final LTO step is always done unconditionally regardless of whether the inputs changed or not. The only real incremental win we could have here is if zero of the input modules changed, but that's so rare it's unlikely to be worthwhile to implement such a code path. cc #57968 cc rust-lang/cargo#6643
2019-01-25Rebase to the llvm-project monorepoJosh Stone-1/+6
The new git submodule src/llvm-project is a monorepo replacing src/llvm and src/tools/{clang,lld,lldb}. This also serves as a rebase for these projects to the new 8.x branch from trunk. The src/llvm-emscripten fork is unchanged for now.
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-09Bump minimum required LLVM version to 6.0Nikita Popov-16/+2
2018-11-30Enable -mergefunc-use-aliasesNikita Popov-1/+1
If the Rust LLVM fork is used, enable the -mergefunc-use-aliases flag, which will create aliases for merged functions, rather than inserting a call from one to the other. A number of codegen tests needed to be adjusted, because functions that previously fell below the thunk limit are now being merged. Merging is prevented either using -C no-prepopulate-passes, or by making the functions non-identical. I expect that this is going to break something, somewhere, because it isn't able to deal with aliases properly, but we won't find out until we try :) This fixes #52651.
2018-11-25Handle some renamed ThinLTO functionsAlex Crichton-0/+8
2018-11-11Auto merge of #55698 - nikic:remove-llvm-4-support, r=alexcrichtonbors-40/+1
Remove support for building against LLVM 4 With emscripten removed in #55626, we no longer need to support building against LLVM 4.
2018-11-10Auto merge of #55626 - nikic:update-emscripten, r=alexcrichtonbors-1/+1
Update emscripten This updates emscripten to 1.38.15, which is based on LLVM 6.0.1 and would allow us to drop code for handling LLVM 4. The main issue I ran into is that exporting statics through `EXPORTED_FUNCTIONS` no longer works. As far as I understand exporting non-functions doesn't really make sense under emscripten anyway, so I've modified the symbol export code to not even try. Closes #52323.
2018-11-05Remove support for building against LLVM 4Nikita Popov-40/+1
With emscripten removed in #55626, we no longer need to support building against LLVM 4.
2018-11-04Update llvm-emscriptenNikita Popov-1/+1
This updates emscripten to version 1.38.15, which is based on LLVM 6.0.1.
2018-11-01Remove checks for LLVM < 4.0Nikita Popov-142/+0
While we still have to support LLVM 4.0 for Emscripten, we can drop checks for LLVM >= 4.0 and < 4.0.
2018-09-26add -Z emit-stack-sizesJorge Aparicio-1/+4
2018-08-31Provide a way of accessing the ThinLTO module import map in rustc.Michael Woerister-0/+27
2018-08-28Fix warnings about the `native` target-cpuAlex Crichton-6/+7
This fixes a regression from #53031 where specifying `-C target-cpu=native` is printing a lot of warnings from LLVM about `native` being an unknown CPU. It turns out that `native` is indeed an unknown CPU and we have to perform a mapping to an actual CPU name, but this mapping is only performed in one location rather than all locations we inform LLVM about the target CPU. This commit centralizes the mapping of `native` to LLVM's value of the native CPU, ensuring that all locations we inform LLVM about the `target-cpu` it's never `native`. Closes #53322
2018-08-19Buffer LLVM's object output streamAlex Crichton-1/+2
In some profiling on OSX I saw the `write` syscall as quite high up on the profiling graph, which is definitely not good! It looks like we're setting the output stream of an object file as directly to a file descriptor which means that we run the risk of doing lots of little writes rather than a few large writes. This commit fixes this issue by adding a buffered stream on the output, causing the `write` syscall to disappear from the profiles on OSX.
2018-08-12Make LLVM emit assembly comments with -Z asm-comments.whitequark-1/+4
Fixes #35741.
2018-08-01[RISCV] Enable LLVM backend.David Craven-1/+8
2018-08-01Rollup merge of #52824 - varkor:fix-llvm-ret-move-warnings, r=rkruppePietro Albini-3/+3
Fix -Wpessimizing-move warnings in rustllvm/PassWrapper These are producing warnings when building rustc (`warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move]`).
2018-07-30rustc_codegen_llvm: remove more unused functions.Irina Popa-24/+0
2018-07-29Fix -Wpessimizing-move warnings in rustllvm/PassWrappervarkor-3/+3
2018-07-23Auto merge of #52506 - alexcrichton:dont-duplicate-wasm-sections, ↵bors-1/+30
r=michaelwoerister rustc: Work around an upstream wasm ThinLTO bug This commit implements a workaround for an [upstream LLVM bug][1] where custom sections were accidentally duplicated amongst codegen units when ThinLTO passes were performed. This is due to the fact that custom sections for wasm are stored as metadata nodes which are automatically imported into modules when ThinLTO happens. The fix here is to forcibly delete the metadata node from imported modules before LLVM has a chance to try to copy it over. [1]: https://bugs.llvm.org/show_bug.cgi?id=38184
2018-07-18rustc: Work around an upstream wasm ThinLTO bugAlex Crichton-1/+30
This commit implements a workaround for an [upstream LLVM bug][1] where custom sections were accidentally duplicated amongst codegen units when ThinLTO passes were performed. This is due to the fact that custom sections for wasm are stored as metadata nodes which are automatically imported into modules when ThinLTO happens. The fix here is to forcibly delete the metadata node from imported modules before LLVM has a chance to try to copy it over. [1]: https://bugs.llvm.org/show_bug.cgi?id=38184
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-16Revert "Provide a way of accessing the ThinLTO module import map in rustc."Michael Woerister-56/+0
This reverts commit 9df56ca0eea1a8f5af945df25ce23e276b1d48a7.
2018-07-16Revert "Use callback-based interface to load ThinLTO import data into rustc."Michael Woerister-20/+47
This reverts commit e045a6cd8c0235a26ef11e6cd9a13ebd817f1265.
2018-07-13Use callback-based interface to load ThinLTO import data into rustc.Michael Woerister-47/+20
2018-07-11Provide a way of accessing the ThinLTO module import map in rustc.Michael Woerister-0/+56
2018-07-10Upgrade to LLVM's master branch (LLVM 7)Alex Crichton-0/+4
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-05-17Rename trans to codegen everywhere.Irina Popa-1/+1
2018-05-15Reenable the MergeFunctions passAnthony Ramine-2/+3
The crash that happened in #23566 doesn't happen anymore with the LLVM mergefunc pass enabled and it hugely reduces code size (for example it shaves off 10% of the final Servo executable). This patch reenables it.
2018-05-12Set PrepareForThinLTO flag when using ThinLTONikita Popov-1/+4
The LLVM PassManager has a PrepareForThinLTO flag, which is intended when compilation occurs in conjunction with linking by ThinLTO. The flag has two effects: * The NameAnonGlobal pass is run after all other passes, which ensures that all globals have a name. * In optimized builds, a number of late passes (mainly related to vectorization and unrolling) are disabled, on the rationale that these a) will increase codesize of the intermediate artifacts and b) will be run by ThinLTO again anyway. This patch enables the use of PrepareForThinLTO if Thin or ThinLocal linking is used. The background for this change is the CI failure in #49479, which we assume to be caused by the NameAnonGlobal pass not being run. As this changes which passes LLVM runs, this might have performance (or other) impact, so we want to land this separately.
2018-03-27Enable target_feature on any LLVM 6+Josh Stone-8/+4
In `LLVMRustHasFeature()`, rather than using `MCInfo->getFeatureTable()` that is specific to Rust's LLVM fork, we can use this in LLVM 6: /// Check whether the subtarget features are enabled/disabled as per /// the provided string, ignoring all other features. bool checkFeatures(StringRef FS) const; Now rustc using external LLVM can also have `target_feature`.
2018-03-25try to fix the build on older LLVM versions.Emilio Cobos Álvarez-0/+18
2018-03-25rustc_llvm: rustc_trans: Thread the PGO config down to the pass manager builder.Emilio Cobos Álvarez-1/+11
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2018-01-30rustc: Add some defines for LLVM 7 compatAlex Crichton-0/+11
I was testing out the tip support to see what's going on with wasm, and this was I believe the only issue encountered with LLVM 7 support so far.
2018-01-24llvm6: Missing include for LLVM 6 in PassWrapper.cppAlex Crichton-0/+1
Just bog-standard compile error fixed by adding some new header files
2018-01-24llvm6: CodeModel::{JIT,}Default no longer existsAlex Crichton-8/+14
LLVM has since removed the `CodeModel::Default` enum value in favor of an `Optional` implementationg throughout LLVM. Let's mirror the same change in Rust and update the various bindings we call accordingly. Removed in llvm-mirror/llvm@9aafb854c
2018-01-14rustc_trans: remove unused `TargetDataRef` accessor.Eduard-Mihai Burtescu-4/+0
2017-12-23rustc: Set release mode cgus to 16 by defaultAlex Crichton-0/+15
This commit is the next attempt to enable multiple codegen units by default in release mode, getting some of those sweet, sweet parallelism wins by running codegen in parallel. Performance should not be lost due to ThinLTO being on by default as well. Closes #45320
2017-12-18rustc: Work around `DICompileUnit` bugs in LLVMAlex Crichton-0/+80
This commit implements a workaround for #46346 which basically just avoids triggering the situation that LLVM's bug https://bugs.llvm.org/show_bug.cgi?id=35562 arises. More details can be found in the code itself but this commit is also intended to ... Closes #46346
2017-12-12ThinLTO: updates for LLVM 5Tatsuyuki Ishi-0/+8
refs: https://github.com/llvm-mirror/llvm/commit/ccb80b9c0f60f33780e5e29bf66a87bb56968b99 https://github.com/llvm-mirror/llvm/commit/e611018a3f1237c9328763027db4a616ed7be04a
2017-12-07rustc: Further tweak linkage in ThinLTOAlex Crichton-1/+1
In #46382 the logic around linkage preservation with ThinLTO ws tweaked but the loop that registered all otherwise exported GUID values as "don't internalize me please" was erroneously too conservative and only asking "external" linkage items to not be internalized. Instead we actually want the inversion of that condition, everything *without* "local" linkage to be internalized. This commit updates the condition there, adds a test, and... Closes #46543
2017-12-03Auto merge of #46435 - cuviper:min-llvm-3.9, r=rkruppebors-21/+0
Assume at least LLVM 3.9 in rustllvm and rustc_llvm We bumped the minimum LLVM to 3.9 in #45326. This just cleans up the conditional code in the `rustllvm` C++ wrappers to assume that minimum, and similarly cleans up the `rustc_llvm` build script.
2017-12-01rustllvm: Remove conditional code for LLVM < 3.9Josh Stone-21/+0
We bumped the minimum LLVM to 3.9 in #45326. This just cleans up the conditional code in the rustllvm C++ wrappers to assume at least 3.9.