diff options
| author | Bob Wilson <bob.wilson@apple.com> | 2014-02-17 19:21:09 +0000 |
|---|---|---|
| committer | Bob Wilson <bob.wilson@apple.com> | 2014-02-17 19:21:09 +0000 |
| commit | bf854f0f53eab60d127d13e33068993007da280f (patch) | |
| tree | 29dde13fe5bf590de7b56280323d46a29d22853a /clang/test/CodeGen/instr-profile.c | |
| parent | a7b16e0ffde87990d3c6ae53e7bb456e2d888bd9 (diff) | |
| download | bcm5719-llvm-bf854f0f53eab60d127d13e33068993007da280f.tar.gz bcm5719-llvm-bf854f0f53eab60d127d13e33068993007da280f.zip | |
Change PGO instrumentation to compute counts in a separate AST traversal.
Previously, we made one traversal of the AST prior to codegen to assign
counters to the ASTs and then propagated the count values during codegen. This
patch now adds a separate AST traversal prior to codegen for the
-fprofile-instr-use option to propagate the count values. The counts are then
saved in a map from which they can be retrieved during codegen.
This new approach has several advantages:
1. It gets rid of a lot of extra PGO-related code that had previously been
added to codegen.
2. It fixes a serious bug. My original implementation (which was mailed to the
list but never committed) used 3 counters for every loop. Justin improved it to
move 2 of those counters into the less-frequently executed breaks and continues,
but that turned out to produce wrong count values in some cases. The solution
requires visiting a loop body before the condition so that the count for the
condition properly includes the break and continue counts. Changing codegen to
visit a loop body first would be a fairly invasive change, but with a separate
AST traversal, it is easy to control the order of traversal. I've added a
testcase (provided by Justin) to make sure this works correctly.
3. It improves the instrumentation overhead, reducing the number of counters for
a loop from 3 to 1. We no longer need dedicated counters for breaks and
continues, since we can just use the propagated count values when visiting
breaks and continues.
To make this work, I needed to make a change to the way we count case
statements, going back to my original approach of not including the fall-through
in the counter values. This was necessary because there isn't always an AST node
that can be used to record the fall-through count. Now case statements are
handled the same as default statements, with the fall-through paths branching
over the counter increments. While I was at it, I also went back to using this
approach for do-loops -- omitting the fall-through count into the loop body
simplifies some of the calculations and make them behave the same as other
loops. Whenever we start using this instrumentation for coverage, we'll need
to add the fall-through counts into the counter values.
llvm-svn: 201528
Diffstat (limited to 'clang/test/CodeGen/instr-profile.c')
| -rw-r--r-- | clang/test/CodeGen/instr-profile.c | 207 |
1 files changed, 125 insertions, 82 deletions
diff --git a/clang/test/CodeGen/instr-profile.c b/clang/test/CodeGen/instr-profile.c index c8e75a7e8c9..b5062f4c908 100644 --- a/clang/test/CodeGen/instr-profile.c +++ b/clang/test/CodeGen/instr-profile.c @@ -8,13 +8,14 @@ // RUN: %clang %s -o - -emit-llvm -S -fprofile-instr-generate | FileCheck -check-prefix=PGOGEN %s // RUN: %clang %s -o - -emit-llvm -S -fprofile-instr-use=%S/Inputs/instr-profile.pgodata | FileCheck -check-prefix=PGOUSE %s -// PGOGEN: @[[SLC:__llvm_pgo_ctr[0-9]*]] = private global [10 x i64] zeroinitializer -// PGOGEN: @[[IFC:__llvm_pgo_ctr[0-9]*]] = private global [13 x i64] zeroinitializer -// PGOGEN: @[[EEC:__llvm_pgo_ctr[0-9]*]] = private global [13 x i64] zeroinitializer -// PGOGEN: @[[JMC:__llvm_pgo_ctr[0-9]*]] = private global [30 x i64] zeroinitializer -// PGOGEN: @[[SWC:__llvm_pgo_ctr[0-9]*]] = private global [21 x i64] zeroinitializer -// PGOGEN: @[[BSC:__llvm_pgo_ctr[0-9]*]] = private global [19 x i64] zeroinitializer -// PGOGEN: @[[BOC:__llvm_pgo_ctr[0-9]*]] = private global [10 x i64] zeroinitializer +// PGOGEN: @[[SLC:__llvm_pgo_ctr[0-9]*]] = private global [4 x i64] zeroinitializer +// PGOGEN: @[[IFC:__llvm_pgo_ctr[0-9]*]] = private global [11 x i64] zeroinitializer +// PGOGEN: @[[EEC:__llvm_pgo_ctr[0-9]*]] = private global [9 x i64] zeroinitializer +// PGOGEN: @[[JMC:__llvm_pgo_ctr[0-9]*]] = private global [22 x i64] zeroinitializer +// PGOGEN: @[[SWC:__llvm_pgo_ctr[0-9]*]] = private global [19 x i64] zeroinitializer +// PGOGEN: @[[BSC:__llvm_pgo_ctr[0-9]*]] = private global [17 x i64] zeroinitializer +// PGOGEN: @[[BOC:__llvm_pgo_ctr[0-9]*]] = private global [8 x i64] zeroinitializer +// PGOGEN: @[[BLC:__llvm_pgo_ctr[0-9]*]] = private global [9 x i64] zeroinitializer // PGOGEN: @[[NOC:__llvm_pgo_ctr[0-9]*]] = private global [2 x i64] zeroinitializer // PGOGEN: @[[MAC:__llvm_pgo_ctr[0-9]*]] = private global [1 x i64] zeroinitializer @@ -27,11 +28,11 @@ void simple_loops() { // PGOUSE: br {{.*}} !prof ![[SL1:[0-9]+]] for (i = 0; i < 100; ++i) { } - // PGOGEN: store {{.*}} @[[SLC]], i64 0, i64 4 + // PGOGEN: store {{.*}} @[[SLC]], i64 0, i64 2 // PGOUSE: br {{.*}} !prof ![[SL2:[0-9]+]] while (i > 0) i--; - // PGOGEN: store {{.*}} @[[SLC]], i64 0, i64 7 + // PGOGEN: store {{.*}} @[[SLC]], i64 0, i64 3 // PGOUSE: br {{.*}} !prof ![[SL3:[0-9]+]] do {} while (i++ < 75); @@ -46,30 +47,30 @@ void conditionals() { // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 1 // PGOUSE: br {{.*}} !prof ![[IF1:[0-9]+]] for (int i = 0; i < 100; ++i) { - // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 4 + // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 2 // PGOUSE: br {{.*}} !prof ![[IF2:[0-9]+]] if (i % 2) { - // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 5 + // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 3 // PGOUSE: br {{.*}} !prof ![[IF3:[0-9]+]] if (i) {} - // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 6 + // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 4 // PGOUSE: br {{.*}} !prof ![[IF4:[0-9]+]] } else if (i % 3) { - // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 7 + // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 5 // PGOUSE: br {{.*}} !prof ![[IF5:[0-9]+]] if (i) {} } else { - // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 8 + // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 6 // PGOUSE: br {{.*}} !prof ![[IF6:[0-9]+]] if (i) {} } - // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 10 - // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 9 + // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 8 + // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 7 // PGOUSE: br {{.*}} !prof ![[IF7:[0-9]+]] if (1 && i) {} - // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 12 - // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 11 + // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 10 + // PGOGEN: store {{.*}} @[[IFC]], i64 0, i64 9 // PGOUSE: br {{.*}} !prof ![[IF8:[0-9]+]] if (0 || i) {} } @@ -92,25 +93,23 @@ void early_exits() { // PGOUSE: br {{.*}} !prof ![[EE2:[0-9]+]] while (i < 100) { i++; - // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 5 + // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 3 // PGOUSE: br {{.*}} !prof ![[EE3:[0-9]+]] if (i > 50) - // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 3 break; - // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 6 + // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 4 // PGOUSE: br {{.*}} !prof ![[EE4:[0-9]+]] if (i % 2) - // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 4 continue; } - // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 7 + // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 5 // PGOUSE: br {{.*}} !prof ![[EE5:[0-9]+]] if (i) {} - // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 8 + // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 6 do { - // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 11 + // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 7 // PGOUSE: br {{.*}} !prof ![[EE6:[0-9]+]] if (i > 75) return; @@ -119,7 +118,7 @@ void early_exits() { // PGOUSE: br {{.*}} !prof ![[EE7:[0-9]+]] } while (i < 100); - // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 12 + // PGOGEN: store {{.*}} @[[EEC]], i64 0, i64 8 // Never reached -> no weights if (i) {} @@ -140,67 +139,67 @@ void jumps() { // Never reached -> no weights if (i) {} } -// PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 5 +// PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 3 outofloop: - // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 6 + // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 4 // PGOUSE: br {{.*}} !prof ![[JM2:[0-9]+]] if (i) {} goto loop1; - // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 7 + // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 5 // PGOUSE: br {{.*}} !prof ![[JM3:[0-9]+]] while (i) { - // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 10 + // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 6 loop1: - // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 11 + // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 7 // PGOUSE: br {{.*}} !prof ![[JM4:[0-9]+]] if (i) {} } goto loop2; -// PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 12 +// PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 8 first: -// PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 13 +// PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 9 second: -// PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 14 +// PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 10 third: i++; - // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 15 + // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 11 // PGOUSE: br {{.*}} !prof ![[JM5:[0-9]+]] if (i < 3) goto loop2; - // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 16 + // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 12 // PGOUSE: br {{.*}} !prof ![[JM6:[0-9]+]] while (i < 3) { - // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 19 + // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 13 loop2: // PGOUSE: switch {{.*}} [ // PGOUSE: ], !prof ![[JM7:[0-9]+]] switch (i) { - // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 21 + // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 15 case 0: goto first; - // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 22 + // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 16 case 1: goto second; - // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 23 + // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 17 case 2: goto third; } - // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 20 + // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 14 } - // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 24 + // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 18 // PGOUSE: br {{.*}} !prof ![[JM8:[0-9]+]] for (i = 0; i < 10; ++i) { goto withinloop; // never reached -> no weights if (i) {} - // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 28 + // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 20 withinloop: - // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 29 + // PGOGEN: store {{.*}} @[[JMC]], i64 0, i64 21 // PGOUSE: br {{.*}} !prof ![[JM9:[0-9]+]] if (i) {} } @@ -229,52 +228,52 @@ void switches() { // PGOUSE: switch {{.*}} [ // PGOUSE: ], !prof ![[SW2:[0-9]+]] switch (i[weights]) { - // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 7 + // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 5 case 1: - // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 8 + // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 6 // PGOUSE: br {{.*}} !prof ![[SW3:[0-9]+]] if (i) {} // fallthrough - // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 9 + // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 7 case 2: - // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 10 + // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 8 // PGOUSE: br {{.*}} !prof ![[SW4:[0-9]+]] if (i) {} break; - // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 11 + // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 9 case 3: - // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 12 + // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 10 // PGOUSE: br {{.*}} !prof ![[SW5:[0-9]+]] if (i) {} continue; - // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 13 + // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 11 case 4: - // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 14 + // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 12 // PGOUSE: br {{.*}} !prof ![[SW6:[0-9]+]] if (i) {} // PGOUSE: switch {{.*}} [ // PGOUSE: ], !prof ![[SW7:[0-9]+]] switch (i) { - // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 16 + // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 14 case 6 ... 9: - // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 17 + // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 15 // PGOUSE: br {{.*}} !prof ![[SW8:[0-9]+]] if (i) {} continue; } - // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 15 + // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 13 - // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 18 + // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 16 default: - // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 19 + // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 17 // PGOUSE: br {{.*}} !prof ![[SW9:[0-9]+]] if (i == len - 1) return; } - // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 6 + // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 4 } - // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 20 + // PGOGEN: store {{.*}} @[[SWC]], i64 0, i64 18 // Never reached -> no weights if (weights[0]) {} @@ -292,56 +291,56 @@ void big_switch() { // PGOUSE: switch {{.*}} [ // PGOUSE: ], !prof ![[BS2:[0-9]+]] switch (1 << i) { - // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 5 + // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 3 case (1 << 0): - // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 6 + // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 4 // PGOUSE: br {{.*}} !prof ![[BS3:[0-9]+]] if (i) {} // fallthrough - // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 7 + // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 5 case (1 << 1): - // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 8 + // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 6 // PGOUSE: br {{.*}} !prof ![[BS4:[0-9]+]] if (i) {} break; - // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 9 + // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 7 case (1 << 2) ... (1 << 12): - // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 10 + // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 8 // PGOUSE: br {{.*}} !prof ![[BS5:[0-9]+]] if (i) {} break; // The branch for the large case range above appears after the case body // PGOUSE: br {{.*}} !prof ![[BS6:[0-9]+]] - // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 11 + // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 9 case (1 << 13): - // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 12 + // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 10 // PGOUSE: br {{.*}} !prof ![[BS7:[0-9]+]] if (i) {} break; - // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 13 + // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 11 case (1 << 14) ... (1 << 28): - // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 14 + // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 12 // PGOUSE: br {{.*}} !prof ![[BS8:[0-9]+]] if (i) {} break; // The branch for the large case range above appears after the case body // PGOUSE: br {{.*}} !prof ![[BS9:[0-9]+]] - // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 15 + // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 13 case (1 << 29) ... ((1 << 29) + 1): - // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 16 + // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 14 // PGOUSE: br {{.*}} !prof ![[BS10:[0-9]+]] if (i) {} break; - // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 17 + // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 15 default: - // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 18 + // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 16 // PGOUSE: br {{.*}} !prof ![[BS11:[0-9]+]] if (i) {} break; } - // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 4 + // PGOGEN: store {{.*}} @[[BSC]], i64 0, i64 2 } // PGOGEN-NOT: store {{.*}} @[[BSC]], @@ -357,28 +356,64 @@ void boolean_operators() { // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 1 // PGOUSE: br {{.*}} !prof ![[BO1:[0-9]+]] for (int i = 0; i < 100; ++i) { - // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 4 + // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 2 // PGOUSE: br {{.*}} !prof ![[BO2:[0-9]+]] v = i % 3 || i; - // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 5 + // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 3 // PGOUSE: br {{.*}} !prof ![[BO3:[0-9]+]] v = i % 3 && i; - // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 7 - // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 6 + // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 5 + // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 4 // PGOUSE: br {{.*}} !prof ![[BO4:[0-9]+]] // PGOUSE: br {{.*}} !prof ![[BO5:[0-9]+]] v = i % 3 || i % 2 || i; - // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 9 - // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 8 + // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 7 + // PGOGEN: store {{.*}} @[[BOC]], i64 0, i64 6 // PGOUSE: br {{.*}} !prof ![[BO6:[0-9]+]] // PGOUSE: br {{.*}} !prof ![[BO7:[0-9]+]] v = i % 2 && i % 3 && i; } - // PGOGEN-NOT: store {{.*}} @[BOC]], + // PGOGEN-NOT: store {{.*}} @[[BOC]], + // PGOUSE-NOT: br {{.*}} !prof ![0-9]+ +} + +// PGOGEN-LABEL: @boolop_loops() +// PGOUSE-LABEL: @boolop_loops() +// PGOGEN: store {{.*}} @[[BLC]], i64 0, i64 0 +void boolop_loops() { + int i = 100; + + // PGOGEN: store {{.*}} @[[BLC]], i64 0, i64 2 + // PGOGEN: store {{.*}} @[[BLC]], i64 0, i64 1 + // PGOUSE: br {{.*}} !prof ![[BL1:[0-9]+]] + // PGOUSE: br {{.*}} !prof ![[BL2:[0-9]+]] + while (i && i > 50) + i--; + + // PGOGEN: store {{.*}} @[[BLC]], i64 0, i64 4 + // PGOGEN: store {{.*}} @[[BLC]], i64 0, i64 3 + // PGOUSE: br {{.*}} !prof ![[BL3:[0-9]+]] + // PGOUSE: br {{.*}} !prof ![[BL4:[0-9]+]] + while ((i % 2) || (i > 0)) + i--; + + // PGOGEN: store {{.*}} @[[BLC]], i64 0, i64 6 + // PGOGEN: store {{.*}} @[[BLC]], i64 0, i64 5 + // PGOUSE: br {{.*}} !prof ![[BL5:[0-9]+]] + // PGOUSE: br {{.*}} !prof ![[BL6:[0-9]+]] + for (i = 100; i && i > 50; --i); + + // PGOGEN: store {{.*}} @[[BLC]], i64 0, i64 8 + // PGOGEN: store {{.*}} @[[BLC]], i64 0, i64 7 + // PGOUSE: br {{.*}} !prof ![[BL7:[0-9]+]] + // PGOUSE: br {{.*}} !prof ![[BL8:[0-9]+]] + for (; (i % 2) || (i > 0); --i); + + // PGOGEN-NOT: store {{.*}} @[[BLC]], // PGOUSE-NOT: br {{.*}} !prof ![0-9]+ } @@ -457,7 +492,14 @@ void no_usable_data() { // PGOUSE-DAG: ![[BO5]] = metadata !{metadata !"branch_weights", i32 18, i32 18} // PGOUSE-DAG: ![[BO6]] = metadata !{metadata !"branch_weights", i32 51, i32 51} // PGOUSE-DAG: ![[BO7]] = metadata !{metadata !"branch_weights", i32 34, i32 18} - +// PGOUSE-DAG: ![[BL1]] = metadata !{metadata !"branch_weights", i32 52, i32 1} +// PGOUSE-DAG: ![[BL2]] = metadata !{metadata !"branch_weights", i32 51, i32 2} +// PGOUSE-DAG: ![[BL3]] = metadata !{metadata !"branch_weights", i32 26, i32 27} +// PGOUSE-DAG: ![[BL4]] = metadata !{metadata !"branch_weights", i32 51, i32 2} +// PGOUSE-DAG: ![[BL5]] = metadata !{metadata !"branch_weights", i32 52, i32 1} +// PGOUSE-DAG: ![[BL6]] = metadata !{metadata !"branch_weights", i32 51, i32 2} +// PGOUSE-DAG: ![[BL7]] = metadata !{metadata !"branch_weights", i32 26, i32 27} +// PGOUSE-DAG: ![[BL8]] = metadata !{metadata !"branch_weights", i32 51, i32 2} int main(int argc, const char *argv[]) { simple_loops(); @@ -467,6 +509,7 @@ int main(int argc, const char *argv[]) { switches(); big_switch(); boolean_operators(); + boolop_loops(); no_usable_data(); return 0; } |

