]> git.proxmox.com Git - rustc.git/blob - tests/run-make-fulldeps/pgo-use/main.rs
eb9192c87e6f05b213bb62781d253119190e6d6a
[rustc.git] / tests / 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 }