Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[experimental] Perform cross-lang-lto for librustc_codegen_llvm. #53855

Conversation

michaelwoerister
Copy link
Member

This is a follow-up to #53245 in order to gauge the impact of cross-language LTO on rustc.

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 31, 2018
@michaelwoerister
Copy link
Member Author

@bors try

@bors
Copy link
Contributor

bors commented Aug 31, 2018

⌛ Trying commit db1c62a with merge a3fe337...

bors added a commit that referenced this pull request Aug 31, 2018
[experimental] Perform cross-lang-lto for librustc_codegen_llvm.

This is a follow-up to #53245 in order to gauge the impact of cross-language LTO on `rustc`.
@michaelwoerister
Copy link
Member Author

Oh, I just remembered: This probably won't work because CI uses Clang 6.0 but cross-language LTO needs Clang 7. Otherwise the LLVM versions of Clang and Rust are not compatible.

@bors
Copy link
Contributor

bors commented Aug 31, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 31, 2018
@rust-highfive
Copy link
Collaborator

The job dist-x86_64-linux of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_fold:end:services

travis_fold:start:git.checkout
travis_time:start:0132a824
$ git clone --depth=2 --branch=try https://github.com/rust-lang/rust.git rust-lang/rust
---
[00:35:00]    Compiling libc v0.2.43
[00:35:00]    Compiling rustc-demangle v0.1.9
[00:35:03]    Compiling num_cpus v1.8.0
[00:35:07]    Compiling rustc_llvm v0.0.0 (file:///checkout/src/librustc_llvm)
[00:35:45] error: linking with `clang` failed: exit code: 254
[00:35:45]   |
[00:35:45]   = note: "clang" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-Wl,-plugin-opt=O2" "-Wl,-plugin-opt=mcpu=x86-64" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/rustc_codegen_llvm-feb1b4d734e14965.rustc_codegen_llvm0.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/rustc_codegen_llvm-feb1b4d734e14965.rustc_codegen_llvm1.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/rustc_codegen_llvm-feb1b4d734e14965.rustc_codegen_llvm10.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/rustc_codegen_llvm-feb1b4d734e14965.rustc_codegen_llvm11.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/rustc_codegen_llvm-feb1b4d734e14965.rustc_codegen_llvm12.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/rustc_codegen_llvm-feb1b4d734e14965.rustc_codegen_llvm13.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/rustc_codegen_llvm-feb1b4d734e14965.rustc_codegen_llvm14.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/rustc_codegen_llvm-feb1b4d734e14965.rustc_codegen_llvm15.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/rustc_codegen_llvm-feb1b4d734e14965.rustc_codegen_llvm2.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/rustc_codegen_llvm-feb1b4d734e14965.rustc_codegen_llvm3.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/rustc_codegen_llvm-feb1b4d734e14965.rustc_codegen_llvm4.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/rustc_codegen_llvm-feb1b4d734e14965.rustc_codegen_llvm5.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/rustc_codegen_llvm-feb1b4d734e14965.rustc_codegen_llvm6.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/rustc_codegen_llvm-feb1b4d734e14965.rustc_codegen_llvm7.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/rustc_codegen_llvm-feb1b4d734e14965.rustc_codegen_llvm8.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/rustc_codegen_llvm-feb1b4d734e14965.rustc_codegen_llvm9.rcgu.o" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/librustc_codegen_llvm-feb1b4d734e14965.so" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/rustc_codegen_llvm-feb1b4d734e14965.crate.metadata.rcgu.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/rustc_codegen_llvm-feb1b4d734e14965.crate.allocator.rcgu.o" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/release/deps" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/build/rustc_llvm-1f47acc9c60cd35e/out" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/build/lib" "-L" "/rustroot/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.5/../../../../lib64" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-Wl,--whole-archive" "/tmp/rustcl0yFHx/libtempfile-5a7f79f86d814286.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustcl0yFHx/libremove_dir_all-e130d7e2b7a78323.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustcl0yFHx/librand-773cd8887f97fff6.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustcl0yFHx/librand_core-5192adf414086896.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustcl0yFHx/libcc-11e0a9f073bf5c97.rlib" "-Wl,--no-whole-archive" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bdynamic" "-lrustc_codegen_utils-c8e693e01b2b0a00" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lrustc_metadata_utils-460e3d644342f3a6" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lrustc_platform_intrinsics-2e835ba951928190" "-Wl,-Bstatic" "-Wl,--whole-archive" "/tmp/rustcl0yFHx/librustc_llvm-b4c8b22ef8c5e426.rlib" "-Wl,--no-whole-archive" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bdynamic" "-lrustc_incremental-716bb13ed29eb7b1" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lrustc_allocator-959b2ac4defc6ded" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lrustc_mir-7952c237ec0d4952" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lrustc-cfbc17aa3c766576" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-ltest-5ddc8f9584faca79" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lterm-76f8ef2b02a12b3e" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lrustc_fs_util-3f97c3ca5071d1e2" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lproc_macro-e52681828ffd372e" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lsyntax-26b6009735d1b07c" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lrustc_errors-f882aab6100635ab" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lsyntax_pos-ef45b71e578357b1" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lrustc_target-51fd1bd0441a9815" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lgraphviz-45ae4394366d07fd" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lfmt_macros-2ce739823c85fd99" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-larena-4ee92b74dcb65ca6" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lrustc_data_structures-61336079186baa43" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lrustc_cratesio_shim-b41313cb9de684df" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lserialize-8d84add221c0f710" "-Wl,--start-group" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lstd-4cf9d268f1f28533" "-Wl,--end-group" "-Wl,-Bstatic" "/tmp/rustcl0yFHx/libcompiler_builtins-02d8b7c22d5a49ce.rlib" "-Wl,-Bdynamic" "-lrt" "-ldl" "-lpthread" "-lm" "-lutil" "-lutil" "-ldl" "-lrt" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil" "-shared" "-Wl,-rpath,$ORIGIN/../lib" "-fuse-ld=lld" "-flto=thin" "-O2" "-Wl,--thinlto-jobs=4"
[00:35:45]   = note: Intrinsic has incorrect argument type!
[00:35:45]           void (i8*, i8*, i64, i1)* @llvm.memcpy.p0i8.p0i8.i64
[00:35:45]           LLVM ERROR: Broken function found, compilation aborted!
[00:35:45]           clang-6.0: error: unable to execute command: Segmentation fault (core dumped)
[00:35:45]           clang-6.0: error: linker command failed due to signal (use -v to see invocation)
[00:35:45] 
[00:35:45] error: aborting due to previous error
[00:35:45] 
[00:35:45] error: Could not compile `rustc_codegen_llvm`.
[00:35:45] error: Could not compile `rustc_codegen_llvm`.
[00:35:45] 
[00:35:45] Caused by:
[00:35:45]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc --crate-name rustc_codegen_llvm librustc_codegen_llvm/lib.rs --color always --error-format json --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 -Zcross-lang-lto -Clink-arg=-fuse-ld=lld -Clink-arg=-flto=thin -Clink-arg=-O2 -Clink-arg=-Wl,--thinlto-jobs=4 -C metadata=feb1b4d734e14965 -C extra-filename=-feb1b4d734e14965 --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -C linker=clang -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/release/deps --extern cc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/libcc-11e0a9f073bf5c97.rlib --extern num_cpus=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/libnum_cpus-9c2b6b79866500de.rlib --extern rustc_demangle=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/librustc_demangle-93a49a52ce463556.rlib --extern rustc_llvm=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/deps/librustc_llvm-b4c8b22ef8c5e426.rlib -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-codegen/x86_64-unknown-linux-gnu/release/build/rustc_llvm-1f47acc9c60cd35e/out -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/build/lib -L native=/rustroot/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.5/../../../../lib64` (exit code: 1)
[00:35:45] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "rustc" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--manifest-path" "/checkout/src/librustc_codegen_llvm/Cargo.toml" "--features" "" "--message-format" "json" "--" "-Zcross-lang-lto" "-Clink-arg=-fuse-ld=lld" "-Clink-arg=-flto=thin" "-Clink-arg=-O2" "-Clink-arg=-Wl,--thinlto-jobs=4"
[00:35:45] expected success, got: exit code: 101
[00:35:45] thread 'main' panicked at 'cargo must succeed', bootstrap/compile.rs:1156:9
[00:35:45] travis_fold:start:stage0-rustc_codegen_llvm
travis_time:start:stage0-rustc_codegen_llvm
travis_fold:end:stage0-rustc_codegen_llvm

---
travis_time:end:0a60c742:start=1535730513616119077,finish=1535730513622530314,duration=6411237
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:029d4017
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:393eac07
travis_time:start:393eac07
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:064cc848
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@alexcrichton
Copy link
Member

Heh and sure enough!

[00:35:45] �[0m  �[0m�[0m�[1m�[38;5;12m= �[0m�[0m�[1mnote�[0m�[0m: Intrinsic has incorrect argument type!�[0m
[00:35:45] �[0m          void (i8*, i8*, i64, i1)* @llvm.memcpy.p0i8.p0i8.i64�[0m
[00:35:45] �[0m          LLVM ERROR: Broken function found, compilation aborted!�[0m

@michaelwoerister
Copy link
Member Author

LLVM 7 is due on Sep 5, I'll mark as blocked until then.

@michaelwoerister michaelwoerister added the S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. label Sep 1, 2018
@michaelwoerister
Copy link
Member Author

Hm, now that rustc uses LLVM 8.0, having Clang 7.0 won't really help here :/

@michaelwoerister
Copy link
Member Author

I tried this out locally, building LLVM with current Clang master and then running the perf.rlo test suite and the results look like there's pretty much no performance win at all:

inflate-opt
    avg: 0.1%?  min: -0.4%? max: 1.1%?
ctfe-stress-opt
    avg: 0.1%?  min: -0.6%? max: 1.0%?
coercions-debug
    avg: -0.4%? min: -1.0%? max: 0.1%?
ctfe-stress-check
    avg: 0.2%?  min: -0.1%? max: 0.9%?
clap-rs-check
    avg: 0.2%   min: -0.6%  max: 0.9%
coercions-opt
    avg: -0.0%? min: -0.5%? max: 0.5%?
clap-rs-debug
    avg: 0.1%   min: -0.3%  max: 0.5%
html5ever-opt
    avg: -0.2%  min: -0.5%  max: 0.0%
html5ever-debug
    avg: 0.1%   min: -0.0%  max: 0.5%
ucd-debug
    avg: -0.0%  min: -0.4%  max: 0.4%
regression-31157-debug
    avg: -0.1%  min: -0.4%  max: 0.2%
regression-31157-check
    avg: 0.0%   min: -0.1%  max: 0.4%
coercions-check
    avg: 0.1%?  min: -0.2%? max: 0.3%?
style-servo-debug
    avg: 0.1%   min: -0.1%  max: 0.3%
deep-vector-opt
    avg: 0.1%   min: -0.1%  max: 0.3%
html5ever-check
    avg: -0.1%  min: -0.3%  max: 0.1%
deep-vector-check
    avg: 0.0%   min: -0.1%  max: 0.3%
issue-46449-check
    avg: -0.1%  min: -0.3%  max: 0.0%
issue-46449-opt
    avg: 0.0%   min: -0.1%  max: 0.2%
regex-debug
    avg: -0.0%  min: -0.2%  max: 0.2%
regex-opt
    avg: -0.0%  min: -0.2%  max: 0.1%
tokio-webpush-simple-check
    avg: 0.0%   min: -0.1%  max: 0.2%
clap-rs-opt
    avg: -0.1%  min: -0.2%  max: 0.1%
ripgrep-opt
    avg: -0.0%  min: -0.2%  max: 0.1%
ucd-opt
    avg: 0.1%   min: 0.1%   max: 0.2%
tuple-stress-check
    avg: -0.0%  min: -0.2%  max: 0.1%
ucd-check
    avg: -0.0%  min: -0.2%  max: 0.2%
deep-vector-debug
    avg: -0.0%  min: -0.2%  max: 0.2%
keccak-debug
    avg: -0.0%  min: -0.2%  max: 0.0%
encoding-debug
    avg: -0.0%  min: -0.1%  max: 0.2%
ctfe-stress-debug
    avg: 0.0%?  min: -0.1%? max: 0.2%?
cargo-opt
    avg: 0.0%   min: -0.1%  max: 0.2%
deeply-nested-opt
    avg: -0.1%  min: -0.2%  max: -0.1%
tokio-webpush-simple-debug
    avg: -0.1%  min: -0.2%  max: 0.0%
syn-check
    avg: 0.0%   min: -0.1%  max: 0.2%
tuple-stress-opt
    avg: -0.1%  min: -0.2%  max: 0.1%
syn-debug
    avg: -0.0%  min: -0.1%  max: 0.1%
regression-31157-opt
    avg: -0.0%  min: -0.1%  max: 0.0%
issue-46449-debug
    avg: -0.0%  min: -0.1%  max: 0.0%
helloworld-check
    avg: -0.1%  min: -0.1%  max: -0.1%
inflate-debug
    avg: -0.0%  min: -0.1%  max: 0.1%
sentry-cli-opt
    avg: 0.0%   min: -0.1%  max: 0.1%
webrender-debug
    avg: -0.0%  min: -0.1%  max: 0.1%
cargo-debug
    avg: -0.1%  min: -0.1%  max: -0.0%
unify-linearly-check
    avg: -0.0%  min: -0.1%  max: -0.0%
webrender-opt
    avg: -0.1%  min: -0.1%  max: -0.0%
sentry-cli-check
    avg: -0.1%  min: -0.1%  max: 0.0%
deeply-nested-debug
    avg: -0.1%  min: -0.1%  max: 0.0%
encoding-opt
    avg: -0.0%  min: -0.1%  max: 0.0%
deeply-nested-check
    avg: -0.0%  min: -0.1%  max: 0.0%
futures-opt
    avg: -0.0%  min: -0.1%  max: -0.0%
cargo-check
    avg: 0.0%   min: -0.0%  max: 0.1%
serde-check
    avg: -0.0%  min: -0.1%  max: 0.0%
piston-image-debug
    avg: -0.0%  min: -0.1%  max: 0.0%
tuple-stress-debug
    avg: 0.0%   min: -0.1%  max: 0.1%
piston-image-check
    avg: -0.0%  min: -0.1%  max: 0.0%
helloworld-opt
    avg: -0.1%  min: -0.1%  max: -0.0%
serde-opt
    avg: -0.0%  min: -0.1%  max: 0.0%
regex-check
    avg: 0.0%   min: -0.0%  max: 0.1%
unused-warnings-check
    avg: -0.0%  min: -0.1%  max: -0.0%
unify-linearly-opt
    avg: -0.0%  min: -0.1%  max: 0.0%
encoding-check
    avg: -0.0%  min: -0.1%  max: 0.0%
piston-image-opt
    avg: -0.0%  min: -0.1%  max: 0.1%
sentry-cli-debug
    avg: -0.0%  min: -0.1%  max: 0.1%
style-servo-check
    avg: 0.0%   min: -0.0%  max: 0.1%
tokio-webpush-simple-opt
    avg: -0.0%  min: -0.1%  max: 0.0%
syn-opt
    avg: -0.0%? min: -0.1%? max: 0.0%?
unify-linearly-debug
    avg: -0.0%  min: -0.1%  max: -0.0%
style-servo-opt
    avg: -0.0%  min: -0.0%  max: 0.0%
helloworld-debug
    avg: -0.0%  min: -0.0%  max: -0.0%
ripgrep-check
    avg: -0.0%  min: -0.0%  max: -0.0%
keccak-check
    avg: 0.0%   min: -0.0%  max: 0.0%
keccak-opt
    avg: 0.0%   min: -0.0%  max: 0.0%
ripgrep-debug
    avg: 0.0%   min: -0.0%  max: 0.0%
webrender-check
    avg: 0.0%   min: -0.0%  max: 0.0%
serde-debug
    avg: -0.0%  min: -0.0%  max: 0.0%
futures-check
    avg: 0.0%   min: -0.0%  max: 0.0%
futures-debug
    avg: 0.0%   min: -0.0%  max: 0.0%
inflate-check
    avg: 0.0%   min: -0.0%  max: 0.0%
unused-warnings-opt
    avg: -0.0%  min: -0.0%  max: 0.0%
unused-warnings-debug
    avg: -0.0%  min: -0.0%  max: 0.0%

I verified that things are actually inlined cross-language by picking a few (5-6) small functions from librustc_codegen_llvm/llvm/ffi.rs and looking for them in the disassembly of librustc_codegen_llvm-llvm.so. The result was exactly as expected: For my baseline there were many calls like

92029: 1412d69:	e8 42 d1 2e 02       	callq  36ffeb0 <LLVMGetIntTypeWidth@plt>

in the Rust code, while for the cross-lang version, no calls could be found, just the definition:

00000000033668e0 <LLVMGetIntTypeWidth>:
 33668e0:	8b 47 08             	mov    0x8(%rdi),%eax
 33668e3:	c1 e8 08             	shr    $0x8,%eax
 33668e6:	c3                   	retq   
 33668e7:	cc                   	int3   
 33668e8:	cc                   	int3   
 33668e9:	cc                   	int3   
 33668ea:	cc                   	int3   
 33668eb:	cc                   	int3   
 33668ec:	cc                   	int3   
 33668ed:	cc                   	int3   
 33668ee:	cc                   	int3   
 33668ef:	cc                   	int3   

Every function I looked at was actually inlined, so the optimization works as expected. It seems to have little effect on runtime performance though, at least for the compiler's codegen backend.

If someone wants to verify these results independently, here are the respective branches:

These branches have their config.toml checked in with the right settings. One just needs to compile a LLVM 8.0 based Clang and LLD and update the paths in config.toml to point to them (cc = .., etc).

cc @rust-lang/compiler @rust-lang/wg-compiler-performance @rust-lang/wg-codegen

@nagisa
Copy link
Member

nagisa commented Sep 8, 2018

@michaelwoerister I wouldn’t expect much change in compile time by optimising LIR->LLVM-IR translation – it already takes a very small part of compilation time, so even removing that part will not affect time final timings much.

Nice to see xLTO working though!

@michaelwoerister
Copy link
Member Author

I'm closing this since it would require quite a bit of work on the CI side and (at least in my local test run) does not provide any substantial gains in performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants