File: inline_more_in_non_inline.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 (46 lines) | stat: -rw-r--r-- 1,215 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
34
35
36
37
38
39
40
41
42
43
44
45
46
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
//@ compile-flags: -O --crate-type lib

// To avoid MIR blow-up, don't inline large callees into simple shim callers,
// but *do* inline other trivial things.

extern "Rust" {
    fn other_thing(x: i32);
}

#[inline]
unsafe fn call_twice(x: i32) {
    unsafe {
        other_thing(x);
        other_thing(x);
    }
}

// EMIT_MIR inline_more_in_non_inline.monomorphic_not_inline.Inline.after.mir
#[no_mangle]
pub unsafe fn monomorphic_not_inline(x: i32) {
    // CHECK-LABEL: monomorphic_not_inline
    // CHECK: other_thing
    // CHECK: other_thing
    unsafe { call_twice(x) };
}

// EMIT_MIR inline_more_in_non_inline.marked_inline_direct.Inline.after.mir
#[inline]
pub unsafe fn marked_inline_direct(x: i32) {
    // CHECK-LABEL: marked_inline_direct
    // CHECK-NOT: other_thing
    // CHECK: call_twice
    // CHECK-NOT: other_thing
    unsafe { call_twice(x) };
}

// EMIT_MIR inline_more_in_non_inline.marked_inline_indirect.Inline.after.mir
#[inline]
pub unsafe fn marked_inline_indirect(x: i32) {
    // CHECK-LABEL: marked_inline_indirect
    // CHECK-NOT: other_thing
    // CHECK: call_twice
    // CHECK-NOT: other_thing
    unsafe { marked_inline_direct(x) };
}