]> git.lizzy.rs Git - rust.git/blob - src/test/run-make-fulldeps/pgo-use/main.rs
Rollup merge of #93217 - willcrichton:example-analyzer, r=GuillaumeGomez
[rust.git] / src / test / run-make-fulldeps / pgo-use / main.rs
1 #[no_mangle]
2 pub fn cold_function(c: u8) {
3     println!("cold {}", c);
4 }
5
6 #[no_mangle]
7 pub fn hot_function(c: u8) {
8     std::env::set_var(format!("var{}", c), format!("hot {}", c));
9 }
10
11 fn main() {
12     let arg = std::env::args().skip(1).next().unwrap();
13
14     for i in 0 .. 1000_000 {
15         let some_value = arg.as_bytes()[i % arg.len()];
16         if some_value == b'!' {
17             // This branch is never taken at runtime
18             cold_function(some_value);
19         } else {
20             hot_function(some_value);
21         }
22     }
23 }