brintos

brintos / llvm-project-archived public Read only

0
0
Text · 694 B · 43ef3fc Raw
27 lines · c
1// Test that misexpect emits no warning when prediction is correct2 3// RUN: llvm-profdata merge %S/Inputs/misexpect-branch.proftext -o %t.profdata4// RUN: %clang_cc1 %s -O2 -o - -disable-llvm-passes -emit-llvm -fprofile-instrument-use=clang -fprofile-instrument-use-path=%t.profdata -verify -Wmisexpect5 6// expected-no-diagnostics7#define likely(x) __builtin_expect(!!(x), 1)8#define unlikely(x) __builtin_expect(!!(x), 0)9 10int foo(int);11int baz(int);12int buzz();13 14const int inner_loop = 100;15const int outer_loop = 2000;16 17int 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}27