Closed
Description
rustc 1.36.0-nightly (3991285f5 2019-04-25)
binary: rustc
commit-hash: 3991285f55a4b7cd92b7ffcdc396a3023076f5cb
commit-date: 2019-04-25
host: x86_64-unknown-linux-gnu
release: 1.36.0-nightly
LLVM version: 8.0
rustc src/test/run-pass/thinlto/thin-lto-inlines.rs -C passes=lint -C opt-level=3
Unusual: Load from function body
%28 = load i8, i8* bitcast (i32 ()* @_ZN16thin_lto_inlines3foo17h0a63dafc3d3ea645E to i8*), align 1
Unusual: Load from function body
%29 = load i8, i8* bitcast (i32 ()* @_ZN16thin_lto_inlines3bar3bar17hb953f1ee32a332f0E to i8*), align 1
the code contains unsafe code though:
// run-pass
// compile-flags: -Z thinlto -C codegen-units=8 -O
// ignore-emscripten can't inspect instructions on emscripten
// We want to assert here that ThinLTO will inline across codegen units. There's
// not really a great way to do that in general so we sort of hack around it by
// praying two functions go into separate codegen units and then assuming that
// if inlining *doesn't* happen the first byte of the functions will differ.
pub fn foo() -> u32 {
bar::bar()
}
mod bar {
pub fn bar() -> u32 {
3
}
}
fn main() {
println!("{} {}", foo(), bar::bar());
unsafe {
let foo = foo as usize as *const u8;
let bar = bar::bar as usize as *const u8;
assert_eq!(*foo, *bar);
}
}
cc #7463