Skip to content

Commit 68a90e4

Browse files
ashwinikardileigcbot
authored andcommitted
KW fix for uninitialized variables
KW fix for uninitialized variables
1 parent b98b6b6 commit 68a90e4

11 files changed

+52
-40
lines changed

IGC/Compiler/CISACodeGen/PatternMatchPass.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ namespace IGC
748748
return std::make_tuple(Val, isSignedDst, false);
749749

750750
// Truncate from signed integer. Need to check further for lower bound.
751-
Value* LHS, * RHS;
751+
Value* LHS = nullptr, * RHS = nullptr;
752752
if (!match(Val, m_SMax(m_Value(LHS), m_Value(RHS))))
753753
return std::make_tuple(nullptr, false, false);
754754

@@ -916,8 +916,8 @@ namespace IGC
916916
if (SI.getType()->isFloatingPointTy())
917917
return false;
918918

919-
bool isMin, isUnsigned;
920-
llvm::Value* LHS, * RHS;
919+
bool isMin = false, isUnsigned = false;
920+
llvm::Value* LHS = nullptr, * RHS = nullptr;
921921

922922
if (!isMinOrMax(&SI, LHS, RHS, isMin, isUnsigned))
923923
return false;
@@ -1485,7 +1485,7 @@ namespace IGC
14851485
};
14861486

14871487
PairOutputMapTy::iterator MI;
1488-
bool New;
1488+
bool New = false;
14891489
std::tie(MI, New) = PairOutputMap.insert(std::make_pair(GII, PairOutputTy()));
14901490
if (New) {
14911491
AddPairPattern* Pat = new (m_allocator) AddPairPattern();
@@ -1535,7 +1535,7 @@ namespace IGC
15351535
};
15361536

15371537
PairOutputMapTy::iterator MI;
1538-
bool New;
1538+
bool New = false;
15391539
std::tie(MI, New) = PairOutputMap.insert(std::make_pair(GII, PairOutputTy()));
15401540
if (New) {
15411541
SubPairPattern* Pat = new (m_allocator) SubPairPattern();
@@ -1585,7 +1585,7 @@ namespace IGC
15851585
};
15861586

15871587
PairOutputMapTy::iterator MI;
1588-
bool New;
1588+
bool New = false;
15891589
std::tie(MI, New) = PairOutputMap.insert(std::make_pair(GII, PairOutputTy()));
15901590
if (New) {
15911591
MulPairPattern* Pat = new (m_allocator) MulPairPattern();
@@ -1635,7 +1635,7 @@ namespace IGC
16351635
};
16361636

