summaryrefslogtreecommitdiffstats
path: root/tests/codegen-units/partitioning/auxiliary
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/codegen-units/partitioning/auxiliary
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/codegen-units/partitioning/auxiliary')
-rw-r--r--tests/codegen-units/partitioning/auxiliary/cgu_explicit_inlining.rs10
-rw-r--r--tests/codegen-units/partitioning/auxiliary/cgu_extern_drop_glue.rs7
-rw-r--r--tests/codegen-units/partitioning/auxiliary/cgu_generic_function.rs26
-rw-r--r--tests/codegen-units/partitioning/auxiliary/shared_generics_aux.rs26
4 files changed, 69 insertions, 0 deletions
diff --git a/tests/codegen-units/partitioning/auxiliary/cgu_explicit_inlining.rs b/tests/codegen-units/partitioning/auxiliary/cgu_explicit_inlining.rs
new file mode 100644
index 000000000..4a3a63cc1
--- /dev/null
+++ b/tests/codegen-units/partitioning/auxiliary/cgu_explicit_inlining.rs
@@ -0,0 +1,10 @@
+#![crate_type = "lib"]
+
+#[inline]
+pub fn inlined() {}
+
+#[inline(always)]
+pub fn always_inlined() {}
+
+#[inline(never)]
+pub fn never_inlined() {}
diff --git a/tests/codegen-units/partitioning/auxiliary/cgu_extern_drop_glue.rs b/tests/codegen-units/partitioning/auxiliary/cgu_extern_drop_glue.rs
new file mode 100644
index 000000000..b5fec2337
--- /dev/null
+++ b/tests/codegen-units/partitioning/auxiliary/cgu_extern_drop_glue.rs
@@ -0,0 +1,7 @@
+#![crate_type = "lib"]
+
+pub struct Struct(pub u32);
+
+impl Drop for Struct {
+ fn drop(&mut self) {}
+}
diff --git a/tests/codegen-units/partitioning/auxiliary/cgu_generic_function.rs b/tests/codegen-units/partitioning/auxiliary/cgu_generic_function.rs
new file mode 100644
index 000000000..3926f2957
--- /dev/null
+++ b/tests/codegen-units/partitioning/auxiliary/cgu_generic_function.rs
@@ -0,0 +1,26 @@
+#![crate_type = "lib"]
+
+struct Struct(u32);
+
+#[inline(never)]
+pub fn foo<T>(x: T) -> (T, u32, i8) {
+ let (x, Struct(y)) = bar(x);
+ (x, y, 2)
+}
+
+#[inline(never)]
+fn bar<T>(x: T) -> (T, Struct) {
+ let _ = not_exported_and_not_generic(0);
+ (x, Struct(1))
+}
+
+// These should not contribute to the codegen items of other crates.
+#[inline(never)]
+pub fn exported_but_not_generic(x: i32) -> i64 {
+ x as i64
+}
+
+#[inline(never)]
+fn not_exported_and_not_generic(x: u32) -> u64 {
+ x as u64
+}
diff --git a/tests/codegen-units/partitioning/auxiliary/shared_generics_aux.rs b/tests/codegen-units/partitioning/auxiliary/shared_generics_aux.rs
new file mode 100644
index 000000000..ffbd0dc54
--- /dev/null
+++ b/tests/codegen-units/partitioning/auxiliary/shared_generics_aux.rs
@@ -0,0 +1,26 @@
+// NOTE: We always compile this test with -Copt-level=0 because higher opt-levels
+// prevent drop-glue from participating in share-generics.
+// compile-flags:-Zshare-generics=yes -Copt-level=0
+// no-prefer-dynamic
+
+#![crate_type="rlib"]
+
+pub fn generic_fn<T>(x: T, y: T) -> (T, T) {
+ (x, y)
+}
+
+pub fn use_generic_fn_f32() -> (f32, f32) {
+ // This line causes drop glue for Foo to be instantiated. We want to make
+ // sure that this crate exports an instance to be re-used by share-generics.
+ let _ = Foo(0);
+
+ generic_fn(0.0f32, 1.0f32)
+}
+
+pub struct Foo(pub u32);
+
+impl Drop for Foo {
+ fn drop(&mut self) {
+ println!("foo");
+ }
+}