summary refs log tree commit diff
path: root/tests/run-make/linker-plugin-lto-fat/rmake.rs
blob: ff5b647a5941f02f4e490bb10d9e997b65b9d29b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Check that -C lto=fat with -C linker-plugin-lto actually works and can inline functions.
// A library is created from LLVM IR, defining a single function. Then a dylib is compiled,
// linking to the library and calling the function from the library.
// The function from the library should end up inlined and disappear from the output.

//@ only-x86_64-unknown-linux-gnu
//@ needs-rust-lld

use run_make_support::{dynamic_lib_name, llvm_as, llvm_objdump, rustc};

fn main() {
    llvm_as().input("ir.ll").run();
    rustc()
        .input("main.rs")
        .opt_level("3")
        .lto("fat")
        .linker_plugin_lto("on")
        .link_arg("ir.bc")
        .arg("-Zunstable-options")
        .arg("-Clinker-features=+lld")
        .run();

    llvm_objdump()
        .input(dynamic_lib_name("main"))
        .arg("--disassemble-symbols=rs_foo")
        .run()
        // The called function should be inlined.
        // Check that we have a ret (to detect tail
        // calls with a jmp) and no call.
        .assert_stdout_contains("foo")
        .assert_stdout_contains("ret")
        .assert_stdout_not_contains("call");
}