Skip to content

Commit

Permalink
Initialize struct member, prevent nullptr dereference
Browse files Browse the repository at this point in the history
Initialize Score struct member.
Prevent m_FGA nullptr dereference.
  • Loading branch information
smilczek authored and igcbot committed Feb 3, 2025
1 parent ed9a285 commit e18110c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
23 changes: 10 additions & 13 deletions IGC/Compiler/CISACodeGen/EmitVISAPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,6 @@ bool EmitPass::setCurrentShader(llvm::Function* F)
}
Kernel = FG->getHead();
}
else
{
// no analysis result avaliable.
m_FGA = nullptr;
}

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

auto FG = m_FGA->getGroup(ParentFunction);
Function *StackOverflowFunction = nullptr;
// Function subgroup can contain clones of the subroutine.
for (auto F : *FG) {
if (F->getName().startswith(FunctionName) &&
m_FGA->getSubGroupMap(ParentFunction) ==
m_FGA->getSubGroupMap(F)) {
StackOverflowFunction = F;
break;
if (m_FGA) {
auto FG = m_FGA->getGroup(ParentFunction);
// Function subgroup can contain clones of the subroutine.
for (auto F : *FG) {
if (F->getName().startswith(FunctionName) &&
m_FGA->getSubGroupMap(ParentFunction) ==
m_FGA->getSubGroupMap(F)) {
StackOverflowFunction = F;
break;
}
}
}
return StackOverflowFunction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ enum ReductionType
// Score used by heuristic for deciding what type of reduction to apply.
struct Score
{
Score() : ReducesInstructions(false), RegisterPressure(0) {}
Score() : ReducesInstructions(false), RegisterPressure(0), ContainsMuli64(false) {}

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

0 comments on commit e18110c

Please sign in to comment.