brintos

brintos / llvm-project-archived public Read only

0
0
Text · 21.3 KiB · 6c865e6 Raw
587 lines · c
1// Test instrumentation of general constructs in C.2 3// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck -allow-deprecated-dag-overlap  -check-prefix=PGOGEN %s4 5// RUN: llvm-profdata merge %S/Inputs/c-general.proftext -o %t.profdata6// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instrument-use=clang -fprofile-instrument-use-path=%t.profdata | FileCheck -allow-deprecated-dag-overlap  -check-prefix=PGOUSE %s7// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instrument-use=clang -fprofile-instrument-use-path=%S/Inputs/c-general.profdata.v12 | FileCheck -allow-deprecated-dag-overlap  -check-prefix=PGOUSE %s8// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instrument-use=clang -fprofile-instrument-use-path=%S/Inputs/c-general.profdata.v5 | FileCheck -allow-deprecated-dag-overlap  -check-prefix=PGOUSE %s9// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instrument-use=clang -fprofile-instrument-use-path=%S/Inputs/c-general.profdata.v3 | FileCheck -allow-deprecated-dag-overlap  -check-prefix=PGOUSE %s10// Also check compatibility with older profiles.11// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instrument-use=clang -fprofile-instrument-use-path=%S/Inputs/c-general.profdata.v1 | FileCheck -allow-deprecated-dag-overlap  -check-prefix=PGOUSE %s12 13// RUN: %clang -fprofile-generate -E -dM %s | FileCheck -match-full-lines -check-prefix=PROFGENMACRO %s14// RUN: %clang -fprofile-instr-generate -E -dM %s | FileCheck -match-full-lines -check-prefix=PROFGENMACRO %s15// RUN: %clang -fcs-profile-generate -E -dM %s | FileCheck -match-full-lines -check-prefix=PROFGENMACRO %s16//17// RUN: %clang -fprofile-use=%t.profdata -E -dM %s | FileCheck -match-full-lines -check-prefix=PROFUSEMACRO %s18// RUN: %clang -fprofile-instr-use=%t.profdata -E -dM %s | FileCheck -match-full-lines -check-prefix=PROFUSEMACRO %s19 20// PROFGENMACRO:#define __LLVM_INSTR_PROFILE_GENERATE 121// PROFUSEMACRO:#define __LLVM_INSTR_PROFILE_USE 122 23// PGOGEN: @[[SLC:__profc_simple_loops]] = private global [4 x i64] zeroinitializer24// PGOGEN: @[[IFC:__profc_conditionals]] = private global [13 x i64] zeroinitializer25// PGOGEN: @[[EEC:__profc_early_exits]] = private global [9 x i64] zeroinitializer26// PGOGEN: @[[JMC:__profc_jumps]] = private global [22 x i64] zeroinitializer27// PGOGEN: @[[SWC:__profc_switches]] = private global [19 x i64] zeroinitializer28// PGOGEN: @[[BSC:__profc_big_switch]] = private global [17 x i64] zeroinitializer29// PGOGEN: @[[BOC:__profc_boolean_operators]] = private global [14 x i64] zeroinitializer30// PGOGEN: @[[BLC:__profc_boolop_loops]] = private global [13 x i64] zeroinitializer31// PGOGEN: @[[COC:__profc_conditional_operator]] = private global [3 x i64] zeroinitializer32// PGOGEN: @[[DFC:__profc_do_fallthrough]] = private global [4 x i64] zeroinitializer33// PGOGEN: @[[MAC:__profc_main]] = private global [1 x i64] zeroinitializer34// PGOGEN: @[[STC:__profc_c_general.c_static_func]] = private global [2 x i64] zeroinitializer35 36// PGOGEN-LABEL: @simple_loops()37// PGOUSE-LABEL: @simple_loops()38// PGOGEN: store {{.*}} @[[SLC]]39void simple_loops(void) {40  int i;41  // PGOGEN: store {{.*}} @[[SLC]], i32 0, i32 142  // PGOUSE: br {{.*}} !prof ![[SL1:[0-9]+]]43  for (i = 0; i < 100; ++i) {44  }45  // PGOGEN: store {{.*}} @[[SLC]], i32 0, i32 246  // PGOUSE: br {{.*}} !prof ![[SL2:[0-9]+]]47  while (i > 0)48    i--;49  // PGOGEN: store {{.*}} @[[SLC]], i32 0, i32 350  // PGOUSE: br {{.*}} !prof ![[SL3:[0-9]+]]51  do {} while (i++ < 75);52 53  // PGOGEN-NOT: store {{.*}} @[[SLC]],54  // PGOUSE-NOT: br {{.*}} !prof ![0-9]+55}56 57// PGOGEN-LABEL: @conditionals()58// PGOUSE-LABEL: @conditionals()59// PGOGEN: store {{.*}} @[[IFC]]60void conditionals(void) {61  // PGOGEN: store {{.*}} @[[IFC]], i32 0, i32 162  // PGOUSE: br {{.*}} !prof ![[IF1:[0-9]+]]63  for (int i = 0; i < 100; ++i) {64    // PGOGEN: store {{.*}} @[[IFC]], i32 0, i32 265    // PGOUSE: br {{.*}} !prof ![[IF2:[0-9]+]]66    if (i % 2) {67      // PGOGEN: store {{.*}} @[[IFC]], i32 0, i32 368      // PGOUSE: br {{.*}} !prof ![[IF3:[0-9]+]]69      if (i) {}70      // PGOGEN: store {{.*}} @[[IFC]], i32 0, i32 471      // PGOUSE: br {{.*}} !prof ![[IF4:[0-9]+]]72    } else if (i % 3) {73      // PGOGEN: store {{.*}} @[[IFC]], i32 0, i32 574      // PGOUSE: br {{.*}} !prof ![[IF5:[0-9]+]]75      if (i) {}76    } else {77      // PGOGEN: store {{.*}} @[[IFC]], i32 0, i32 678      // PGOUSE: br {{.*}} !prof ![[IF6:[0-9]+]]79      if (i) {}80    }81 82    // PGOGEN: store {{.*}} @[[IFC]], i32 0, i32 883    // PGOGEN: store {{.*}} @[[IFC]], i32 0, i32 984    // PGOGEN: store {{.*}} @[[IFC]], i32 0, i32 785    // PGOUSE: br {{.*}} !prof ![[IF7:[0-9]+]]86    if (1 && i) {}87    // PGOGEN: store {{.*}} @[[IFC]], i32 0, i32 1188    // PGOGEN: store {{.*}} @[[IFC]], i32 0, i32 1289    // PGOGEN: store {{.*}} @[[IFC]], i32 0, i32 1090    // PGOUSE: br {{.*}} !prof ![[IF8:[0-9]+]]91    if (0 || i) {}92  }93 94  // PGOGEN-NOT: store {{.*}} @[[IFC]],95  // PGOUSE-NOT: br {{.*}} !prof ![0-9]+96}97 98// PGOGEN-LABEL: @early_exits()99// PGOUSE-LABEL: @early_exits()100// PGOGEN: store {{.*}} @[[EEC]]101void early_exits(void) {102  int i = 0;103 104  // PGOGEN: store {{.*}} @[[EEC]], i32 0, i32 1105  // PGOUSE: br {{.*}} !prof ![[EE1:[0-9]+]]106  if (i) {}107 108  // PGOGEN: store {{.*}} @[[EEC]], i32 0, i32 2109  // PGOUSE: br {{.*}} !prof ![[EE2:[0-9]+]]110  while (i < 100) {111    i++;112    // PGOGEN: store {{.*}} @[[EEC]], i32 0, i32 3113    // PGOUSE: br {{.*}} !prof ![[EE3:[0-9]+]]114    if (i > 50)115      break;116    // PGOGEN: store {{.*}} @[[EEC]], i32 0, i32 4117    // PGOUSE: br {{.*}} !prof ![[EE4:[0-9]+]]118    if (i % 2)119      continue;120  }121 122  // PGOGEN: store {{.*}} @[[EEC]], i32 0, i32 5123  // PGOUSE: br {{.*}} !prof ![[EE5:[0-9]+]]124  if (i) {}125 126  // PGOGEN: store {{.*}} @[[EEC]], i32 0, i32 6127  do {128    // PGOGEN: store {{.*}} @[[EEC]], i32 0, i32 7129    // PGOUSE: br {{.*}} !prof ![[EE6:[0-9]+]]130    if (i > 75)131      return;132    else133      i++;134  // PGOUSE: br {{.*}} !prof ![[EE7:[0-9]+]]135  } while (i < 100);136 137  // PGOGEN: store {{.*}} @[[EEC]], i32 0, i32 8138  // Never reached -> no weights139  if (i) {}140 141  // PGOGEN-NOT: store {{.*}} @[[EEC]],142  // PGOUSE-NOT: br {{.*}} !prof ![0-9]+143}144 145// PGOGEN-LABEL: @jumps()146// PGOUSE-LABEL: @jumps()147// PGOGEN: store {{.*}} @[[JMC]]148void jumps(void) {149  int i;150 151  // PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 1152  // PGOUSE: br {{.*}} !prof ![[JM1:[0-9]+]]153  for (i = 0; i < 2; ++i) {154    goto outofloop;155    // Never reached -> no weights156    if (i) {}157  }158// PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 3159outofloop:160  // PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 4161  // PGOUSE: br {{.*}} !prof ![[JM2:[0-9]+]]162  if (i) {}163 164  goto loop1;165 166  // PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 5167  // PGOUSE: br {{.*}} !prof ![[JM3:[0-9]+]]168  while (i) {169  // PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 6170  loop1:171    // PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 7172    // PGOUSE: br {{.*}} !prof ![[JM4:[0-9]+]]173    if (i) {}174  }175 176  goto loop2;177// PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 8178first:179// PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 9180second:181// PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 10182third:183  i++;184  // PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 11185  // PGOUSE: br {{.*}} !prof ![[JM5:[0-9]+]]186  if (i < 3)187    goto loop2;188 189  // PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 12190  // PGOUSE: br {{.*}} !prof ![[JM6:[0-9]+]]191  while (i < 3) {192  // PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 13193  loop2:194    // PGOUSE: switch {{.*}} [195    // PGOUSE: ], !prof ![[JM7:[0-9]+]]196    switch (i) {197    // PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 15198    case 0:199      goto first;200    // PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 16201    case 1:202      goto second;203    // PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 17204    case 2:205      goto third;206    }207    // PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 14208  }209 210  // PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 18211  // PGOUSE: br {{.*}} !prof ![[JM8:[0-9]+]]212  for (i = 0; i < 10; ++i) {213    goto withinloop;214    // never reached -> no weights215    if (i) {}216  // PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 20217  withinloop:218    // PGOGEN: store {{.*}} @[[JMC]], i32 0, i32 21219    // PGOUSE: br {{.*}} !prof ![[JM9:[0-9]+]]220    if (i) {}221  }222 223  // PGOGEN-NOT: store {{.*}} @[[JMC]],224  // PGOUSE-NOT: br {{.*}} !prof ![0-9]+225}226 227// PGOGEN-LABEL: @switches()228// PGOUSE-LABEL: @switches()229// PGOGEN: store {{.*}} @[[SWC]]230void switches(void) {231  static int weights[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5};232 233  // No cases -> no weights234  switch (weights[0]) {235  // PGOGEN: store {{.*}} @[[SWC]], i32 0, i32 2236  default:237    break;238  }239  // PGOGEN: store {{.*}} @[[SWC]], i32 0, i32 1240 241  // PGOGEN: store {{.*}} @[[SWC]], i32 0, i32 3242  // PGOUSE: br {{.*}} !prof ![[SW1:[0-9]+]]243  for (int i = 0, len = sizeof(weights) / sizeof(weights[0]); i < len; ++i) {244    // PGOUSE: switch {{.*}} [245    // PGOUSE: ], !prof ![[SW2:[0-9]+]]246    switch (i[weights]) {247    // PGOGEN: store {{.*}} @[[SWC]], i32 0, i32 5248    case 1:249      // PGOGEN: store {{.*}} @[[SWC]], i32 0, i32 6250      // PGOUSE: br {{.*}} !prof ![[SW3:[0-9]+]]251      if (i) {}252      // fallthrough253    // PGOGEN: store {{.*}} @[[SWC]], i32 0, i32 7254    case 2:255      // PGOGEN: store {{.*}} @[[SWC]], i32 0, i32 8256      // PGOUSE: br {{.*}} !prof ![[SW4:[0-9]+]]257      if (i) {}258      break;259    // PGOGEN: store {{.*}} @[[SWC]], i32 0, i32 9260    case 3:261      // PGOGEN: store {{.*}} @[[SWC]], i32 0, i32 10262      // PGOUSE: br {{.*}} !prof ![[SW5:[0-9]+]]263      if (i) {}264      continue;265    // PGOGEN: store {{.*}} @[[SWC]], i32 0, i32 11266    case 4:267      // PGOGEN: store {{.*}} @[[SWC]], i32 0, i32 12268      // PGOUSE: br {{.*}} !prof ![[SW6:[0-9]+]]269      if (i) {}270      // PGOUSE: switch {{.*}} [271      // PGOUSE: ], !prof ![[SW7:[0-9]+]]272      switch (i) {273      // PGOGEN: store {{.*}} @[[SWC]], i32 0, i32 14274      case 6 ... 9:275        // PGOGEN: store {{.*}} @[[SWC]], i32 0, i32 15276        // PGOUSE: br {{.*}} !prof ![[SW8:[0-9]+]]277        if (i) {}278        continue;279      }280      // PGOGEN: store {{.*}} @[[SWC]], i32 0, i32 13281 282    // PGOGEN: store {{.*}} @[[SWC]], i32 0, i32 16283    default:284      // PGOGEN: store {{.*}} @[[SWC]], i32 0, i32 17285      // PGOUSE: br {{.*}} !prof ![[SW9:[0-9]+]]286      if (i == len - 1)287        return;288    }289    // PGOGEN: store {{.*}} @[[SWC]], i32 0, i32 4290  }291 292  // PGOGEN: store {{.*}} @[[SWC]], i32 0, i32 18293  // Never reached -> no weights294  if (weights[0]) {}295 296  // PGOGEN-NOT: store {{.*}} @[[SWC]],297  // PGOUSE-NOT: br {{.*}} !prof ![0-9]+298}299 300// PGOGEN-LABEL: @big_switch()301// PGOUSE-LABEL: @big_switch()302// PGOGEN: store {{.*}} @[[BSC]]303void big_switch(void) {304  // PGOGEN: store {{.*}} @[[BSC]], i32 0, i32 1305  // PGOUSE: br {{.*}} !prof ![[BS1:[0-9]+]]306  for (int i = 0; i < 32; ++i) {307    // PGOUSE: switch {{.*}} [308    // PGOUSE: ], !prof ![[BS2:[0-9]+]]309    switch (1 << i) {310    // PGOGEN: store {{.*}} @[[BSC]], i32 0, i32 3311    case (1 << 0):312      // PGOGEN: store {{.*}} @[[BSC]], i32 0, i32 4313      // PGOUSE: br {{.*}} !prof ![[BS3:[0-9]+]]314      if (i) {}315      // fallthrough316    // PGOGEN: store {{.*}} @[[BSC]], i32 0, i32 5317    case (1 << 1):318      // PGOGEN: store {{.*}} @[[BSC]], i32 0, i32 6319      // PGOUSE: br {{.*}} !prof ![[BS4:[0-9]+]]320      if (i) {}321      break;322    // PGOGEN: store {{.*}} @[[BSC]], i32 0, i32 7323    case (1 << 2) ... (1 << 12):324      // PGOGEN: store {{.*}} @[[BSC]], i32 0, i32 8325      // PGOUSE: br {{.*}} !prof ![[BS5:[0-9]+]]326      if (i) {}327      break;328    // The branch for the large case range above appears after the case body329    // PGOUSE: br {{.*}} !prof ![[BS6:[0-9]+]]330 331    // PGOGEN: store {{.*}} @[[BSC]], i32 0, i32 9332    case (1 << 13):333      // PGOGEN: store {{.*}} @[[BSC]], i32 0, i32 10334      // PGOUSE: br {{.*}} !prof ![[BS7:[0-9]+]]335      if (i) {}336      break;337    // PGOGEN: store {{.*}} @[[BSC]], i32 0, i32 11338    case (1 << 14) ... (1 << 28):339      // PGOGEN: store {{.*}} @[[BSC]], i32 0, i32 12340      // PGOUSE: br {{.*}} !prof ![[BS8:[0-9]+]]341      if (i) {}342      break;343    // The branch for the large case range above appears after the case body344    // PGOUSE: br {{.*}} !prof ![[BS9:[0-9]+]]345 346    // PGOGEN: store {{.*}} @[[BSC]], i32 0, i32 13347    case (1 << 29) ... ((1 << 29) + 1):348      // PGOGEN: store {{.*}} @[[BSC]], i32 0, i32 14349      // PGOUSE: br {{.*}} !prof ![[BS10:[0-9]+]]350      if (i) {}351      break;352    // PGOGEN: store {{.*}} @[[BSC]], i32 0, i32 15353    default:354      // PGOGEN: store {{.*}} @[[BSC]], i32 0, i32 16355      // PGOUSE: br {{.*}} !prof ![[BS11:[0-9]+]]356      if (i) {}357      break;358    }359    // PGOGEN: store {{.*}} @[[BSC]], i32 0, i32 2360  }361 362  // PGOGEN-NOT: store {{.*}} @[[BSC]],363  // PGOUSE-NOT: br {{.*}} !prof ![0-9]+364  // PGOUSE: ret void365}366 367// PGOGEN-LABEL: @boolean_operators()368// PGOUSE-LABEL: @boolean_operators()369// PGOGEN: store {{.*}} @[[BOC]]370void boolean_operators(void) {371  int v;372  // PGOGEN: store {{.*}} @[[BOC]], i32 0, i32 1373  // PGOUSE: br {{.*}} !prof ![[BO1:[0-9]+]]374  for (int i = 0; i < 100; ++i) {375    // PGOGEN: store {{.*}} @[[BOC]], i32 0, i32 2376    // PGOGEN: store {{.*}} @[[BOC]], i32 0, i32 3377    // PGOUSE: br {{.*}} !prof ![[BO2:[0-9]+]]378    v = i % 3 || i;379 380    // PGOGEN: store {{.*}} @[[BOC]], i32 0, i32 4381    // PGOGEN: store {{.*}} @[[BOC]], i32 0, i32 5382    // PGOUSE: br {{.*}} !prof ![[BO3:[0-9]+]]383    v = i % 3 && i;384 385    // PGOGEN: store {{.*}} @[[BOC]], i32 0, i32 8386    // PGOGEN: store {{.*}} @[[BOC]], i32 0, i32 9387    // PGOGEN: store {{.*}} @[[BOC]], i32 0, i32 6388    // PGOGEN: store {{.*}} @[[BOC]], i32 0, i32 7389    // PGOUSE: br {{.*}} !prof ![[BO4:[0-9]+]]390    // PGOUSE: br {{.*}} !prof ![[BO5:[0-9]+]]391    v = i % 3 || i % 2 || i;392 393    // PGOGEN: store {{.*}} @[[BOC]], i32 0, i32 12394    // PGOGEN: store {{.*}} @[[BOC]], i32 0, i32 13395    // PGOGEN: store {{.*}} @[[BOC]], i32 0, i32 10396    // PGOGEN: store {{.*}} @[[BOC]], i32 0, i32 11397    // PGOUSE: br {{.*}} !prof ![[BO6:[0-9]+]]398    // PGOUSE: br {{.*}} !prof ![[BO7:[0-9]+]]399    v = i % 2 && i % 3 && i;400  }401 402  // PGOGEN-NOT: store {{.*}} @[[BOC]],403  // PGOUSE-NOT: br {{.*}} !prof ![0-9]+404}405 406// PGOGEN-LABEL: @boolop_loops()407// PGOUSE-LABEL: @boolop_loops()408// PGOGEN: store {{.*}} @[[BLC]]409void boolop_loops(void) {410  int i = 100;411 412  // PGOGEN: store {{.*}} @[[BLC]], i32 0, i32 2413  // PGOGEN: store {{.*}} @[[BLC]], i32 0, i32 3414  // PGOGEN: store {{.*}} @[[BLC]], i32 0, i32 1415  // PGOUSE: br {{.*}} !prof ![[BL1:[0-9]+]]416  // PGOUSE: br {{.*}} !prof ![[BL2:[0-9]+]]417  while (i && i > 50)418    i--;419 420  // PGOGEN: store {{.*}} @[[BLC]], i32 0, i32 5421  // PGOGEN: store {{.*}} @[[BLC]], i32 0, i32 6422  // PGOGEN: store {{.*}} @[[BLC]], i32 0, i32 4423  // PGOUSE: br {{.*}} !prof ![[BL3:[0-9]+]]424  // PGOUSE: br {{.*}} !prof ![[BL4:[0-9]+]]425  while ((i % 2) || (i > 0))426    i--;427 428  // PGOGEN: store {{.*}} @[[BLC]], i32 0, i32 8429  // PGOGEN: store {{.*}} @[[BLC]], i32 0, i32 9430  // PGOGEN: store {{.*}} @[[BLC]], i32 0, i32 7431  // PGOUSE: br {{.*}} !prof ![[BL5:[0-9]+]]432  // PGOUSE: br {{.*}} !prof ![[BL6:[0-9]+]]433  for (i = 100; i && i > 50; --i);434 435  // PGOGEN: store {{.*}} @[[BLC]], i32 0, i32 11436  // PGOGEN: store {{.*}} @[[BLC]], i32 0, i32 12437  // PGOGEN: store {{.*}} @[[BLC]], i32 0, i32 10438  // PGOUSE: br {{.*}} !prof ![[BL7:[0-9]+]]439  // PGOUSE: br {{.*}} !prof ![[BL8:[0-9]+]]440  for (; (i % 2) || (i > 0); --i);441 442  // PGOGEN-NOT: store {{.*}} @[[BLC]],443  // PGOUSE-NOT: br {{.*}} !prof ![0-9]+444}445 446// PGOGEN-LABEL: @conditional_operator()447// PGOUSE-LABEL: @conditional_operator()448// PGOGEN: store {{.*}} @[[COC]]449void conditional_operator(void) {450  int i = 100;451 452  // PGOGEN: store {{.*}} @[[COC]], i32 0, i32 1453  // PGOUSE: br {{.*}} !prof ![[CO1:[0-9]+]]454  int j = i < 50 ? i : 1;455 456  // PGOGEN: store {{.*}} @[[COC]], i32 0, i32 2457  // PGOUSE: br {{.*}} !prof ![[CO2:[0-9]+]]458  int k = i ?: 0;459 460  // PGOGEN-NOT: store {{.*}} @[[COC]],461  // PGOUSE-NOT: br {{.*}} !prof ![0-9]+462}463 464// PGOGEN-LABEL: @do_fallthrough()465// PGOUSE-LABEL: @do_fallthrough()466// PGOGEN: store {{.*}} @[[DFC]]467void do_fallthrough(void) {468  // PGOGEN: store {{.*}} @[[DFC]], i32 0, i32 1469  // PGOUSE: br {{.*}} !prof ![[DF1:[0-9]+]]470  for (int i = 0; i < 10; ++i) {471    int j = 0;472    // PGOGEN: store {{.*}} @[[DFC]], i32 0, i32 2473    do {474      // The number of exits out of this do-loop via the break statement475      // exceeds the counter value for the loop (which does not include the476      // fallthrough count). Make sure that does not violate any assertions.477      // PGOGEN: store {{.*}} @[[DFC]], i32 0, i32 3478      // PGOUSE: br {{.*}} !prof ![[DF3:[0-9]+]]479      if (i < 8) break;480      j++;481    // PGOUSE: br {{.*}} !prof ![[DF2:[0-9]+]]482    } while (j < 2);483  }484}485 486// PGOGEN-LABEL: @static_func()487// PGOUSE-LABEL: @static_func()488// PGOGEN: store {{.*}} @[[STC]]489static void static_func(void) {490  // PGOGEN: store {{.*}} @[[STC]], i32 0, i32 1491  // PGOUSE: br {{.*}} !prof ![[ST1:[0-9]+]]492  for (int i = 0; i < 10; ++i) {493  }494}495 496// PGOUSE-DAG: ![[SL1]] = !{!"branch_weights", i32 101, i32 2}497// PGOUSE-DAG: ![[SL2]] = !{!"branch_weights", i32 101, i32 2}498// PGOUSE-DAG: ![[SL3]] = !{!"branch_weights", i32 76, i32 2}499 500// PGOUSE-DAG: ![[EE1]] = !{!"branch_weights", i32 1, i32 2}501// PGOUSE-DAG: ![[EE2]] = !{!"branch_weights", i32 52, i32 1}502// PGOUSE-DAG: ![[EE3]] = !{!"branch_weights", i32 2, i32 51}503// PGOUSE-DAG: ![[EE4]] = !{!"branch_weights", i32 26, i32 26}504// PGOUSE-DAG: ![[EE5]] = !{!"branch_weights", i32 2, i32 1}505// PGOUSE-DAG: ![[EE6]] = !{!"branch_weights", i32 2, i32 26}506// PGOUSE-DAG: ![[EE7]] = !{!"branch_weights", i32 26, i32 1}507 508// PGOUSE-DAG: ![[IF1]] = !{!"branch_weights", i32 101, i32 2}509// PGOUSE-DAG: ![[IF2]] = !{!"branch_weights", i32 51, i32 51}510// PGOUSE-DAG: ![[IF3]] = !{!"branch_weights", i32 51, i32 1}511// PGOUSE-DAG: ![[IF4]] = !{!"branch_weights", i32 34, i32 18}512// PGOUSE-DAG: ![[IF5]] = !{!"branch_weights", i32 34, i32 1}513// PGOUSE-DAG: ![[IF6]] = !{!"branch_weights", i32 17, i32 2}514// PGOUSE-DAG: ![[IF7]] = !{!"branch_weights", i32 100, i32 2}515// PGOUSE-DAG: ![[IF8]] = !{!"branch_weights", i32 100, i32 2}516 517// PGOUSE-DAG: ![[JM1]] = !{!"branch_weights", i32 2, i32 1}518// PGOUSE-DAG: ![[JM2]] = !{!"branch_weights", i32 1, i32 2}519// PGOUSE-DAG: ![[JM3]] = !{!"branch_weights", i32 1, i32 2}520// PGOUSE-DAG: ![[JM4]] = !{!"branch_weights", i32 1, i32 2}521// PGOUSE-DAG: ![[JM5]] = !{!"branch_weights", i32 3, i32 2}522// PGOUSE-DAG: ![[JM6]] = !{!"branch_weights", i32 1, i32 2}523// PGOUSE-DAG: ![[JM7]] = !{!"branch_weights", i32 1, i32 2, i32 2, i32 2}524// PGOUSE-DAG: ![[JM8]] = !{!"branch_weights", i32 11, i32 2}525// PGOUSE-DAG: ![[JM9]] = !{!"branch_weights", i32 10, i32 2}526 527// PGOUSE-DAG: ![[SW1]] = !{!"branch_weights", i32 16, i32 1}528// PGOUSE-DAG: ![[SW2]] = !{!"branch_weights", i32 6, i32 2, i32 3, i32 4, i32 5}529// PGOUSE-DAG: ![[SW3]] = !{!"branch_weights", i32 1, i32 2}530// PGOUSE-DAG: ![[SW4]] = !{!"branch_weights", i32 3, i32 2}531// PGOUSE-DAG: ![[SW5]] = !{!"branch_weights", i32 4, i32 1}532// PGOUSE-DAG: ![[SW6]] = !{!"branch_weights", i32 5, i32 1}533// PGOUSE-DAG: ![[SW7]] = !{!"branch_weights", i32 1, i32 2, i32 2, i32 2, i32 2}534// PGOUSE-DAG: ![[SW8]] = !{!"branch_weights", i32 5, i32 1}535// PGOUSE-DAG: ![[SW9]] = !{!"branch_weights", i32 2, i32 5}536 537// PGOUSE-DAG: ![[BS1]] = !{!"branch_weights", i32 33, i32 2}538// PGOUSE-DAG: ![[BS2]] = !{!"branch_weights", i32 29, i32 2, i32 2, i32 2, i32 2, i32 1}539// PGOUSE-DAG: ![[BS3]] = !{!"branch_weights", i32 1, i32 2}540// PGOUSE-DAG: ![[BS4]] = !{!"branch_weights", i32 2, i32 2}541// PGOUSE-DAG: ![[BS5]] = !{!"branch_weights", i32 12, i32 1}542// PGOUSE-DAG: ![[BS6]] = !{!"branch_weights", i32 12, i32 3}543// PGOUSE-DAG: ![[BS7]] = !{!"branch_weights", i32 2, i32 1}544// PGOUSE-DAG: ![[BS8]] = !{!"branch_weights", i32 16, i32 1}545// PGOUSE-DAG: ![[BS9]] = !{!"branch_weights", i32 16, i32 14}546// PGOUSE-DAG: ![[BS10]] = !{!"branch_weights", i32 2, i32 1}547// PGOUSE-DAG: ![[BS11]] = !{!"branch_weights", i32 3, i32 1}548 549// PGOUSE-DAG: ![[BO1]] = !{!"branch_weights", i32 101, i32 2}550// PGOUSE-DAG: ![[BO2]] = !{!"branch_weights", i32 67, i32 35}551// PGOUSE-DAG: ![[BO3]] = !{!"branch_weights", i32 67, i32 35}552// PGOUSE-DAG: ![[BO4]] = !{!"branch_weights", i32 67, i32 35}553// PGOUSE-DAG: ![[BO5]] = !{!"branch_weights", i32 18, i32 18}554// PGOUSE-DAG: ![[BO6]] = !{!"branch_weights", i32 51, i32 51}555// PGOUSE-DAG: ![[BO7]] = !{!"branch_weights", i32 34, i32 18}556// PGOUSE-DAG: ![[BL1]] = !{!"branch_weights", i32 52, i32 1}557// PGOUSE-DAG: ![[BL2]] = !{!"branch_weights", i32 51, i32 2}558// PGOUSE-DAG: ![[BL3]] = !{!"branch_weights", i32 26, i32 27}559// PGOUSE-DAG: ![[BL4]] = !{!"branch_weights", i32 51, i32 2}560// PGOUSE-DAG: ![[BL5]] = !{!"branch_weights", i32 52, i32 1}561// PGOUSE-DAG: ![[BL6]] = !{!"branch_weights", i32 51, i32 2}562// PGOUSE-DAG: ![[BL7]] = !{!"branch_weights", i32 26, i32 27}563// PGOUSE-DAG: ![[BL8]] = !{!"branch_weights", i32 51, i32 2}564// PGOUSE-DAG: ![[CO1]] = !{!"branch_weights", i32 1, i32 2}565// PGOUSE-DAG: ![[CO2]] = !{!"branch_weights", i32 2, i32 1}566 567// PGOUSE-DAG: ![[DF1]] = !{!"branch_weights", i32 11, i32 2}568// PGOUSE-DAG: ![[DF2]] = !{!"branch_weights", i32 3, i32 3}569// PGOUSE-DAG: ![[DF3]] = !{!"branch_weights", i32 9, i32 5}570 571// PGOUSE-DAG: ![[ST1]] = !{!"branch_weights", i32 11, i32 2}572 573int main(int argc, const char *argv[]) {574  simple_loops();575  conditionals();576  early_exits();577  jumps();578  switches();579  big_switch();580  boolean_operators();581  boolop_loops();582  conditional_operator();583  do_fallthrough();584  static_func();585  return 0;586}587