From b8aba76a4eab8e39008e243ebc2a3d0b56c1bd0c Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Tue, 6 Apr 2021 12:24:04 +0100 Subject: [PATCH] LoopFlatten - CanWidenIV - Fix uninitialized variable warnings and use for-range loop. NFCI. Fix static analysis uninitialized variable warnings, and use for-range loop iteration across WideIVs array. --- llvm/lib/Transforms/Scalar/LoopFlatten.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/LoopFlatten.cpp b/llvm/lib/Transforms/Scalar/LoopFlatten.cpp index 4eea953ec814..7dc7cbff3dab 100644 --- a/llvm/lib/Transforms/Scalar/LoopFlatten.cpp +++ b/llvm/lib/Transforms/Scalar/LoopFlatten.cpp @@ -605,21 +605,21 @@ static bool CanWidenIV(FlattenInfo &FI, DominatorTree *DT, LoopInfo *LI, SmallVector DeadInsts; WideIVs.push_back( {FI.InnerInductionPHI, MaxLegalType, false }); WideIVs.push_back( {FI.OuterInductionPHI, MaxLegalType, false }); - unsigned ElimExt; - unsigned Widened; + unsigned ElimExt = 0; + unsigned Widened = 0; - for (unsigned i = 0; i < WideIVs.size(); i++) { - PHINode *WidePhi = createWideIV(WideIVs[i], LI, SE, Rewriter, DT, DeadInsts, + for (const auto &WideIV : WideIVs) { + PHINode *WidePhi = createWideIV(WideIV, LI, SE, Rewriter, DT, DeadInsts, ElimExt, Widened, true /* HasGuards */, true /* UsePostIncrementRanges */); if (!WidePhi) return false; LLVM_DEBUG(dbgs() << "Created wide phi: "; WidePhi->dump()); - LLVM_DEBUG(dbgs() << "Deleting old phi: "; WideIVs[i].NarrowIV->dump()); - RecursivelyDeleteDeadPHINode(WideIVs[i].NarrowIV); + LLVM_DEBUG(dbgs() << "Deleting old phi: "; WideIV.NarrowIV->dump()); + RecursivelyDeleteDeadPHINode(WideIV.NarrowIV); } // After widening, rediscover all the loop components. - assert(Widened && "Widenend IV expected"); + assert(Widened && "Widened IV expected"); FI.Widened = true; return CanFlattenLoopPair(FI, DT, LI, SE, AC, TTI); }