16371637
PairOutputMapTy::iterator MI;
1638-
bool New;
1638+
bool New = false;
16391639
std::tie(MI, New) = PairOutputMap.insert(std::make_pair(GII, PairOutputTy()));
16401640
if (New) {
16411641
PtrToPairPattern* Pat = new (m_allocator) PtrToPairPattern();
@@ -1667,7 +1667,7 @@ namespace IGC
16671667
};
16681668
bool match = false;
16691669
e_modifier mod;
1670-
Value* source;
1670+
Value* source = nullptr;
16711671
if (GetModifier(I, mod, source))
16721672
{
16731673
MovModifierPattern* pattern = new (m_allocator) MovModifierPattern();
@@ -2822,8 +2822,8 @@ namespace IGC
28222822
std::swap(LHS, RHS);
28232823

28242824
bool IsUnsigned = false;
2825-
llvm::Value* L = nullptr;
2826-
llvm::Value* R = nullptr;
2825+
llvm::Value* L;
2826+
llvm::Value* R;
28272827

28282828
// Check LHS
28292829
if (match(LHS, m_SExt(m_Value(L)))) {
@@ -2950,7 +2950,7 @@ namespace IGC
29502950
for (int i = 0; i < 2; ++i)
29512951
{
29522952
Value* oprd = I.getOperand(i);
2953-
Value* L;
2953+
Value* L = nullptr;
29542954

29552955
// oprdInfo[i].src == null --> no W operand replacement.
29562956
oprdInfo[i].src = nullptr;

IGC/Compiler/CISACodeGen/PixelShaderLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,8 +1542,8 @@ bool DiscardLowering::lowerDiscards(Function& F)
15421542

15431543
bool DiscardLowering::runOnFunction(Function& F)
15441544
{
1545-
IGCMD::MetaDataUtils* pMdUtils =
1546-
getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils();
1545+
IGCMD::MetaDataUtils* pMdUtils = nullptr;
1546+
pMdUtils = getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils();
15471547
if (pMdUtils->findFunctionsInfoItem(&F) == pMdUtils->end_FunctionsInfo())
15481548
{
15491549
return false;

IGC/Compiler/CISACodeGen/PreRARematFlag.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ namespace IGC {
208208

209209
bool PreRARematFlag::runOnFunction(Function& F) {
210210
// Skip non-kernel function.
211-
MetaDataUtils* MDU = getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils();
211+
MetaDataUtils* MDU = nullptr;
212+
MDU = getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils();
212213
auto FII = MDU->findFunctionsInfoItem(&F);
213214
if (FII == MDU->end_FunctionsInfo())
214215
return false;

IGC/Compiler/CISACodeGen/PullConstantHeuristics.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ static std::tuple<unsigned, unsigned, unsigned> getInstStats(const Function& F)
9999
// thread_payload_size > max(simd4_sample_instr, simd4_eu_instr / 16, simd4_rt_write * 2, shader_lifetime / 56)
100100
unsigned int PullConstantHeuristics::getPSDBottleNeckThreshold(const Function& F)
101101
{
102-
CodeGenContext* ctx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
102+
CodeGenContext* ctx = nullptr;
103+
ctx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
103104
const unsigned numThreadsPerSubslice = ctx->platform.getMaxNumberThreadPerSubslice(); //read from ctx.platform
104105
const unsigned roofLineIPC = 16;
105106
const unsigned pixelRate = 2;
@@ -157,7 +158,8 @@ bool PullConstantHeuristics::runOnModule(Module& M)
157158
{
158159
return false;
159160
}
160-
CodeGenContext* ctx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
161+
CodeGenContext* ctx = nullptr;
162+
ctx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
161163
if (ctx->type == ShaderType::PIXEL_SHADER && ctx->platform.hasPSDBottleneck())
162164
{
163165
for (auto& F : M)

IGC/Compiler/CISACodeGen/PushAnalysis.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ namespace IGC
100100
Value* PushAnalysis::addArgumentAndMetadata(llvm::Type* pType, std::string argName, IGC::WIAnalysis::WIDependancy dependency)
101101
{
102102
auto pArgInfo = m_pFuncUpgrade.AddArgument(argName, pType);
103-
ModuleMetaData* modMD = getAnalysis<MetaDataUtilsWrapper>().getModuleMetaData();
103+
ModuleMetaData* modMD = nullptr;
104+
modMD = getAnalysis<MetaDataUtilsWrapper>().getModuleMetaData();
104105
IGC::ArgDependencyInfoMD argDepInfoMD;
105106
argDepInfoMD.argDependency = dependency;
106107
modMD->pushInfo.pushAnalysisWIInfos.push_back(argDepInfoMD);

IGC/Compiler/CISACodeGen/SLMConstProp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,8 @@ bool SLMConstProp::runOnFunction(Function& F)
974974
#endif
975975

976976
// Do this only for the top function
977-
MetaDataUtils* pMdUtils = getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils();
977+
MetaDataUtils* pMdUtils = nullptr;
978+
pMdUtils = getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils();
978979
if (pMdUtils->findFunctionsInfoItem(&F) == pMdUtils->end_FunctionsInfo())
979980
{
980981
return false;

IGC/Compiler/CISACodeGen/Simd32Profitability.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ countOperands(Value* V, Value* LHS, Value* RHS) {
214214
ConstantInt* CI = dyn_cast<ConstantInt>(BO->getOperand(1));
215215
if (!CI)
216216
return std::make_tuple(0, 0);
217-
int L, R;
217+
int L = 0, R = 0;
218218
std::tie(L, R) = countOperands(BO->getOperand(0), LHS, RHS);
219219
uint64_t ShAmt = CI->getZExtValue();
220220
return std::make_tuple((L << ShAmt), (R << ShAmt));
@@ -224,7 +224,7 @@ countOperands(Value* V, Value* LHS, Value* RHS) {
224224
ConstantInt* CI = dyn_cast<ConstantInt>(BO->getOperand(1));
225225
if (!CI || CI->getSExtValue() != -1)
226226
return std::make_tuple(0, 0);
227-
int L, R;
227+
int L = 0, R = 0;
228228
std::tie(L, R) = countOperands(BO->getOperand(0), LHS, RHS);
229229
return std::make_tuple(-L, -R);
230230
}
@@ -234,9 +234,9 @@ countOperands(Value* V, Value* LHS, Value* RHS) {
234234

235235
if (isa<Constant>(BO->getOperand(1)))
236236
return countOperands(BO->getOperand(0), LHS, RHS);
237-
int L0, L1;
237+
int L0 = 0, L1 = 0;
238238
std::tie(L0, L1) = countOperands(BO->getOperand(0), LHS, RHS);
239-
int R0, R1;
239+
int R0 = 0, R1 = 0;
240240
std::tie(R0, R1) = countOperands(BO->getOperand(1), LHS, RHS);
241241
if (BO->getOpcode() == Instruction::Add)
242242
return std::make_tuple(L0 + R0, L1 + R1);
@@ -247,14 +247,14 @@ countOperands(Value* V, Value* LHS, Value* RHS) {
247247

248248
static bool isNegatedByLB(Value* V, Value* X, Value* LB) {
249249
// Check if `V` is calculated as LB - X +/- C, where C is constant.
250-
int L, R;
250+
int L = 0, R = 0;
251251
std::tie(L, R) = countOperands(V, LB, X);
252252
return (L == 1) && (R == -1);
253253
}
254254

255255
static bool isNegatedBy2UB(Value* V, Value* X, Value* UB) {
256256
// Check if `V` is calculated as 2UB - X +/- C, where C is constant.
257-
int L, R;
257+
int L = 0, R = 0;
258258
std::tie(L, R) = countOperands(V, UB, X);
259259
return (L == 2) && (R == -1);
260260
}
@@ -270,8 +270,8 @@ unsigned Simd32ProfitabilityAnalysis::estimateLoopCount_CASE1(Loop* L) {
270270
if (!L->contains(Br->getSuccessor(0)))
271271
return LOOPCOUNT_UNKNOWN;
272272

273-
Value* X, * LB, * UB;
274-
bool Signed;
273+
Value* X = nullptr, * LB = nullptr, * UB = nullptr;
274+
bool Signed = false;
275275
std::tie(X, LB, UB, Signed) = isOutOfRangeComparison(Br->getCondition());
276276
if (!X) {
277277
ICmpInst* Cmp = dyn_cast<ICmpInst>(Br->getCondition());
@@ -364,9 +364,9 @@ unsigned Simd32ProfitabilityAnalysis::estimateLoopCount_CASE1(Loop* L) {
364364
return LOOPCOUNT_UNKNOWN;
365365
if (RHS != LB)
366366
return LOOPCOUNT_UNKNOWN;
367-
int L0, R0;
367+
int L0 = 0, R0 = 0;
368368
std::tie(L0, R0) = countOperands(X0, LB, nullptr);
369-
int L1, R1;
369+
int L1 = 0, R1 = 0;
370370
std::tie(L1, R1) = countOperands(X1, UB, nullptr);
371371
if (L0 != 1 || L1 != 2)
372372
return LOOPCOUNT_UNKNOWN;
@@ -394,7 +394,7 @@ unsigned Simd32ProfitabilityAnalysis::estimateLoopCount_CASE2(Loop* L) {
394394
SmallVector<BasicBlock*, 8> ExitingBBs;
395395
L->getExitingBlocks(ExitingBBs);
396396

397-
Value* Init, * Curr, * Next, * Step;
397+
Value* Init = nullptr, * Curr= nullptr, * Next= nullptr, * Step= nullptr;
398398
std::tie(Init, Curr, Step, Next) = getInductionVariable(L);
399399
if (!Init || !Curr || !Step || !Next)
400400
return LOOPCOUNT_UNKNOWN;
@@ -541,7 +541,8 @@ static bool hasSubGroupFunc(const Function& F)
541541
bool Simd32ProfitabilityAnalysis::runOnFunction(Function& F)
542542
{
543543
this->F = &F;
544-
CodeGenContext* context = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
544+
CodeGenContext* context = nullptr;
545+
context = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
545546
if (context->type == ShaderType::OPENCL_SHADER)
546547
{
547548
PDT = &getAnalysis<PostDominatorTreeWrapperPass>().getPostDomTree();
@@ -809,7 +810,7 @@ bool Simd32ProfitabilityAnalysis::checkSimd32Profitable(CodeGenContext* ctx)
809810
if (Br && Br->isConditional()) {
810811
auto ICmp = dyn_cast<ICmpInst>(Br->getCondition());
811812
if (ICmp) {
812-
Value* Init, * Curr, * Step, * Next;
813+
Value* Init = nullptr, * Curr = nullptr, * Step= nullptr, * Next = nullptr;
813814
std::tie(Init, Curr, Step, Next)
814815
= getInductionVariable(loop);
815816
if (Init && Curr && Next && Step &&

IGC/Compiler/CISACodeGen/VariableReuseAnalysis.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -756,9 +756,9 @@ bool VariableReuseAnalysis::getAllInsEltsIfAvailable(
756756
m_DeSSA->getRootValue(I) != dessaRoot)
757757
return false;
758758

759-
Value* V;
760-
Value* E;
761-
int IEI_ix, V_ix;
759+
Value* V = nullptr;
760+
Value* E = nullptr;
761+
int IEI_ix = 0, V_ix = 0;
762762
if (!getElementValue(I, IEI_ix, E, V, V_ix)) {
763763
return false;
764764
}

IGC/Compiler/CISACodeGen/VariableReuseAnalysis.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@ namespace IGC {
369369
void BeginBlock(llvm::BasicBlock* BB) {
370370
IGC_ASSERT(m_SimdSize != 0);
371371
if (m_RPE) {
372-
CodeGenContext* context = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
372+
CodeGenContext* context = nullptr;
373+
context = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
373374
uint32_t BBPresure = m_RPE->getMaxLiveGRFAtBB(BB, m_SimdSize);
374375
if (BBPresure <= context->getNumGRFPerThread())
375376
m_IsBlockPressureLow = Status::True;

IGC/Compiler/CISACodeGen/VectorProcess.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ bool VectorProcess::reLayoutLoadStore(Instruction* Inst)
278278
else
279279
{
280280
// This handles all the other cases
281-
CodeGenContext* cgCtx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
281+
CodeGenContext* cgCtx = nullptr;
282+
cgCtx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
282283
bool useA64 = IGC::isA64Ptr(PtrTy, cgCtx);
283284
uint32_t align;
284285
if (LI)
@@ -522,7 +523,8 @@ bool VectorProcess::optimizeBitCast(BitCastInst* BC)
522523

523524
bool VectorProcess::runOnFunction(Function& F)
524525
{
525-
CodeGenContext* cgCtx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
526+
CodeGenContext* cgCtx = nullptr;
527+
cgCtx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext();
526528
bool changed = false;
527529
m_DL = &F.getParent()->getDataLayout();
528530
m_C = &F.getContext();

IGC/Compiler/CISACodeGen/VertexShaderLowering.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ namespace IGC
5252
{
5353
// VS lowering only applies to entry function. Non-entry funtions
5454
// are emulation functions that do not need to be lowered!
55-
MetaDataUtils* pMdUtils = getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils();
55+
MetaDataUtils* pMdUtils = nullptr;
56+
pMdUtils = getAnalysis<MetaDataUtilsWrapper>().getMetaDataUtils();
5657
if (!isEntryFunc(pMdUtils, &F))
5758
{
5859
return false;
@@ -571,7 +572,8 @@ namespace IGC
571572
index,
572573
offset
573574
};
574-
unsigned int inIndex = int_cast<unsigned int>(cast<ConstantInt>(offset)->getZExtValue());
575+
unsigned int inIndex = 0;
576+
inIndex = int_cast<unsigned int>(cast<ConstantInt>(offset)->getZExtValue());
575577
IGC_ASSERT(inIndex < MaxNumOfInputs);
576578

577579
Instruction* urbRead = GenIntrinsicInst::Create(
@@ -592,7 +594,8 @@ namespace IGC
592594
Instruction* newExt = ExtractElementInst::Create(urbRead, extIdx, "", elem);
593595
if (isa<ConstantInt>(extIdx))
594596
{
595-
unsigned int channel = int_cast<unsigned int>(
597+
unsigned int channel = 0;
598+
channel = int_cast<unsigned int>(
596599
cast<ConstantInt>(extIdx)->getZExtValue());
597600
m_inputUsed[inIndex * 4 + channel] = true;
598601
}

0 commit comments

Comments
 (0)