]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lto/thin-lto-inlines.rs
Rollup merge of #94577 - RalfJung:simd-miri, r=scottmcm
[rust.git] / src / test / ui / lto / thin-lto-inlines.rs
1 // run-pass
2
3 // compile-flags: -Z thinlto -C codegen-units=8 -O
4 // ignore-emscripten can't inspect instructions on emscripten
5
6 // We want to assert here that ThinLTO will inline across codegen units. There's
7 // not really a great way to do that in general so we sort of hack around it by
8 // praying two functions go into separate codegen units and then assuming that
9 // if inlining *doesn't* happen the first byte of the functions will differ.
10
11 pub fn foo() -> u32 {
12     bar::bar()
13 }
14
15 mod bar {
16     pub fn bar() -> u32 {
17         3
18     }
19 }
20
21 fn main() {
22     println!("{} {}", foo(), bar::bar());
23
24     unsafe {
25         let foo = foo as usize as *const u8;
26         let bar = bar::bar as usize as *const u8;
27
28         assert_eq!(*foo, *bar);
29     }
30 }