]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/thinlto/thin-lto-inlines2.rs
Auto merge of #45359 - arielb1:escaping-borrow, r=eddyb
[rust.git] / src / test / run-pass / thinlto / thin-lto-inlines2.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // compile-flags: -Z thinlto -C codegen-units=8 -O -C lto
12 // aux-build:thin-lto-inlines-aux.rs
13 // min-llvm-version 4.0
14 // no-prefer-dynamic
15 // ignore-emscripten can't inspect instructions on emscripten
16
17 // We want to assert here that ThinLTO will inline across codegen units. There's
18 // not really a great way to do that in general so we sort of hack around it by
19 // praying two functions go into separate codegen units and then assuming that
20 // if inlining *doesn't* happen the first byte of the functions will differ.
21
22 extern crate thin_lto_inlines_aux as bar;
23
24 pub fn foo() -> u32 {
25     bar::bar()
26 }
27
28 fn main() {
29     println!("{} {}", foo(), bar::bar());
30
31     unsafe {
32         let foo = foo as usize as *const u8;
33         let bar = bar::bar as usize as *const u8;
34
35         assert_eq!(*foo, *bar);
36     }
37 }
38