[llvm] b8aba76 - LoopFlatten - CanWidenIV - Fix uninitialized variable warnings and use for-range loop. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 6 04:24:36 PDT 2021
Author: Simon Pilgrim
Date: 2021-04-06T12:24:20+01:00
New Revision: b8aba76a4eab8e39008e243ebc2a3d0b56c1bd0c
URL: https://github.com/llvm/llvm-project/commit/b8aba76a4eab8e39008e243ebc2a3d0b56c1bd0c
DIFF: https://github.com/llvm/llvm-project/commit/b8aba76a4eab8e39008e243ebc2a3d0b56c1bd0c.diff
LOG: 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.
Added:
Modified:
llvm/lib/Transforms/Scalar/LoopFlatten.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/LoopFlatten.cpp b/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
index 4eea953ec814b..7dc7cbff3dab3 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<WeakTrackingVH, 4> 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);
}
More information about the llvm-commits
mailing list