rust/src/librustc_trans
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
..
back rustc: Persist LLVM's Linker in Fat LTO 2018-02-12 09:11:06 -08:00
debuginfo
mir Rollup merge of #48078 - alexcrichton:fix-required-const-and-proc-macro, r=eddyb 2018-02-10 14:24:04 +08:00
abi.rs
allocator.rs
asm.rs
attributes.rs
base.rs
build.rs
builder.rs
cabi_aarch64.rs
cabi_arm.rs
cabi_asmjs.rs
cabi_hexagon.rs
cabi_mips64.rs
cabi_mips.rs
cabi_msp430.rs
cabi_nvptx64.rs
cabi_nvptx.rs
cabi_powerpc64.rs
cabi_powerpc.rs
cabi_s390x.rs
cabi_sparc64.rs
cabi_sparc.rs
cabi_x86_64.rs Fix oversized loads on x86_64 SysV FFI calls 2018-02-08 13:50:18 +01:00
cabi_x86_win64.rs
cabi_x86.rs
callee.rs
Cargo.toml
common.rs
consts.rs
context.rs rustc: prefer ParamEnvAnd and LayoutCx over tuples for LayoutOf. 2018-02-01 00:01:08 +02:00
declare.rs
diagnostics.rs
glue.rs
intrinsic.rs
lib.rs
llvm_util.rs
metadata.rs
meth.rs
README.md
time_graph.rs
trans_item.rs
type_.rs
type_of.rs
value.rs

NB: This crate is part of the Rust compiler. For an overview of the compiler as a whole, see the README.md file found in librustc.

The trans crate contains the code to convert from MIR into LLVM IR, and then from LLVM IR into machine code. In general it contains code that runs towards the end of the compilation process.