mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-09 12:32:33 +03:00
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:
parent
8fbb0ddbfa
commit
9d5bf5a707
3 changed files with 10 additions and 22 deletions
|
@ -1365,6 +1365,7 @@ public:
|
||||||
PGO.setCurrentStmt(stmt);
|
PGO.setCurrentStmt(stmt);
|
||||||
|
|
||||||
const auto body = funcGen.switchTargets.getOrCreate(stmt, "case");
|
const auto body = funcGen.switchTargets.getOrCreate(stmt, "case");
|
||||||
|
body->moveAfter(irs->scopebb());
|
||||||
|
|
||||||
if (!irs->scopereturned()) {
|
if (!irs->scopereturned()) {
|
||||||
llvm::BranchInst::Create(body, irs->scopebb());
|
llvm::BranchInst::Create(body, irs->scopebb());
|
||||||
|
@ -1393,6 +1394,7 @@ public:
|
||||||
PGO.setCurrentStmt(stmt);
|
PGO.setCurrentStmt(stmt);
|
||||||
|
|
||||||
const auto body = funcGen.switchTargets.getOrCreate(stmt, "default");
|
const auto body = funcGen.switchTargets.getOrCreate(stmt, "default");
|
||||||
|
body->moveAfter(irs->scopebb());
|
||||||
|
|
||||||
if (!irs->scopereturned()) {
|
if (!irs->scopereturned()) {
|
||||||
llvm::BranchInst::Create(body, irs->scopebb());
|
llvm::BranchInst::Create(body, irs->scopebb());
|
||||||
|
|
|
@ -172,12 +172,6 @@ void c_switches() {
|
||||||
// PROFUSE: switch {{.*}} [
|
// PROFUSE: switch {{.*}} [
|
||||||
// PROFUSE: ], !prof ![[SW2:[0-9]+]]
|
// PROFUSE: ], !prof ![[SW2:[0-9]+]]
|
||||||
switch (weights[i]) {
|
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
|
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 5
|
||||||
case 1:
|
case 1:
|
||||||
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 6
|
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 6
|
||||||
|
@ -204,9 +198,6 @@ void c_switches() {
|
||||||
// PROFUSE: switch {{.*}} [
|
// PROFUSE: switch {{.*}} [
|
||||||
// PROFUSE: ], !prof ![[SW7:[0-9]+]]
|
// PROFUSE: ], !prof ![[SW7:[0-9]+]]
|
||||||
switch (i) {
|
switch (i) {
|
||||||
// default counter:
|
|
||||||
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 19
|
|
||||||
|
|
||||||
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 14
|
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 14
|
||||||
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 15
|
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 15
|
||||||
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 16
|
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 16
|
||||||
|
@ -216,12 +207,15 @@ void c_switches() {
|
||||||
// PROFUSE: br {{.*}} !prof ![[SW8:[0-9]+]]
|
// PROFUSE: br {{.*}} !prof ![[SW8:[0-9]+]]
|
||||||
if (i) {}
|
if (i) {}
|
||||||
continue;
|
continue;
|
||||||
|
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 19
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 13
|
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 13
|
||||||
// fallthrough
|
// fallthrough
|
||||||
|
|
||||||
|
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 20
|
||||||
default:
|
default:
|
||||||
|
// PROFUSE: br {{.*}} !prof ![[SW9:[0-9]+]]
|
||||||
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 21
|
// PROFGEN: store {{.*}} @[[SWC]], i64 0, i64 21
|
||||||
if (i == weights.length - 1)
|
if (i == weights.length - 1)
|
||||||
return;
|
return;
|
||||||
|
@ -252,12 +246,6 @@ void d_switches() {
|
||||||
// PROFUSE: switch {{.*}} [
|
// PROFUSE: switch {{.*}} [
|
||||||
// PROFUSE: ], !prof ![[DSW2:[0-9]+]]
|
// PROFUSE: ], !prof ![[DSW2:[0-9]+]]
|
||||||
switch (i) {
|
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
|
// PROFGEN: store {{.*}} @[[DSW]], i64 0, i64 3
|
||||||
case 1: // 2x (gototarget)
|
case 1: // 2x (gototarget)
|
||||||
// PROFGEN: store {{.*}} @[[DSW]], i64 0, i64 4
|
// PROFGEN: store {{.*}} @[[DSW]], i64 0, i64 4
|
||||||
|
@ -280,7 +268,9 @@ void d_switches() {
|
||||||
if (i != 2) {}
|
if (i != 2) {}
|
||||||
goto case 1;
|
goto case 1;
|
||||||
|
|
||||||
|
// PROFGEN: store {{.*}} @[[DSW]], i64 0, i64 10
|
||||||
default:
|
default:
|
||||||
|
// PROFGEN: store {{.*}} @[[DSW]], i64 0, i64 11
|
||||||
// fall through
|
// fall through
|
||||||
|
|
||||||
// PROFGEN: store {{.*}} @[[DSW]], i64 0, i64 12
|
// PROFGEN: store {{.*}} @[[DSW]], i64 0, i64 12
|
||||||
|
|
|
@ -24,12 +24,6 @@ void bunch_of_branches() {
|
||||||
for (i = 1; i < 4; ++i) {
|
for (i = 1; i < 4; ++i) {
|
||||||
|
|
||||||
switch (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
|
// PROFGEN: store {{.*}} @[[BoB]], i64 0, i64 3
|
||||||
case 1: // 1 + 1*gototarget
|
case 1: // 1 + 1*gototarget
|
||||||
// PROFGEN: store {{.*}} @[[BoB]], i64 0, i64 4
|
// PROFGEN: store {{.*}} @[[BoB]], i64 0, i64 4
|
||||||
|
@ -54,7 +48,9 @@ void bunch_of_branches() {
|
||||||
if (i != 2) {}
|
if (i != 2) {}
|
||||||
goto case 1;
|
goto case 1;
|
||||||
|
|
||||||
default:
|
// PROFGEN: store {{.*}} @[[BoB]], i64 0, i64 10
|
||||||
|
default: // 1 + 1*gototarget
|
||||||
|
// PROFGEN: store {{.*}} @[[BoB]], i64 0, i64 11
|
||||||
// fall through
|
// fall through
|
||||||
|
|
||||||
// PROFGEN: store {{.*}} @[[BoB]], i64 0, i64 12
|
// PROFGEN: store {{.*}} @[[BoB]], i64 0, i64 12
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue