diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-07-21 14:34:12 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-07-22 14:28:48 +0200 |
| commit | a27f3e3fd1e4d16160f8885b6b06665b5319f56c (patch) | |
| tree | b033935392cbadf6f85d2dbddf433a88e323aeeb /tests/codegen-llvm/no-redundant-item-monomorphization.rs | |
| parent | ed93c1783b404d728d4809973a0550eb33cd293f (diff) | |
| download | rust-a27f3e3fd1e4d16160f8885b6b06665b5319f56c.tar.gz rust-a27f3e3fd1e4d16160f8885b6b06665b5319f56c.zip | |
Rename `tests/codegen` into `tests/codegen-llvm`
Diffstat (limited to 'tests/codegen-llvm/no-redundant-item-monomorphization.rs')
| -rw-r--r-- | tests/codegen-llvm/no-redundant-item-monomorphization.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/codegen-llvm/no-redundant-item-monomorphization.rs b/tests/codegen-llvm/no-redundant-item-monomorphization.rs new file mode 100644 index 00000000000..466037c3770 --- /dev/null +++ b/tests/codegen-llvm/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>(); +} |
