From dcbeaf027cc2fe149bfa465dc534aed9101d2ac9 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 23 Jan 2021 10:56:33 -0800 Subject: [PATCH] [llvm] Use pop_back_val (NFC) --- lib/Transforms/Coroutines/CoroFrame.cpp | 6 ++---- lib/Transforms/IPO/ArgumentPromotion.cpp | 3 +-- lib/Transforms/Scalar/LoopStrengthReduce.cpp | 3 +-- lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp | 6 ++---- lib/Transforms/Scalar/NewGVN.cpp | 3 +-- lib/Transforms/Scalar/Reassociate.cpp | 3 +-- lib/Transforms/Scalar/SCCP.cpp | 3 +-- lib/Transforms/Utils/FixIrreducible.cpp | 3 +-- lib/Transforms/Utils/LoopUnrollAndJam.cpp | 3 +-- lib/Transforms/Vectorize/SLPVectorizer.cpp | 6 ++---- 10 files changed, 13 insertions(+), 26 deletions(-) diff --git a/lib/Transforms/Coroutines/CoroFrame.cpp b/lib/Transforms/Coroutines/CoroFrame.cpp index b12f53032fa..3f290f2f087 100644 --- a/lib/Transforms/Coroutines/CoroFrame.cpp +++ b/lib/Transforms/Coroutines/CoroFrame.cpp @@ -913,8 +913,7 @@ struct AllocaUseVisitor : PtrUseVisitor { // StoreAliases contains aliases of the memory location stored into. SmallVector StoreAliases = {AI}; while (!StoreAliases.empty()) { - Instruction *I = StoreAliases.back(); - StoreAliases.pop_back(); + Instruction *I = StoreAliases.pop_back_val(); for (User *U : I->users()) { // If we are loading from the memory location, we are creating an // alias of the original pointer. @@ -2005,8 +2004,7 @@ static void sinkSpillUsesAfterCoroBegin(Function &F, } // Recursively collect users before coro.begin. while (!Worklist.empty()) { - auto *Def = Worklist.back(); - Worklist.pop_back(); + auto *Def = Worklist.pop_back_val(); for (User *U : Def->users()) { auto Inst = cast(U); if (Dom.dominates(CoroBegin, Inst)) diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index 877515910dc..7998a1ae5c6 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -824,8 +824,7 @@ static bool canPaddingBeAccessed(Argument *arg) { // sanely. SmallVector WorkList(arg->users()); while (!WorkList.empty()) { - Value *V = WorkList.back(); - WorkList.pop_back(); + Value *V = WorkList.pop_back_val(); if (isa(V) || isa(V)) { if (PtrValues.insert(V).second) llvm::append_range(WorkList, V->users()); diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 118cbbbd418..5dec9b54207 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -507,8 +507,7 @@ void Formula::canonicalize(const Loop &L) { // Keep the invariant sum in BaseRegs and one of the variant sum in ScaledReg. if (!ScaledReg) { - ScaledReg = BaseRegs.back(); - BaseRegs.pop_back(); + ScaledReg = BaseRegs.pop_back_val(); Scale = 1; } diff --git a/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp b/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp index 812922c49cf..8e251ca940a 100644 --- a/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp +++ b/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp @@ -531,8 +531,7 @@ public: // list. LLVM_DEBUG(dbgs() << "Forward-propagate shapes:\n"); while (!WorkList.empty()) { - Instruction *Inst = WorkList.back(); - WorkList.pop_back(); + Instruction *Inst = WorkList.pop_back_val(); // New entry, set the value and insert operands bool Propagate = false; @@ -602,8 +601,7 @@ public: // worklist. LLVM_DEBUG(dbgs() << "Backward-propagate shapes:\n"); while (!WorkList.empty()) { - Value *V = WorkList.back(); - WorkList.pop_back(); + Value *V = WorkList.pop_back_val(); size_t BeforeProcessingV = WorkList.size(); if (!isa(V)) diff --git a/lib/Transforms/Scalar/NewGVN.cpp b/lib/Transforms/Scalar/NewGVN.cpp index 13afd3b72be..281d47c8625 100644 --- a/lib/Transforms/Scalar/NewGVN.cpp +++ b/lib/Transforms/Scalar/NewGVN.cpp @@ -2876,8 +2876,7 @@ void NewGVN::cleanupTables() { } while (!TempInst.empty()) { - auto *I = TempInst.back(); - TempInst.pop_back(); + auto *I = TempInst.pop_back_val(); I->deleteValue(); } diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp index 04e7a59c0d0..dffeb7cc227 100644 --- a/lib/Transforms/Scalar/Reassociate.cpp +++ b/lib/Transforms/Scalar/Reassociate.cpp @@ -1128,8 +1128,7 @@ static Value *EmitAddTreeOfValues(Instruction *I, SmallVectorImpl &Ops) { if (Ops.size() == 1) return Ops.back(); - Value *V1 = Ops.back(); - Ops.pop_back(); + Value *V1 = Ops.pop_back_val(); Value *V2 = EmitAddTreeOfValues(I, Ops); return CreateAdd(V2, V1, "reass.add", I, I); } diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 24b4da64703..de6be52adf2 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -1448,8 +1448,7 @@ void SCCPSolver::Solve() { // Process the basic block work list. while (!BBWorkList.empty()) { - BasicBlock *BB = BBWorkList.back(); - BBWorkList.pop_back(); + BasicBlock *BB = BBWorkList.pop_back_val(); LLVM_DEBUG(dbgs() << "\nPopped off BBWL: " << *BB << '\n'); diff --git a/lib/Transforms/Utils/FixIrreducible.cpp b/lib/Transforms/Utils/FixIrreducible.cpp index 32408d0a2bd..44af95eef67 100644 --- a/lib/Transforms/Utils/FixIrreducible.cpp +++ b/lib/Transforms/Utils/FixIrreducible.cpp @@ -320,8 +320,7 @@ static bool FixIrreducibleImpl(Function &F, LoopInfo &LI, DominatorTree &DT) { append_range(WorkList, LI); while (!WorkList.empty()) { - auto L = WorkList.back(); - WorkList.pop_back(); + auto L = WorkList.pop_back_val(); LLVM_DEBUG(dbgs() << "visiting loop with header " << L->getHeader()->getName() << "\n"); Changed |= makeReducible(LI, DT, *L); diff --git a/lib/Transforms/Utils/LoopUnrollAndJam.cpp b/lib/Transforms/Utils/LoopUnrollAndJam.cpp index ef9e9c863bd..6e32a2b865a 100644 --- a/lib/Transforms/Utils/LoopUnrollAndJam.cpp +++ b/lib/Transforms/Utils/LoopUnrollAndJam.cpp @@ -148,8 +148,7 @@ static bool processHeaderPhiOperands(BasicBlock *Header, BasicBlock *Latch, } while (!Worklist.empty()) { - Instruction *I = Worklist.back(); - Worklist.pop_back(); + Instruction *I = Worklist.pop_back_val(); if (!Visit(I)) return false; diff --git a/lib/Transforms/Vectorize/SLPVectorizer.cpp b/lib/Transforms/Vectorize/SLPVectorizer.cpp index 6c2b10e5b9f..c5cfc9e77d8 100644 --- a/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -5164,8 +5164,7 @@ BoUpSLP::BlockScheduling::tryScheduleBundle(ArrayRef VL, BoUpSLP *SLP, // cancelScheduling). while (!Bundle->isReady() && !ReadyInsts.empty()) { - ScheduleData *pickedSD = ReadyInsts.back(); - ReadyInsts.pop_back(); + ScheduleData *pickedSD = ReadyInsts.pop_back_val(); if (pickedSD->isSchedulingEntity() && pickedSD->isReady()) { schedule(pickedSD, ReadyInsts); @@ -5338,8 +5337,7 @@ void BoUpSLP::BlockScheduling::calculateDependencies(ScheduleData *SD, WorkList.push_back(SD); while (!WorkList.empty()) { - ScheduleData *SD = WorkList.back(); - WorkList.pop_back(); + ScheduleData *SD = WorkList.pop_back_val(); ScheduleData *BundleMember = SD; while (BundleMember) {