]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/thinlto/cgu_invalidated_via_import.rs
Merge pull request #2 from rust-lang/master
[rust.git] / src / test / incremental / thinlto / cgu_invalidated_via_import.rs
1 // This test checks that the LTO phase is re-done for CGUs that import something
2 // via ThinLTO and that imported thing changes while the definition of the CGU
3 // stays untouched.
4
5 // revisions: cfail1 cfail2 cfail3
6 // compile-flags: -Z query-dep-graph -O
7 // build-pass (FIXME(62277): could be check-pass?)
8
9 #![feature(rustc_attrs)]
10 #![crate_type="rlib"]
11
12 #![rustc_expected_cgu_reuse(module="cgu_invalidated_via_import-foo",
13                             cfg="cfail2",
14                             kind="no")]
15 #![rustc_expected_cgu_reuse(module="cgu_invalidated_via_import-foo",
16                             cfg="cfail3",
17                             kind="post-lto")]
18
19 #![rustc_expected_cgu_reuse(module="cgu_invalidated_via_import-bar",
20                             cfg="cfail2",
21                             kind="pre-lto")]
22 #![rustc_expected_cgu_reuse(module="cgu_invalidated_via_import-bar",
23                             cfg="cfail3",
24                             kind="post-lto")]
25
26 mod foo {
27
28     // Trivial functions like this one are imported very reliably by ThinLTO.
29     #[cfg(cfail1)]
30     pub fn inlined_fn() -> u32 {
31         1234
32     }
33
34     #[cfg(not(cfail1))]
35     pub fn inlined_fn() -> u32 {
36         1234
37     }
38 }
39
40 pub mod bar {
41     use foo::inlined_fn;
42
43     pub fn caller() -> u32 {
44         inlined_fn()
45     }
46 }