Skip to content

Commit 9a6fef0

Browse files
author
Dan Gohman
committed
Simplify code by using SmallVector's pop_back_val() instead of
separate back() and pop_back() calls. llvm-svn: 71089
1 parent 164ac10 commit 9a6fef0

File tree

4 files changed

+6
-12
lines changed

4 files changed

+6
-12
lines changed

llvm/lib/Transforms/Utils/CloneLoop.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ Loop *llvm::CloneLoop(Loop *OrigL, LPPassManager *LPM, LoopInfo *LI,
9292

9393
Loop *NewParentLoop = NULL;
9494
while (!LoopNest.empty()) {
95-
Loop *L = LoopNest.back();
96-
LoopNest.pop_back();
95+
Loop *L = LoopNest.pop_back_val();
9796
Loop *NewLoop = new Loop();
9897

9998
if (!NewParentLoop)

llvm/lib/Transforms/Utils/Local.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ void llvm::RecursivelyDeleteTriviallyDeadInstructions(Value *V) {
188188
DeadInsts.push_back(I);
189189

190190
while (!DeadInsts.empty()) {
191-
I = DeadInsts.back();
192-
DeadInsts.pop_back();
191+
I = DeadInsts.pop_back_val();
193192

194193
// Null out all of the instruction's operands to see if any operand becomes
195194
// dead as we go.

llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,7 @@ ComputeLiveInBlocks(AllocaInst *AI, AllocaInfo &Info,
616616
// Now that we have a set of blocks where the phi is live-in, recursively add
617617
// their predecessors until we find the full region the value is live.
618618
while (!LiveInBlockWorklist.empty()) {
619-
BasicBlock *BB = LiveInBlockWorklist.back();
620-
LiveInBlockWorklist.pop_back();
619+
BasicBlock *BB = LiveInBlockWorklist.pop_back_val();
621620

622621
// The block really is live in here, insert it into the set. If already in
623622
// the set, then it has already been processed.

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -742,8 +742,7 @@ static bool FoldValueComparisonIntoPredecessors(TerminatorInst *TI) {
742742

743743
SmallVector<BasicBlock*, 16> Preds(pred_begin(BB), pred_end(BB));
744744
while (!Preds.empty()) {
745-
BasicBlock *Pred = Preds.back();
746-
Preds.pop_back();
745+
BasicBlock *Pred = Preds.pop_back_val();
747746

748747
// See if the predecessor is a comparison with the same value.
749748
TerminatorInst *PTI = Pred->getTerminator();
@@ -1805,10 +1804,9 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
18051804
// If we found some, do the transformation!
18061805
if (!UncondBranchPreds.empty()) {
18071806
while (!UncondBranchPreds.empty()) {
1808-
BasicBlock *Pred = UncondBranchPreds.back();
1807+
BasicBlock *Pred = UncondBranchPreds.pop_back_val();
18091808
DOUT << "FOLDING: " << *BB
18101809
<< "INTO UNCOND BRANCH PRED: " << *Pred;
1811-
UncondBranchPreds.pop_back();
18121810
Instruction *UncondBranch = Pred->getTerminator();
18131811
// Clone the return and add it to the end of the predecessor.
18141812
Instruction *NewRet = RI->clone();
@@ -1847,8 +1845,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
18471845
// instruction. If any of them just select between returns, change the
18481846
// branch itself into a select/return pair.
18491847
while (!CondBranchPreds.empty()) {
1850-
BranchInst *BI = CondBranchPreds.back();
1851-
CondBranchPreds.pop_back();
1848+
BranchInst *BI = CondBranchPreds.pop_back_val();
18521849

18531850
// Check to see if the non-BB successor is also a return block.
18541851
if (isa<ReturnInst>(BI->getSuccessor(0)->getTerminator()) &&

0 commit comments

Comments
 (0)