Skip to content

Commit 77debf5

Browse files
committed
[GVN] Fix uninitialized variable warnings. NFCI.
1 parent 1842fe6 commit 77debf5

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

llvm/include/llvm/Transforms/Scalar/GVN.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class GVN : public PassInfoMixin<GVN> {
9494
// value number to the index of Expression in Expressions. We use it
9595
// instead of a DenseMap because filling such mapping is faster than
9696
// filling a DenseMap and the compile time is a little better.
97-
uint32_t nextExprNumber;
97+
uint32_t nextExprNumber = 0;
9898

9999
std::vector<Expression> Expressions;
100100
std::vector<uint32_t> ExprIdx;
@@ -107,9 +107,9 @@ class GVN : public PassInfoMixin<GVN> {
107107
DenseMap<std::pair<uint32_t, const BasicBlock *>, uint32_t>;
108108
PhiTranslateMap PhiTranslateTable;
109109

110-
AliasAnalysis *AA;
111-
MemoryDependenceResults *MD;
112-
DominatorTree *DT;
110+
AliasAnalysis *AA = nullptr;
111+
MemoryDependenceResults *MD = nullptr;
112+
DominatorTree *DT = nullptr;
113113

114114
uint32_t nextValueNumber = 1;
115115

@@ -155,14 +155,14 @@ class GVN : public PassInfoMixin<GVN> {
155155
friend class gvn::GVNLegacyPass;
156156
friend struct DenseMapInfo<Expression>;
157157

158-
MemoryDependenceResults *MD;
159-
DominatorTree *DT;
160-
const TargetLibraryInfo *TLI;
161-
AssumptionCache *AC;
158+
MemoryDependenceResults *MD = nullptr;
159+
DominatorTree *DT = nullptr;
160+
const TargetLibraryInfo *TLI = nullptr;
161+
AssumptionCache *AC = nullptr;
162162
SetVector<BasicBlock *> DeadBlocks;
163-
OptimizationRemarkEmitter *ORE;
164-
ImplicitControlFlowTracking *ICF;
165-
LoopInfo *LI;
163+
OptimizationRemarkEmitter *ORE = nullptr;
164+
ImplicitControlFlowTracking *ICF = nullptr;
165+
LoopInfo *LI = nullptr;
166166

167167
ValueTable VN;
168168

llvm/lib/Transforms/Scalar/GVN.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static cl::opt<uint32_t> MaxNumDeps(
112112

113113
struct llvm::GVN::Expression {
114114
uint32_t opcode;
115-
Type *type;
115+
Type *type = nullptr;
116116
bool commutative = false;
117117
SmallVector<uint32_t, 4> varargs;
118118

@@ -173,7 +173,7 @@ struct llvm::gvn::AvailableValue {
173173
PointerIntPair<Value *, 2, ValType> Val;
174174

175175
/// Offset - The byte offset in Val that is interesting for the load query.
176-
unsigned Offset;
176+
unsigned Offset = 0;
177177

178178
static AvailableValue get(Value *V, unsigned Offset = 0) {
179179
AvailableValue Res;
@@ -237,7 +237,7 @@ struct llvm::gvn::AvailableValue {
237237
/// the associated BasicBlock.
238238
struct llvm::gvn::AvailableValueInBlock {
239239
/// BB - The basic block in question.
240-
BasicBlock *BB;
240+
BasicBlock *BB = nullptr;
241241

242242
/// AV - The actual available value
243243
AvailableValue AV;

llvm/lib/Transforms/Scalar/NewGVN.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -489,11 +489,11 @@ namespace {
489489

490490
class NewGVN {
491491
Function &F;
492-
DominatorTree *DT;
493-
const TargetLibraryInfo *TLI;
494-
AliasAnalysis *AA;
495-
MemorySSA *MSSA;
496-
MemorySSAWalker *MSSAWalker;
492+
DominatorTree *DT = nullptr;
493+
const TargetLibraryInfo *TLI = nullptr;
494+
AliasAnalysis *AA = nullptr;
495+
MemorySSA *MSSA = nullptr;
496+
MemorySSAWalker *MSSAWalker = nullptr;
497497
const DataLayout &DL;
498498
std::unique_ptr<PredicateInfo> PredInfo;
499499

@@ -505,7 +505,7 @@ class NewGVN {
505505
const SimplifyQuery SQ;
506506

507507
// Number of function arguments, used by ranking
508-
unsigned int NumFuncArgs;
508+
unsigned int NumFuncArgs = 0;
509509

510510
// RPOOrdering of basic blocks
511511
DenseMap<const DomTreeNode *, unsigned> RPOOrdering;
@@ -516,9 +516,9 @@ class NewGVN {
516516
// startsout in, and represents any value. Being an optimistic analysis,
517517
// anything in the TOP class has the value TOP, which is indeterminate and
518518
// equivalent to everything.
519-
CongruenceClass *TOPClass;
519+
CongruenceClass *TOPClass = nullptr;
520520
std::vector<CongruenceClass *> CongruenceClasses;
521-
unsigned NextCongruenceNum;
521+
unsigned NextCongruenceNum = 0;
522522

523523
// Value Mappings.
524524
DenseMap<Value *, CongruenceClass *> ValueToClass;
@@ -862,7 +862,7 @@ class NewGVN {
862862

863863
// Debug counter info. When verifying, we have to reset the value numbering
864864
// debug counter to the same state it started in to get the same results.
865-
int64_t StartingVNCounter;
865+
int64_t StartingVNCounter = 0;
866866
};
867867

868868
} // end anonymous namespace

0 commit comments

Comments
 (0)