brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 5309722 Raw
176 lines · cpp
1// Check that all of the hashes in this file are unique (i.e, that none of the2// profiles for these functions are mutually interchangeable).3//4// RUN: llvm-profdata show -all-functions %S/Inputs/cxx-hash-v2.profdata.v5 | grep "Hash: 0x" | sort > %t.hashes5// RUN: uniq %t.hashes > %t.hashes.unique6// RUN: diff %t.hashes %t.hashes.unique7 8// RUN: llvm-profdata merge %S/Inputs/cxx-hash-v2.proftext -o %t.profdata9// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -triple x86_64-apple-macosx10.9 -main-file-name cxx-hash-v2.mm %s -o /dev/null -emit-llvm -fprofile-instrument-use=clang -fprofile-instrument-use-path=%t.profdata 2>&1 | FileCheck %s -allow-empty10// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -triple x86_64-apple-macosx10.9 -main-file-name cxx-hash-v2.mm %s -o /dev/null -emit-llvm -fprofile-instrument-use=clang -fprofile-instrument-use-path=%S/Inputs/cxx-hash-v2.profdata.v5 2>&1 | FileCheck %s -allow-empty11 12// CHECK-NOT: warning: profile data may be out of date13 14int x;15int arr[1] = {0};16 17void loop_after_if_else() {18  if (1)19    x = 1;20  else21    x = 2;22  while (0)23    ++x;24}25 26void loop_in_then_block() {27  if (1) {28    while (0)29      ++x;30  } else {31    x = 2;32  }33}34 35void loop_in_else_block() {36  if (1) {37    x = 1;38  } else {39    while (0)40      ++x;41  }42}43 44void if_inside_of_for() {45  for (x = 0; x < 0; ++x) {46    x = 1;47    if (1)48      x = 2;49  }50}51 52void if_outside_of_for() {53  for (x = 0; x < 0; ++x)54    x = 1;55  if (1)56    x = 2;57}58 59void if_inside_of_while() {60  while (0) {61    x = 1;62    if (1)63      x = 2;64  }65}66 67void if_outside_of_while() {68  while (0)69    x = 1;70  if (1)71    x = 2;72}73 74void nested_dos() {75  do {76    do {77      ++x;78    } while (0);79  } while (0);80}81 82void consecutive_dos() {83  do {84  } while (0);85  do {86    ++x;87  } while (0);88}89 90void loop_empty() {91  for (x = 0; x < 5; ++x) {}92}93 94void loop_return() {95  for (x = 0; x < 5; ++x)96    return;97}98 99void loop_continue() {100  for (x = 0; x < 5; ++x)101    continue;102}103 104void loop_break() {105  for (x = 0; x < 5; ++x)106    break;107}108 109void no_gotos() {110  static void *dispatch[] = {&&done};111  x = 0;112done:113  ++x;114}115 116void direct_goto() {117  static void *dispatch[] = {&&done};118  x = 0;119  goto done;120done:121  ++x;122}123 124void indirect_goto() {125  static void *dispatch[] = {&&done};126  x = 0;127  goto *dispatch[x];128done:129  ++x;130}131 132void nested_for_ranges() {133  for (int a : arr)134    for (int b : arr)135      ++x;136}137 138void consecutive_for_ranges() {139  for (int a : arr) {}140  for (int b : arr)141    ++x;142}143 144void nested_try_catch() {145  try {146    try {147      ++x;148    } catch (...) {}149  } catch (...) {}150}151 152void consecutive_try_catch() {153  try {} catch (...) {}154  try {155    ++x;156  } catch (...) {}157}158 159void no_throw() {}160 161void has_throw() {162  throw 0;163}164 165void single_lnot() {166  if (!x) {}167}168 169void double_lnot() {170  if (!!x) {}171}172 173int main() {174  return 0;175}176