From 05946c144dc6c383e2f4a15353baa6ea2a65517b Mon Sep 17 00:00:00 2001 From: Pavel Samolysov Date: Mon, 12 Sep 2022 15:24:09 +0300 Subject: [PATCH] [NFC][ScheduleDAG] Use structure bindings and emplace_back Some uses of std::make_pair and the std::pair's first/second members in the ScheduleDAGRRList.cpp file were replaced with using of the vector's emplace_back along with structure bindings from C++17. --- llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp index 12450b6..04a8b4d 100644 --- a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp @@ -1204,11 +1204,11 @@ SUnit *ScheduleDAGRRList::CopyAndMoveSuccessors(SUnit *SU) { D.setSUnit(NewSU); AddPredQueued(SuccSU, D); D.setSUnit(SU); - DelDeps.push_back(std::make_pair(SuccSU, D)); + DelDeps.emplace_back(SuccSU, D); } } - for (auto &DelDep : DelDeps) - RemovePred(DelDep.first, DelDep.second); + for (const auto &[DelSU, DelD] : DelDeps) + RemovePred(DelSU, DelD); AvailableQueue->updateNode(SU); AvailableQueue->addNode(NewSU); @@ -1242,17 +1242,17 @@ void ScheduleDAGRRList::InsertCopiesAndMoveSuccs(SUnit *SU, unsigned Reg, SDep D = Succ; D.setSUnit(CopyToSU); AddPredQueued(SuccSU, D); - DelDeps.push_back(std::make_pair(SuccSU, Succ)); + DelDeps.emplace_back(SuccSU, Succ); } else { - // Avoid scheduling the def-side copy before other successors. Otherwise + // Avoid scheduling the def-side copy before other successors. Otherwise, // we could introduce another physreg interference on the copy and // continue inserting copies indefinitely. AddPredQueued(SuccSU, SDep(CopyFromSU, SDep::Artificial)); } } - for (auto &DelDep : DelDeps) - RemovePred(DelDep.first, DelDep.second); + for (const auto &[DelSU, DelD] : DelDeps) + RemovePred(DelSU, DelD); SDep FromDep(SU, SDep::Data, Reg); FromDep.setLatency(SU->Latency); @@ -1484,16 +1484,15 @@ SUnit *ScheduleDAGRRList::PickNodeToScheduleBottomUp() { if (LRegs[0] == TRI->getNumRegs()) dbgs() << "CallResource"; else dbgs() << printReg(LRegs[0], TRI); dbgs() << " SU #" << CurSU->NodeNum << '\n'); - std::pair LRegsPair = - LRegsMap.insert(std::make_pair(CurSU, LRegs)); - if (LRegsPair.second) { + auto [LRegsIter, LRegsInserted] = LRegsMap.try_emplace(CurSU, LRegs); + if (LRegsInserted) { CurSU->isPending = true; // This SU is not in AvailableQueue right now. Interferences.push_back(CurSU); } else { assert(CurSU->isPending && "Interferences are pending"); // Update the interference with current live regs. - LRegsPair.first->second = LRegs; + LRegsIter->second = LRegs; } CurSU = AvailableQueue->pop(); } -- 2.7.4