diff options
| author | bors <bors@rust-lang.org> | 2018-09-23 07:38:17 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-09-23 07:38:17 +0000 |
| commit | 317ae05a7e4ee5324cc006eda877eb8f2eb57898 (patch) | |
| tree | 8ee1ec1f1f10f20299f44f7b648dd49748959624 /src/test/incremental/thinlto | |
| parent | 7714c430ae1f771001fc0a1b083752485baba56e (diff) | |
| parent | ca197323b9554c9fa1c74f1d3b6370669b709c07 (diff) | |
| download | rust-317ae05a7e4ee5324cc006eda877eb8f2eb57898.tar.gz rust-317ae05a7e4ee5324cc006eda877eb8f2eb57898.zip | |
Auto merge of #54325 - michaelwoerister:incr-thinlto-tests, r=alexcrichton
incr.comp.: Allow for more fine-grained testing of CGU reuse and use it to test incremental ThinLTO. This adds some tests specifically targeted at incremental ThinLTO, plus the infrastructure for tracking the kind of cache hit/miss we had for a given CGU. @alexcrichton, let me know if you can think of any more tests to add. ThinLTO works rather reliably for small functions, so we should be able to test it in a robust way. I think after this lands it might time for a "Help us test incremental ThinLTO" post on irlo. r? @alexcrichton
Diffstat (limited to 'src/test/incremental/thinlto')
| -rw-r--r-- | src/test/incremental/thinlto/cgu_invalidated_via_import.rs | 57 | ||||
| -rw-r--r-- | src/test/incremental/thinlto/independent_cgus_dont_affect_each_other.rs | 67 |
2 files changed, 124 insertions, 0 deletions
diff --git a/src/test/incremental/thinlto/cgu_invalidated_via_import.rs b/src/test/incremental/thinlto/cgu_invalidated_via_import.rs new file mode 100644 index 00000000000..c9e1ab89e50 --- /dev/null +++ b/src/test/incremental/thinlto/cgu_invalidated_via_import.rs @@ -0,0 +1,57 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +// This test checks that the LTO phase is re-done for CGUs that import something +// via ThinLTO and that imported thing changes while the definition of the CGU +// stays untouched. + +// revisions: cfail1 cfail2 cfail3 +// compile-flags: -Z query-dep-graph -O +// compile-pass + +#![feature(rustc_attrs)] +#![crate_type="rlib"] + +#![rustc_expected_cgu_reuse(module="cgu_invalidated_via_import-foo", + cfg="cfail2", + kind="no")] +#![rustc_expected_cgu_reuse(module="cgu_invalidated_via_import-foo", + cfg="cfail3", + kind="post-lto")] + +#![rustc_expected_cgu_reuse(module="cgu_invalidated_via_import-bar", + cfg="cfail2", + kind="pre-lto")] +#![rustc_expected_cgu_reuse(module="cgu_invalidated_via_import-bar", + cfg="cfail3", + kind="post-lto")] + +mod foo { + + // Trivial functions like this one are imported very reliably by ThinLTO. + #[cfg(cfail1)] + pub fn inlined_fn() -> u32 { + 1234 + } + + #[cfg(not(cfail1))] + pub fn inlined_fn() -> u32 { + 1234 + } +} + +pub mod bar { + use foo::inlined_fn; + + pub fn caller() -> u32 { + inlined_fn() + } +} diff --git a/src/test/incremental/thinlto/independent_cgus_dont_affect_each_other.rs b/src/test/incremental/thinlto/independent_cgus_dont_affect_each_other.rs new file mode 100644 index 00000000000..d0d6d6fdc24 --- /dev/null +++ b/src/test/incremental/thinlto/independent_cgus_dont_affect_each_other.rs @@ -0,0 +1,67 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +// This test checks that a change in a CGU does not invalidate an unrelated CGU +// during incremental ThinLTO. + +// revisions: cfail1 cfail2 cfail3 +// compile-flags: -Z query-dep-graph -O +// compile-pass + +#![feature(rustc_attrs)] +#![crate_type="rlib"] + +#![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-foo", + cfg="cfail2", + kind="no")] +#![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-foo", + cfg="cfail3", + kind="post-lto")] + +#![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-bar", + cfg="cfail2", + kind="pre-lto")] +#![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-bar", + cfg="cfail3", + kind="post-lto")] + +#![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-baz", + cfg="cfail2", + kind="post-lto")] +#![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-baz", + cfg="cfail3", + kind="post-lto")] +mod foo { + + #[cfg(cfail1)] + pub fn inlined_fn() -> u32 { + 1234 + } + + #[cfg(not(cfail1))] + pub fn inlined_fn() -> u32 { + 1234 + } +} + +pub mod bar { + use foo::inlined_fn; + + pub fn caller() -> u32 { + inlined_fn() + } +} + +pub mod baz { + pub fn unrelated_to_other_fns() -> u64 { + 0xbeef + } +} |
