Skip to content

Commit 6fbca28

Browse files
smilczekigcbot
authored andcommitted
Minor fixes and refactors.
Add std::move if it's at the end of variable's scope. Small refactor + typo fix in tryPrintLabel labmda. Replace `construct -> push_back` pattern with emplace_back. Change arg to const ref where makes sense.
1 parent f728b0f commit 6fbca28

File tree

6 files changed

+10
-13
lines changed

6 files changed

+10
-13
lines changed

visa/DebugInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,8 +2044,7 @@ INST_LIST KernelDebugInfo::getDeltaInstructions(G4_BB *bb) {
20442044

20452045
void SaveRestoreManager::addInst(G4_INST *inst) {
20462046
const IR_Builder &builder = inst->getBuilder();
2047-
SaveRestoreInfo newSVInfo = {};
2048-
srInfo.push_back(newSVInfo);
2047+
srInfo.emplace_back();
20492048
if (srInfo.size() > 1) {
20502049
// Copy over from previous
20512050
// so emitted data is

visa/G4_Kernel.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,16 +1888,14 @@ void G4_Kernel::emitDeviceAsmInstructionsIga(std::ostream &os,
18881888
// there's an empty BB contains only labels. The BB and the following BB will
18891889
// both print those labels. The pair is the pc to label name pair.
18901890
std::set<std::pair<int32_t, std::string>> printedLabels;
1891-
// tryPrintLable - check if the given label is already printed with the given
1891+
// tryPrintLabel - check if the given label is already printed with the given
18921892
// pc. Print it if not, and skip it if yes.
18931893
auto tryPrintLabel = [&os, &printedLabels](int32_t label_pc,
18941894
const std::string &label_name) {
1895-
auto label_pair = std::make_pair(label_pc, label_name);
1896-
// skip if the same label in the set
1897-
if (printedLabels.find(label_pair) != printedLabels.end())
1898-
return;
1899-
os << label_name << ":\n";
1900-
printedLabels.insert(label_pair);
1895+
auto [iter, inserted] = printedLabels.emplace(label_pc, label_name);
1896+
// print if the label is new in the set.
1897+
if (inserted)
1898+
os << label_name << ":\n";
19011899
};
19021900

19031901
for (BB_LIST_ITER itBB = fg.begin(); itBB != fg.end(); ++itBB) {

visa/MetadataDumpRA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void MetadataDumpRA::addKernelMD(G4_Kernel* kernel) {
113113
}
114114

115115
// add this instruction metadata to the kernel's metadata
116-
kernelMD.instMetadatas.push_back(instMD);
116+
kernelMD.instMetadatas.push_back(std::move(instMD));
117117
kernelMD.numInsts += 1;
118118

119119
}

visa/SCCAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void SCCAnalysis::findSCC(SCCNode *node) {
9393
bodyNode->isOnStack = false;
9494
newSCC.addBB(bodyNode->bb);
9595
} while (bodyNode != node);
96-
SCCs.push_back(newSCC);
96+
SCCs.push_back(std::move(newSCC));
9797
}
9898
} // findSCC
9999

visa/iga/IGALibrary/Frontend/Formatter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,7 @@ bool Formatter::formatLoadStoreSyntax(const Instruction &i) {
13831383

13841384
formatMaskAndPredication(i);
13851385

1386-
const auto syntax = di.syntax;
1386+
const auto &syntax = di.syntax;
13871387
startColumn(cols.opCodeExecInfo + 12);
13881388
emit(' ');
13891389
emit(ANSI_MNEMONIC);

visa/iga/IGALibrary/IR/InstBuilder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ class InstBuilder {
411411
inst->setLabelSource(opIx, 0, src.type);
412412
UnresolvedLabel u{src.loc, src.immLabel, inst->getSource(opIx),
413413
*inst};
414-
m_unresolvedLabels.push_back(u);
414+
m_unresolvedLabels.push_back(std::move(u));
415415
}
416416
} else if (src.kind == Operand::Kind::IMMEDIATE) {
417417
inst->setImmediateSource(opIx, src.immValue, src.type);

0 commit comments

Comments
 (0)