Debian Codegraph @

clang/test/Profile/misexpect-branch-cold.c

raw
1 // Test that misexpect emits no warning when prediction is correct
2
3 // RUN: llvm-profdata merge %S/Inputs/misexpect-branch.proftext -o %t.profdata
4 // RUN: %clang_cc1 %s -O2 -o - -disable-llvm-passes -emit-llvm -fprofile-instrument-use=clang -fprofile-instrument-use-path=%t.profdata -verify -Wmisexpect
5
6 // expected-no-diagnostics
7 #define likely(x) __builtin_expect(!!(x), 1)
8 #define unlikely(x) __builtin_expect(!!(x), 0)
9
10 int foo(int);
11 int baz(int);
12 int buzz();
13
14 const int inner_loop = 100;
15 const int outer_loop = 2000;
16
17 int bar() {
18 int rando = buzz();
19 int x = 0;
20 if (unlikely(rando % (outer_loop * inner_loop) == 0)) {
21 x = baz(rando);
22 } else {
23 x = foo(50);
24 }
25 return x;
26 }