Skip to content

Commit

Permalink
[AMDGPU] clang-tidy: use emplace_back instead of push_back. NFC.
Browse files Browse the repository at this point in the history
  • Loading branch information
jayfoad committed Jul 17, 2024
1 parent d3dab0c commit 5e338f1
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 38 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ void AMDGPUAsmPrinter::emitFunctionEntryLabel() {
// Disassemble function name label to text.
DisasmLines.push_back(MF->getName().str() + ":");
DisasmLineMaxLen = std::max(DisasmLineMaxLen, DisasmLines.back().size());
HexLines.push_back("");
HexLines.emplace_back("");
}

AsmPrinter::emitFunctionEntryLabel();
Expand All @@ -298,7 +298,7 @@ void AMDGPUAsmPrinter::emitBasicBlockStart(const MachineBasicBlock &MBB) {
(Twine("BB") + Twine(getFunctionNumber())
+ "_" + Twine(MBB.getNumber()) + ":").str());
DisasmLineMaxLen = std::max(DisasmLineMaxLen, DisasmLines.back().size());
HexLines.push_back("");
HexLines.emplace_back("");
}
AsmPrinter::emitBasicBlockStart(MBB);
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2466,7 +2466,7 @@ int SchedGroup::link(SUnit &SU, bool MakePred,
// the A->B edge impossible, otherwise it returns true;
bool Added = tryAddEdge(A, B);
if (Added)
AddedEdges.push_back(std::pair(A, B));
AddedEdges.emplace_back(A, B);
else
++MissedEdges;
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ doPartitioning(SplitModuleLogger &SML, Module &M, unsigned NumParts,
// partitions) so it's a cheap operation.
std::vector<std::pair<PartitionID, CostType>> BalancingQueue;
for (unsigned I = 0; I < NumParts; ++I)
BalancingQueue.push_back(std::make_pair(I, 0));
BalancingQueue.emplace_back(I, 0);

// Helper function to handle assigning a function to a partition. This takes
// care of updating the balancing queue.
Expand Down
14 changes: 7 additions & 7 deletions llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ BasicBlock *AMDGPUUnifyDivergentExitNodesImpl::unifyReturnBlockSet(
// Remove and delete the return inst.
BB->getTerminator()->eraseFromParent();
BranchInst::Create(NewRetBlock, BB);
Updates.push_back({DominatorTree::Insert, BB, NewRetBlock});
Updates.emplace_back(DominatorTree::Insert, BB, NewRetBlock);
}

if (RequireAndPreserveDomTree)
Expand Down Expand Up @@ -239,7 +239,7 @@ bool AMDGPUUnifyDivergentExitNodesImpl::run(Function &F, DominatorTree *DT,
BI->eraseFromParent(); // Delete the unconditional branch.
// Add a new conditional branch with a dummy edge to the return block.
BranchInst::Create(LoopHeaderBB, DummyReturnBB, BoolTrue, BB);
Updates.push_back({DominatorTree::Insert, BB, DummyReturnBB});
Updates.emplace_back(DominatorTree::Insert, BB, DummyReturnBB);
} else { // Conditional branch.
SmallVector<BasicBlock *, 2> Successors(successors(BB));

Expand All @@ -250,17 +250,17 @@ bool AMDGPUUnifyDivergentExitNodesImpl::run(Function &F, DominatorTree *DT,

// 'Successors' become successors of TransitionBB instead of BB,
// and TransitionBB becomes a single successor of BB.
Updates.push_back({DominatorTree::Insert, BB, TransitionBB});
Updates.emplace_back(DominatorTree::Insert, BB, TransitionBB);
for (BasicBlock *Successor : Successors) {
Updates.push_back({DominatorTree::Insert, TransitionBB, Successor});
Updates.push_back({DominatorTree::Delete, BB, Successor});
Updates.emplace_back(DominatorTree::Insert, TransitionBB, Successor);
Updates.emplace_back(DominatorTree::Delete, BB, Successor);
}

// Create a branch that will always branch to the transition block and
// references DummyReturnBB.
BB->getTerminator()->eraseFromParent();
BranchInst::Create(TransitionBB, DummyReturnBB, BoolTrue, BB);
Updates.push_back({DominatorTree::Insert, BB, DummyReturnBB});
Updates.emplace_back(DominatorTree::Insert, BB, DummyReturnBB);
}
Changed = true;
}
Expand All @@ -281,7 +281,7 @@ bool AMDGPUUnifyDivergentExitNodesImpl::run(Function &F, DominatorTree *DT,
// Remove and delete the unreachable inst.
BB->getTerminator()->eraseFromParent();
BranchInst::Create(UnreachableBlock, BB);
Updates.push_back({DominatorTree::Insert, BB, UnreachableBlock});
Updates.emplace_back(DominatorTree::Insert, BB, UnreachableBlock);
}
Changed = true;
}
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Target/AMDGPU/R600EmitClauseMarkers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,20 @@ class R600EmitClauseMarkers : public MachineFunctionPass {
const std::pair<unsigned, unsigned> &BankLine = getAccessedBankLine(Sel);
if (CachedConsts.empty()) {
CachedConsts.push_back(BankLine);
UsedKCache.push_back(std::pair<unsigned, unsigned>(0, KCacheIndex));
UsedKCache.emplace_back(0, KCacheIndex);
continue;
}
if (CachedConsts[0] == BankLine) {
UsedKCache.push_back(std::pair<unsigned, unsigned>(0, KCacheIndex));
UsedKCache.emplace_back(0, KCacheIndex);
continue;
}
if (CachedConsts.size() == 1) {
CachedConsts.push_back(BankLine);
UsedKCache.push_back(std::pair<unsigned, unsigned>(1, KCacheIndex));
UsedKCache.emplace_back(1, KCacheIndex);
continue;
}
if (CachedConsts[1] == BankLine) {
UsedKCache.push_back(std::pair<unsigned, unsigned>(1, KCacheIndex));
UsedKCache.emplace_back(1, KCacheIndex);
continue;
}
return false;
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Target/AMDGPU/R600InstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,11 @@ R600InstrInfo::ExtractSrcs(MachineInstr &MI,
Register Reg = Src.first->getReg();
int Index = RI.getEncodingValue(Reg) & 0xff;
if (Reg == R600::OQAP) {
Result.push_back(std::pair(Index, 0U));
Result.emplace_back(Index, 0U);
}
if (PV.contains(Reg)) {
// 255 is used to tells its a PS/PV reg
Result.push_back(std::pair(255, 0U));
Result.emplace_back(255, 0U);
continue;
}
if (Index > 127) {
Expand All @@ -339,7 +339,7 @@ R600InstrInfo::ExtractSrcs(MachineInstr &MI,
continue;
}
unsigned Chan = RI.getHWRegChan(Reg);
Result.push_back(std::pair(Index, Chan));
Result.emplace_back(Index, Chan);
}
for (; i < 3; ++i)
Result.push_back(DummyPair);
Expand Down
8 changes: 3 additions & 5 deletions llvm/lib/Target/AMDGPU/R600OptimizeVectorRegisters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class RegSeqInfo {
MachineOperand &MO = Instr->getOperand(i);
unsigned Chan = Instr->getOperand(i + 1).getImm();
if (isImplicitlyDef(MRI, MO.getReg()))
UndefReg.push_back(Chan);
UndefReg.emplace_back(Chan);
else
RegToChan[MO.getReg()] = Chan;
}
Expand Down Expand Up @@ -154,14 +154,12 @@ bool R600VectorRegMerger::tryMergeVector(const RegSeqInfo *Untouched,
DenseMap<Register, unsigned>::const_iterator PosInUntouched =
Untouched->RegToChan.find(It.first);
if (PosInUntouched != Untouched->RegToChan.end()) {
Remap.push_back(
std::pair<unsigned, unsigned>(It.second, (*PosInUntouched).second));
Remap.emplace_back(It.second, (*PosInUntouched).second);
continue;
}
if (CurrentUndexIdx >= Untouched->UndefReg.size())
return false;
Remap.push_back(std::pair<unsigned, unsigned>(
It.second, Untouched->UndefReg[CurrentUndexIdx++]));
Remap.emplace_back(It.second, Untouched->UndefReg[CurrentUndexIdx++]);
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/SILowerSGPRSpills.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ bool SILowerSGPRSpills::spillCalleeSavedRegs(
int JunkFI = MFI.CreateStackObject(TRI->getSpillSize(*RC),
TRI->getSpillAlign(*RC), true);

CSI.push_back(CalleeSavedInfo(Reg, JunkFI));
CSI.emplace_back(Reg, JunkFI);
CalleeSavedFIs.push_back(JunkFI);
}
}
Expand Down
6 changes: 2 additions & 4 deletions llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,7 @@ bool SIMachineFunctionInfo::allocateVirtualVGPRForSGPRSpills(
LaneVGPR = SpillVGPRs.back();
}

SGPRSpillsToVirtualVGPRLanes[FI].push_back(
SIRegisterInfo::SpilledReg(LaneVGPR, LaneIndex));
SGPRSpillsToVirtualVGPRLanes[FI].emplace_back(LaneVGPR, LaneIndex);
return true;
}

Expand Down Expand Up @@ -393,8 +392,7 @@ bool SIMachineFunctionInfo::allocatePhysicalVGPRForSGPRSpills(
LaneVGPR = SpillPhysVGPRs.back();
}

SGPRSpillsToPhysicalVGPRLanes[FI].push_back(
SIRegisterInfo::SpilledReg(LaneVGPR, LaneIndex));
SGPRSpillsToPhysicalVGPRLanes[FI].emplace_back(LaneVGPR, LaneIndex);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/SIMachineScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ void SIScheduleBlock::addSucc(SIScheduleBlock *Succ,
}
if (Succ->isHighLatencyBlock())
++NumHighLatencySuccessors;
Succs.push_back(std::pair(Succ, Kind));
Succs.emplace_back(Succ, Kind);

assert(none_of(Preds,
[=](SIScheduleBlock *P) { return SuccID == P->getID(); }) &&
Expand Down
16 changes: 8 additions & 8 deletions llvm/lib/Target/AMDGPU/SIWholeQuadMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ void SIWholeQuadMode::markInstruction(MachineInstr &MI, char Flag,

LLVM_DEBUG(dbgs() << "markInstruction " << PrintState(Flag) << ": " << MI);
II.Needs |= Flag;
Worklist.push_back(&MI);
Worklist.emplace_back(&MI);
}

/// Mark all relevant definitions of register \p Reg in usage \p UseMI.
Expand Down Expand Up @@ -539,7 +539,7 @@ char SIWholeQuadMode::scanInstructions(MachineFunction &MF,
BBI.Needs |= StateExact;
if (!(BBI.InNeeds & StateExact)) {
BBI.InNeeds |= StateExact;
Worklist.push_back(MBB);
Worklist.emplace_back(MBB);
}
GlobalFlags |= StateExact;
III.Disabled = StateWQM | StateStrict;
Expand Down Expand Up @@ -568,7 +568,7 @@ char SIWholeQuadMode::scanInstructions(MachineFunction &MF,
BBI.Needs |= StateExact;
if (!(BBI.InNeeds & StateExact)) {
BBI.InNeeds |= StateExact;
Worklist.push_back(MBB);
Worklist.emplace_back(MBB);
}
GlobalFlags |= StateExact;
III.Disabled = StateWQM | StateStrict;
Expand Down Expand Up @@ -638,7 +638,7 @@ void SIWholeQuadMode::propagateInstruction(MachineInstr &MI,
BI.Needs |= StateWQM;
if (!(BI.InNeeds & StateWQM)) {
BI.InNeeds |= StateWQM;
Worklist.push_back(MBB);
Worklist.emplace_back(MBB);
}
}

Expand All @@ -649,7 +649,7 @@ void SIWholeQuadMode::propagateInstruction(MachineInstr &MI,
InstrInfo &PrevII = Instructions[PrevMI];
if ((PrevII.OutNeeds | InNeeds) != PrevII.OutNeeds) {
PrevII.OutNeeds |= InNeeds;
Worklist.push_back(PrevMI);
Worklist.emplace_back(PrevMI);
}
}
}
Expand Down Expand Up @@ -678,7 +678,7 @@ void SIWholeQuadMode::propagateBlock(MachineBasicBlock &MBB,
InstrInfo &LastII = Instructions[LastMI];
if ((LastII.OutNeeds | BI.OutNeeds) != LastII.OutNeeds) {
LastII.OutNeeds |= BI.OutNeeds;
Worklist.push_back(LastMI);
Worklist.emplace_back(LastMI);
}
}

Expand All @@ -690,7 +690,7 @@ void SIWholeQuadMode::propagateBlock(MachineBasicBlock &MBB,

PredBI.OutNeeds |= BI.InNeeds;
PredBI.InNeeds |= BI.InNeeds;
Worklist.push_back(Pred);
Worklist.emplace_back(Pred);
}

// All successors must be prepared to accept the same set of WQM/Exact data.
Expand All @@ -700,7 +700,7 @@ void SIWholeQuadMode::propagateBlock(MachineBasicBlock &MBB,
continue;

SuccBI.InNeeds |= BI.OutNeeds;
Worklist.push_back(Succ);
Worklist.emplace_back(Succ);
}
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/Utils/AMDGPUDelayedMCExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void DelayedMCExprs::assignDocNode(msgpack::DocNode &DN, msgpack::Type Type,
}
}

DelayedExprs.push_back(Expr{DN, Type, ExprValue});
DelayedExprs.emplace_back(DN, Type, ExprValue);
}

bool DelayedMCExprs::resolveDelayedExpressions() {
Expand Down

0 comments on commit 5e338f1

Please sign in to comment.