Skip to content

Commit e18110c

Browse files
smilczekigcbot
authored andcommitted
Initialize struct member, prevent nullptr dereference
Initialize Score struct member. Prevent m_FGA nullptr dereference.
1 parent ed9a285 commit e18110c

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,6 @@ bool EmitPass::setCurrentShader(llvm::Function* F)
510510
}
511511
Kernel = FG->getHead();
512512
}
513-
else
514-
{
515-
// no analysis result avaliable.
516-
m_FGA = nullptr;
517-
}
518513

519514
auto Iter = m_shaders.find(Kernel);
520515
if (Iter == m_shaders.end())
@@ -25515,15 +25510,17 @@ Function* EmitPass::findStackOverflowDetectionFunction(Function* ParentFunction,
2551525510
};
2551625511
const char *FunctionName = (FindInitFunction ? FunctionNames[0] : FunctionNames[1]);
2551725512

25518-
auto FG = m_FGA->getGroup(ParentFunction);
2551925513
Function *StackOverflowFunction = nullptr;
25520-
// Function subgroup can contain clones of the subroutine.
25521-
for (auto F : *FG) {
25522-
if (F->getName().startswith(FunctionName) &&
25523-
m_FGA->getSubGroupMap(ParentFunction) ==
25524-
m_FGA->getSubGroupMap(F)) {
25525-
StackOverflowFunction = F;
25526-
break;
25514+
if (m_FGA) {
25515+
auto FG = m_FGA->getGroup(ParentFunction);
25516+
// Function subgroup can contain clones of the subroutine.
25517+
for (auto F : *FG) {
25518+
if (F->getName().startswith(FunctionName) &&
25519+
m_FGA->getSubGroupMap(ParentFunction) ==
25520+
m_FGA->getSubGroupMap(F)) {
25521+
StackOverflowFunction = F;
25522+
break;
25523+
}
2552725524
}
2552825525
}
2552925526
return StackOverflowFunction;

IGC/Compiler/Optimizer/OpenCLPasses/GEPLoopStrengthReduction/GEPLoopStrengthReduction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ enum ReductionType
118118
// Score used by heuristic for deciding what type of reduction to apply.
119119
struct Score
120120
{
121-
Score() : ReducesInstructions(false), RegisterPressure(0) {}
121+
Score() : ReducesInstructions(false), RegisterPressure(0), ContainsMuli64(false) {}
122122

123123
// True if reduction to preheader would lower number of instructions in
124124
// loop. False otherwise.

0 commit comments

Comments
 (0)