Skip to content

Commit 140dada

Browse files
jgu222igcbot
authored andcommitted
More on normalizing label creation
Convert some createLabel() to createLocalBlockLabel()
1 parent 226f071 commit 140dada

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

visa/BuildIR.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,13 +1157,19 @@ class IR_Builder
11571157
//
11581158
G4_Label* createLocalBlockLabel(const std::string& lab = "")
11591159
{
1160-
std::stringstream ss;
1161-
std::string kname(kernel.getName() ? kernel.getName() : "L");
1162-
if (kname.size() > 30)
1160+
const char* cstr_kname = kernel.getName();
1161+
std::string kname("L");
1162+
if (cstr_kname)
11631163
{
1164-
// kname is just for readability. If it is too long, don't use it.
1165-
kname = "L";
1164+
std::string tName = sanitizeLabelString(cstr_kname);
1165+
// cstr_kname is just for readability. If it is too long, don't use it.
1166+
if (tName.size() != 0 && tName.size() <= 30)
1167+
{
1168+
kname = tName;
1169+
}
11661170
}
1171+
1172+
std::stringstream ss;
11671173
uint32_t lbl_id = getAndUpdateNextLabelId();
11681174
ss << "_" << kname << "_f" << kernel.getFunctionId() << "_" << lbl_id << "_" << lab;
11691175
size_t len = ss.str().size() + 1;

visa/CFGStructurizer.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2934,9 +2934,7 @@ G4_BB *CFGStructurizer::createBBWithLabel()
29342934
G4_BB *newBB = CFG->createNewBB();
29352935

29362936
// Create a label for the new BB
2937-
std::string str = sanitizeLabelString(CFG->builder->kernel.getName()) +
2938-
"_cf_" + std::to_string(newBB->getId());
2939-
G4_Label* lab = CFG->builder->createLabel(str, LABEL_BLOCK);
2937+
G4_Label* lab = CFG->builder->createLocalBlockLabel("cf");
29402938
G4_INST *labelInst = CFG->builder->createLabelInst(lab, false);
29412939
newBB->push_front(labelInst);
29422940
return newBB;

visa/FlowGraph.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,8 +1209,7 @@ void FlowGraph::handleExit(G4_BB* firstSubroutineBB)
12091209
insert(iter, exitBB);
12101210
}
12111211

1212-
std::string exitBBStr("__EXIT_BB");
1213-
G4_Label *exitLabel = builder->createLabel(exitBBStr, LABEL_BLOCK);
1212+
G4_Label *exitLabel = builder->createLocalBlockLabel("EXIT_BB");
12141213
G4_INST* label = createNewLabelInst(exitLabel);
12151214
exitBB->push_back(label);
12161215

@@ -1472,8 +1471,7 @@ G4_BB* FlowGraph::mergeSubRoutineReturn(G4_Label* subroutineLabel)
14721471
//
14731472
// Create a label for the newBB and insert return to new BB
14741473
//
1475-
std::string str = "LABEL__" + std::to_string(newBB->getId());
1476-
G4_Label* lab = builder->createLabel(str, LABEL_BLOCK);
1474+
G4_Label* lab = builder->createLocalBlockLabel();
14771475
G4_INST* labelInst = createNewLabelInst(lab);
14781476

14791477
// exitBB is really just a dummy one for analysis, and does not need a return
@@ -2338,8 +2336,7 @@ void FlowGraph::mergeFReturns()
23382336
{
23392337
G4_BB* newExit = createNewBB();
23402338
assert(!builder->getIsKernel() && "Not expecting fret in kernel");
2341-
std::string str = "__MERGED_FRET_EXIT_BLOCK";
2342-
dumLabel = builder->createLabel(str, LABEL_BLOCK);
2339+
dumLabel = builder->createLocalBlockLabel("MERGED_FRET_EXIT_BB");
23432340
G4_INST* label = createNewLabelInst(dumLabel);
23442341
newExit->push_back(label);
23452342
G4_INST* fret = builder->createInternalCFInst(

0 commit comments

Comments
 (0)