gen: Keep case/default body IR blocks in lexical order [nfc]

This makes the IR slightly easier to read, in particular the
PGO lit tests.
This commit is contained in:
David Nadlinger 2016-08-02 19:56:59 +01:00
parent 8fbb0ddbfa
commit 9d5bf5a707
3 changed files with 10 additions and 22 deletions

View file

@ -1365,6 +1365,7 @@ public:
PGO.setCurrentStmt(stmt);
const auto body = funcGen.switchTargets.getOrCreate(stmt, "case");
body->moveAfter(irs->scopebb());
if (!irs->scopereturned()) {
llvm::BranchInst::Create(body, irs->scopebb());
@ -1393,6 +1394,7 @@ public:
PGO.setCurrentStmt(stmt);
const auto body = funcGen.switchTargets.getOrCreate(stmt, "default");
body->moveAfter(irs->scopebb());
if (!irs->scopereturned()) {
llvm::BranchInst::Create(body, irs->scopebb());

View file

@ -172,12 +172,6 @@ void c_switches() {
// PROFUSE: switch {{.*}} [
// PROFUSE: ], !prof ![[SW2:[0-9]+]]
switch (weights[i]) {
// default counter:
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 20
// default body (codegen'd out-of-order):
// PROFUSE: br {{.*}} !prof ![[SW9:[0-9]+]]
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 5
case 1:
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 6
@ -204,9 +198,6 @@ void c_switches() {
// PROFUSE: switch {{.*}} [
// PROFUSE: ], !prof ![[SW7:[0-9]+]]
switch (i) {
// default counter:
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 19
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 14
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 15
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 16
@ -216,12 +207,15 @@ void c_switches() {
// PROFUSE: br {{.*}} !prof ![[SW8:[0-9]+]]
if (i) {}
continue;
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 19
default:
}
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 13
// fallthrough
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 20
default:
// PROFUSE: br {{.*}} !prof ![[SW9:[0-9]+]]
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 21
if (i == weights.length - 1)
return;
@ -252,12 +246,6 @@ void d_switches() {
// PROFUSE: switch {{.*}} [
// PROFUSE: ], !prof ![[DSW2:[0-9]+]]
switch (i) {
// default counter:
// PROFGEN: store {{.*}} @[[DSW]], i64 0, i64 10
// default: (codegen'd out-of-order), 2x (gototarget)
// PROFGEN: store {{.*}} @[[DSW]], i64 0, i64 11
// PROFGEN: store {{.*}} @[[DSW]], i64 0, i64 3
case 1: // 2x (gototarget)
// PROFGEN: store {{.*}} @[[DSW]], i64 0, i64 4
@ -280,7 +268,9 @@ void d_switches() {
if (i != 2) {}
goto case 1;
// PROFGEN: store {{.*}} @[[DSW]], i64 0, i64 10
default:
// PROFGEN: store {{.*}} @[[DSW]], i64 0, i64 11
// fall through
// PROFGEN: store {{.*}} @[[DSW]], i64 0, i64 12

View file

@ -24,12 +24,6 @@ void bunch_of_branches() {
for (i = 1; i < 4; ++i) {
switch (i) {
// default counter:
// PROFGEN: store {{.*}} @[[BoB]], i64 0, i64 10
// default: (codegen'd out-of-order, 1 + 1*gototarget)
// PROFGEN: store {{.*}} @[[BoB]], i64 0, i64 11
// PROFGEN: store {{.*}} @[[BoB]], i64 0, i64 3
case 1: // 1 + 1*gototarget
// PROFGEN: store {{.*}} @[[BoB]], i64 0, i64 4
@ -54,7 +48,9 @@ void bunch_of_branches() {
if (i != 2) {}
goto case 1;
default:
// PROFGEN: store {{.*}} @[[BoB]], i64 0, i64 10
default: // 1 + 1*gototarget
// PROFGEN: store {{.*}} @[[BoB]], i64 0, i64 11
// fall through
// PROFGEN: store {{.*}} @[[BoB]], i64 0, i64 12