Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Profile / cxx-never-executed-branch.cpp
blob812f65f3996d3fe6f5237d91dac3db5b8cdd9886
1 // Test that clang doesn't emit llvm.expect when the counter is 0
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-path=%t.profdata -disable-llvm-passes | FileCheck %s
6 int rand();
8 // CHECK: define {{.*}}@_Z13is_in_profilev
9 // CHECK-NOT: call {{.*}}@llvm.expect
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;
21 // CHECK: define {{.*}}@_Z17is_not_in_profilev
22 // CHECK: call {{.*}}@llvm.expect
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;