File: no-redundant-item-monomorphization.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (33 lines) | stat: -rw-r--r-- 818 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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>();
}