about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-04-05 15:20:50 +0000
committerbors <bors@rust-lang.org>2024-04-05 15:20:50 +0000
commit1921968cc5403892739b43bdefe793a130badd15 (patch)
treef53db054de5cf0612c38d204349b32d9cfcbbe32 /tests/codegen
parent5958f5e08fa88ee95ede8c00f1b89befe0372d54 (diff)
parent9cb517aede5500e80d25a39ba9f079dcf29fb8d4 (diff)
downloadrust-1921968cc5403892739b43bdefe793a130badd15.tar.gz
rust-1921968cc5403892739b43bdefe793a130badd15.zip
Auto merge of #123497 - GuillaumeGomez:rollup-usqb4q9, r=GuillaumeGomez
Rollup of 8 pull requests

Successful merges:

 - #122334 (Vendor rustc_codegen_gcc)
 - #122894 (Move check for error in impl header outside of reporting)
 - #123149 (Port argument-non-c-like-enum to Rust)
 - #123311 (Match ergonomics: implement "`&`pat everywhere")
 - #123350 (Actually use the inferred `ClosureKind` from signature inference in coroutine-closures)
 - #123474 (Port `run-make/issue-7349` to a codegen test)
 - #123489 (handle rustc args properly in bootstrap)
 - #123496 (ping on wf changes, remove fixme)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/no-redundant-item-monomorphization.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/codegen/no-redundant-item-monomorphization.rs b/tests/codegen/no-redundant-item-monomorphization.rs
new file mode 100644
index 00000000000..466037c3770
--- /dev/null
+++ b/tests/codegen/no-redundant-item-monomorphization.rs
@@ -0,0 +1,33 @@
+// Test to make sure that inner functions within a polymorphic outer function
+// don't get re-codegened when the outer function is monomorphized. The test
+// code monomorphizes the outer functions several times, but the magic constants
+// used in the inner functions should each appear only once in the generated IR.
+
+// issue: rust-lang/rust#7349
+//@ compile-flags: -Cno-prepopulate-passes -Copt-level=0
+
+// CHECK-COUNT-1: ret i32 8675309
+// CHECK-COUNT-1: ret i32 11235813
+
+fn outer<T>() {
+    #[allow(dead_code)]
+    fn inner() -> u32 {
+        8675309
+    }
+    inner();
+}
+
+extern "C" fn outer_foreign<T>() {
+    #[allow(dead_code)]
+    fn inner() -> u32 {
+        11235813
+    }
+    inner();
+}
+
+fn main() {
+    outer::<isize>();
+    outer::<usize>();
+    outer_foreign::<isize>();
+    outer_foreign::<usize>();
+}