File: cold_path2.rs

package info (click to toggle)
rustc 1.90.0%2Bdfsg1-1~bpo13%2B2
  • links: PTS, VCS
  • area: main
  • in suites: trixie-backports
  • size: 925,944 kB
  • sloc: xml: 158,148; javascript: 19,781; sh: 19,174; python: 15,732; ansic: 13,096; cpp: 7,181; asm: 4,376; makefile: 697; lisp: 176; sql: 15
file content (37 lines) | stat: -rw-r--r-- 738 bytes parent folder | download | duplicates (12)
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
//@ compile-flags: -O
#![crate_type = "lib"]
#![feature(core_intrinsics)]

use std::intrinsics::cold_path;

#[inline(never)]
#[no_mangle]
pub fn path_a() {
    println!("path a");
}

#[inline(never)]
#[no_mangle]
pub fn path_b() {
    println!("path b");
}

#[no_mangle]
pub fn test(x: Option<bool>) {
    if let Some(_) = x {
        path_a();
    } else {
        cold_path();
        path_b();
    }

    // CHECK-LABEL: void @test(i8{{.+}}%x)
    // CHECK: %[[IS_NONE:.+]] = icmp eq i8 %x, 2
    // CHECK: br i1 %[[IS_NONE]], label %bb2, label %bb1, !prof ![[NUM:[0-9]+]]
    // CHECK: bb1:
    // CHECK: path_a
    // CHECK: bb2:
    // CHECK: path_b
}

// CHECK: ![[NUM]] = !{!"branch_weights", {{(!"expected", )?}}i32 1, i32 2000}