brintos

brintos / llvm-project-archived public Read only

0
0
Text · 786 B · d7bdd3c Raw
33 lines · cpp
1// Test that clang doesn't emit llvm.expect when the counter is 02 3// RUN: llvm-profdata merge %S/Inputs/cxx-never-executed-branch.proftext -o %t.profdata4// 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 %s5 6int rand();7 8// CHECK: define {{.*}}@_Z13is_in_profilev9// CHECK-NOT: call {{.*}}@llvm.expect10 11int is_in_profile() {12  int rando = rand();13  int x = 0;14  if (rando == 0) [[likely]]15    x = 2;16  else17    x = 3;18  return x;19}20 21// CHECK: define {{.*}}@_Z17is_not_in_profilev22// CHECK: call {{.*}}@llvm.expect23 24int is_not_in_profile() {25  int rando = rand();26  int x = 0;27  if (rando == 0) [[likely]]28    x = 2;29  else30    x = 3;31  return x;32}33