rust/src/rustllvm
Alex Crichton 43e8ac27d9 rustc: Persist LLVM's `Linker` in Fat LTO
This commit updates our Fat LTO logic to tweak our custom wrapper around LLVM's
"link modules" functionality. Previously whenever the
`LLVMRustLinkInExternalBitcode` function was called it would call LLVM's
`Linker::linkModules` wrapper. Internally this would crate an instance of a
`Linker` which internally creates an instance of an `IRMover`. Unfortunately for
us the creation of `IRMover` is somewhat O(n) with the input module. This means
that every time we linked a module it was O(n) with respect to the entire module
we had built up!

Now the modules we build up during LTO are quite large, so this quickly started
creating an O(n^2) problem for us! Discovered in #48025 it turns out this has
always been a problem and we just haven't noticed it. It became particularly
worse recently though due to most libraries having 16x more object files than
they previously did (1 -> 16).

This commit fixes this performance issue by preserving the `Linker` instance
across all links into the main LLVM module. This means we only create one
`IRMover` and allows LTO to progress much speedier.

From the `cargo-cache` project in #48025 a **full build** locally when from
5m15s to 2m24s. Looking at the timing logs each object file was linked in in
single-digit millisecond rather than hundreds, clearly being a nice improvement!

Closes #48025
2018-02-12 09:11:06 -08:00
..
.editorconfig Add .editorconfig to src/rustllvm 2017-06-30 23:13:40 +03:00
ArchiveWrapper.cpp llvm6: Different return value for writeArchive 2018-01-24 07:18:02 -08:00
Linker.cpp rustc: Persist LLVM's `Linker` in Fat LTO 2018-02-12 09:11:06 -08:00
PassWrapper.cpp rustc: Add some defines for LLVM 7 compat 2018-01-30 12:11:31 -08:00
README audit LLVM C++ types in ArchiveWrapper and PassWrapper 2016-08-03 15:08:47 +03:00
RustWrapper.cpp rustc: Persist LLVM's `Linker` in Fat LTO 2018-02-12 09:11:06 -08:00
llvm-rebuild-trigger rustc: Upgrade to LLVM 6 2018-02-09 17:13:14 -08:00
rustllvm.h Remove unused LLVMRustJITMemoryManagerRef typedef 2018-01-07 04:39:58 +01:00

README

This directory currently contains some LLVM support code. This will generally
be sent upstream to LLVM in time; for now it lives here.

NOTE: the LLVM C++ ABI is subject to between-version breakage and must *never*
be exposed to Rust. To allow for easy auditing of that, all Rust-exposed types
must be typedef-ed as "LLVMXyz", or "LLVMRustXyz" if they were defined here.

Functions that return a failure status and leave the error in
the LLVM last error should return an LLVMRustResult rather than an
int or anything to avoid confusion.

When translating enums, add a single `Other` variant as the first
one to allow for new variants to be added. It should abort when used
as an input.

All other types must not be typedef-ed as such.