summaryrefslogtreecommitdiffstats
path: root/src/test/incremental/thinlto
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
commita4b7ed7a42c716ab9f05e351f003d589124fd55d (patch)
treeb620cd3f223850b28716e474e80c58059dca5dd4 /src/test/incremental/thinlto
parentAdding upstream version 1.67.1+dfsg1. (diff)
downloadrustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz
rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/incremental/thinlto')
-rw-r--r--src/test/incremental/thinlto/cgu_invalidated_via_import.rs48
-rw-r--r--src/test/incremental/thinlto/cgu_invalidated_when_export_added.rs26
-rw-r--r--src/test/incremental/thinlto/cgu_invalidated_when_export_removed.rs26
-rw-r--r--src/test/incremental/thinlto/cgu_invalidated_when_import_added.rs62
-rw-r--r--src/test/incremental/thinlto/cgu_invalidated_when_import_removed.rs74
-rw-r--r--src/test/incremental/thinlto/cgu_keeps_identical_fn.rs72
-rw-r--r--src/test/incremental/thinlto/independent_cgus_dont_affect_each_other.rs58
7 files changed, 0 insertions, 366 deletions
diff --git a/src/test/incremental/thinlto/cgu_invalidated_via_import.rs b/src/test/incremental/thinlto/cgu_invalidated_via_import.rs
deleted file mode 100644
index 5fe435d79..000000000
--- a/src/test/incremental/thinlto/cgu_invalidated_via_import.rs
+++ /dev/null
@@ -1,48 +0,0 @@
-// 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
-// build-pass (FIXME(62277): could be check-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 {
- // See `cgu_keeps_identical_fn.rs` for why this is different
- // from the other version of this function.
- 12345
- }
-}
-
-pub mod bar {
- use foo::inlined_fn;
-
- pub fn caller() -> u32 {
- inlined_fn()
- }
-}
diff --git a/src/test/incremental/thinlto/cgu_invalidated_when_export_added.rs b/src/test/incremental/thinlto/cgu_invalidated_when_export_added.rs
deleted file mode 100644
index 95f3b8ae4..000000000
--- a/src/test/incremental/thinlto/cgu_invalidated_when_export_added.rs
+++ /dev/null
@@ -1,26 +0,0 @@
-// revisions: cfail1 cfail2
-// build-pass
-
-// rust-lang/rust#69798:
-//
-// This is analogous to cgu_invalidated_when_import_added, but it covers a
-// problem uncovered where a change to the *export* set caused a link failure
-// when reusing post-LTO optimized object code.
-
-pub struct Foo {}
-impl Drop for Foo {
- fn drop(&mut self) {
- println!("Dropping Foo");
- }
-}
-#[no_mangle]
-pub extern "C" fn run() {
- thread_local! { pub static FOO : Foo = Foo { } ; }
-
- #[cfg(cfail2)]
- {
- FOO.with(|_f| ())
- }
-}
-
-pub fn main() { run() }
diff --git a/src/test/incremental/thinlto/cgu_invalidated_when_export_removed.rs b/src/test/incremental/thinlto/cgu_invalidated_when_export_removed.rs
deleted file mode 100644
index e86ebd354..000000000
--- a/src/test/incremental/thinlto/cgu_invalidated_when_export_removed.rs
+++ /dev/null
@@ -1,26 +0,0 @@
-// revisions: cfail1 cfail2
-// build-pass
-
-// rust-lang/rust#69798:
-//
-// This is analogous to cgu_invalidated_when_export_added, but it covers the
-// other direction. This is analogous to cgu_invalidated_when_import_added: we
-// include it, because it may uncover bugs in variant implementation strategies.
-
-pub struct Foo {}
-impl Drop for Foo {
- fn drop(&mut self) {
- println!("Dropping Foo");
- }
-}
-#[no_mangle]
-pub extern "C" fn run() {
- thread_local! { pub static FOO : Foo = Foo { } ; }
-
- #[cfg(cfail1)]
- {
- FOO.with(|_f| ())
- }
-}
-
-pub fn main() { run() }
diff --git a/src/test/incremental/thinlto/cgu_invalidated_when_import_added.rs b/src/test/incremental/thinlto/cgu_invalidated_when_import_added.rs
deleted file mode 100644
index 9c17c8745..000000000
--- a/src/test/incremental/thinlto/cgu_invalidated_when_import_added.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-// revisions: cfail1 cfail2
-// compile-flags: -O -Zhuman-readable-cgu-names -Cllvm-args=-import-instr-limit=10
-// build-pass
-
-// rust-lang/rust#59535:
-//
-// This is analogous to cgu_invalidated_when_import_removed.rs, but it covers
-// the other direction:
-//
-// We start with a call-graph like `[A] -> [B -> D] [C]` (where the letters are
-// functions and the modules are enclosed in `[]`), and add a new call `D <- C`,
-// yielding the new call-graph: `[A] -> [B -> D] <- [C]`
-//
-// The effect of this is that the compiler previously classfied `D` as internal
-// and the import-set of `[A]` to be just `B`. But after adding the `D <- C` call,
-// `D` is no longer classified as internal, and the import-set of `[A]` becomes
-// both `B` and `D`.
-//
-// We check this case because an early proposed pull request included an
-// assertion that the import-sets monotonically decreased over time, a claim
-// which this test case proves to be false.
-
-fn main() {
- foo::foo();
- bar::baz();
-}
-
-mod foo {
-
- // In cfail1, ThinLTO decides that foo() does not get inlined into main, and
- // instead bar() gets inlined into foo().
- // In cfail2, foo() gets inlined into main.
- pub fn foo(){
- bar()
- }
-
- // This function needs to be big so that it does not get inlined by ThinLTO
- // but *does* get inlined into foo() when it is declared `internal` in
- // cfail1 (alone).
- pub fn bar(){
- println!("quux1");
- println!("quux2");
- println!("quux3");
- println!("quux4");
- println!("quux5");
- println!("quux6");
- println!("quux7");
- println!("quux8");
- println!("quux9");
- }
-}
-
-mod bar {
-
- #[inline(never)]
- pub fn baz() {
- #[cfg(cfail2)]
- {
- crate::foo::bar();
- }
- }
-}
diff --git a/src/test/incremental/thinlto/cgu_invalidated_when_import_removed.rs b/src/test/incremental/thinlto/cgu_invalidated_when_import_removed.rs
deleted file mode 100644
index fc53acf75..000000000
--- a/src/test/incremental/thinlto/cgu_invalidated_when_import_removed.rs
+++ /dev/null
@@ -1,74 +0,0 @@
-// revisions: cfail1 cfail2
-// compile-flags: -O -Zhuman-readable-cgu-names -Cllvm-args=-import-instr-limit=10
-// build-pass
-
-// rust-lang/rust#59535:
-//
-// Consider a call-graph like `[A] -> [B -> D] <- [C]` (where the letters are
-// functions and the modules are enclosed in `[]`)
-//
-// In our specific instance, the earlier compilations were inlining the call
-// to`B` into `A`; thus `A` ended up with an external reference to the symbol `D`
-// in its object code, to be resolved at subsequent link time. The LTO import
-// information provided by LLVM for those runs reflected that information: it
-// explicitly says during those runs, `B` definition and `D` declaration were
-// imported into `[A]`.
-//
-// The change between incremental builds was that the call `D <- C` was removed.
-//
-// That change, coupled with other decisions within `rustc`, made the compiler
-// decide to make `D` an internal symbol (since it was no longer accessed from
-// other codegen units, this makes sense locally). And then the definition of
-// `D` was inlined into `B` and `D` itself was eliminated entirely.
-//
-// The current LTO import information reported that `B` alone is imported into
-// `[A]` for the *current compilation*. So when the Rust compiler surveyed the
-// dependence graph, it determined that nothing `[A]` imports changed since the
-// last build (and `[A]` itself has not changed either), so it chooses to reuse
-// the object code generated during the previous compilation.
-//
-// But that previous object code has an unresolved reference to `D`, and that
-// causes a link time failure!
-
-fn main() {
- foo::foo();
- bar::baz();
-}
-
-mod foo {
-
- // In cfail1, foo() gets inlined into main.
- // In cfail2, ThinLTO decides that foo() does not get inlined into main, and
- // instead bar() gets inlined into foo(). But faulty logic in our incr.
- // ThinLTO implementation thought that `main()` is unchanged and thus reused
- // the object file still containing a call to the now non-existent bar().
- pub fn foo(){
- bar()
- }
-
- // This function needs to be big so that it does not get inlined by ThinLTO
- // but *does* get inlined into foo() once it is declared `internal` in
- // cfail2.
- pub fn bar(){
- println!("quux1");
- println!("quux2");
- println!("quux3");
- println!("quux4");
- println!("quux5");
- println!("quux6");
- println!("quux7");
- println!("quux8");
- println!("quux9");
- }
-}
-
-mod bar {
-
- #[inline(never)]
- pub fn baz() {
- #[cfg(cfail1)]
- {
- crate::foo::bar();
- }
- }
-}
diff --git a/src/test/incremental/thinlto/cgu_keeps_identical_fn.rs b/src/test/incremental/thinlto/cgu_keeps_identical_fn.rs
deleted file mode 100644
index 31f329a7f..000000000
--- a/src/test/incremental/thinlto/cgu_keeps_identical_fn.rs
+++ /dev/null
@@ -1,72 +0,0 @@
-// This test is almost identical to `cgu_invalided_via_import`, except that
-// the two versions of `inline_fn` are identical. Neither version of `inlined_fn`
-// ends up with any spans in its LLVM bitecode, so LLVM is able to skip
-// re-building any modules which import 'inlined_fn'
-
-// revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
-// [cfail4]compile-flags: -Zincremental-relative-spans
-// [cfail5]compile-flags: -Zincremental-relative-spans
-// [cfail6]compile-flags: -Zincremental-relative-spans
-// compile-flags: -Z query-dep-graph -O
-// build-pass (FIXME(62277): could be check-pass?)
-
-#![feature(rustc_attrs)]
-#![crate_type = "rlib"]
-#![rustc_expected_cgu_reuse(module = "cgu_keeps_identical_fn-foo", cfg = "cfail2", kind = "no")]
-#![rustc_expected_cgu_reuse(
- module = "cgu_keeps_identical_fn-foo",
- cfg = "cfail3",
- kind = "post-lto"
-)]
-#![rustc_expected_cgu_reuse(
- module = "cgu_keeps_identical_fn-foo",
- cfg = "cfail5",
- kind = "post-lto"
-)]
-#![rustc_expected_cgu_reuse(
- module = "cgu_keeps_identical_fn-foo",
- cfg = "cfail6",
- kind = "post-lto"
-)]
-#![rustc_expected_cgu_reuse(
- module = "cgu_keeps_identical_fn-bar",
- cfg = "cfail2",
- kind = "post-lto"
-)]
-#![rustc_expected_cgu_reuse(
- module = "cgu_keeps_identical_fn-bar",
- cfg = "cfail3",
- kind = "post-lto"
-)]
-#![rustc_expected_cgu_reuse(
- module = "cgu_keeps_identical_fn-bar",
- cfg = "cfail5",
- kind = "post-lto"
-)]
-#![rustc_expected_cgu_reuse(
- module = "cgu_keeps_identical_fn-bar",
- cfg = "cfail6",
- kind = "post-lto"
-)]
-
-mod foo {
-
- // Trivial functions like this one are imported very reliably by ThinLTO.
- #[cfg(any(cfail1, cfail4))]
- pub fn inlined_fn() -> u32 {
- 1234
- }
-
- #[cfg(not(any(cfail1, cfail4)))]
- 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
deleted file mode 100644
index 045f20119..000000000
--- a/src/test/incremental/thinlto/independent_cgus_dont_affect_each_other.rs
+++ /dev/null
@@ -1,58 +0,0 @@
-// 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
-// build-pass (FIXME(62277): could be check-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 {
- // See `cgu_keeps_identical_fn.rs` for why this is different
- // from the other version of this function.
- 12345
- }
-}
-
-pub mod bar {
- use foo::inlined_fn;
-
- pub fn caller() -> u32 {
- inlined_fn()
- }
-}
-
-pub mod baz {
- pub fn unrelated_to_other_fns() -> u64 {
- 0xbeef
- }
-}