| 1 |
// Test that clang doesn't emit llvm.expect when the counter is 0 |
| 2 |
|
| 3 |
// RUN: llvm-profdata merge %S/Inputs/cxx-never-executed-branch.proftext -o %t.profdata |
| 4 |
// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -O2 -o - -emit-llvm -fprofile-instrument-use=clang -fprofile-instrument-use-path=%t.profdata -disable-llvm-passes | FileCheck %s |
| 5 |
|
| 6 |
int rand(); |
| 7 |
|
| 8 |
// CHECK: define {{.*}}@_Z13is_in_profilev |
| 9 |
// CHECK-NOT: call {{.*}}@llvm.expect |
| 10 |
|
| 11 |
int is_in_profile() { |
| 12 |
int rando = rand(); |
| 13 |
int x = 0; |
| 14 |
if (rando == 0) [[likely]] |
| 15 |
x = 2; |
| 16 |
else |
| 17 |
x = 3; |
| 18 |
return x; |
| 19 |
} |
| 20 |
|
| 21 |
// CHECK: define {{.*}}@_Z17is_not_in_profilev |
| 22 |
// CHECK: call {{.*}}@llvm.expect |
| 23 |
|
| 24 |
int is_not_in_profile() { |
| 25 |
int rando = rand(); |
| 26 |
int x = 0; |
| 27 |
if (rando == 0) [[likely]] |
| 28 |
x = 2; |
| 29 |
else |
| 30 |
x = 3; |
| 31 |
return x; |
| 32 |
} |