Skip to content

Commit

Permalink
Fix null dereferences
Browse files Browse the repository at this point in the history
Refactor potential null dereferences or assert that values
aren't null in suspicious places.
  • Loading branch information
fda0 authored and igcbot committed Sep 27, 2023
1 parent 26e89c1 commit 3c9297c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions IGC/VectorCompiler/lib/GenXCodeGen/GenXLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4486,6 +4486,7 @@ bool GenXLowering::lowerLogicalThreadID(CallInst *CI) {

if (!isPowerOf2_32(NumThreads)) {
IGC_ASSERT_EXIT(Res);
IGC_ASSERT_EXIT(TID);
auto *Mul = IRB.CreateMul(Res, ConstantInt::get(Ty, NumThreads));
Res = IRB.CreateAdd(Mul, TID);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,9 @@ getIntrinsicInfoTableEntries(InternalIntrinsic::ID id,
/// parse ffXX as f(fXX) or f(fX)X. (X is a placeholder for any other type.)
static std::string getMangledTypeStr(Type *Ty) {
std::string Result;
if (!Ty)
return Result;

if (PointerType *PTyp = dyn_cast<PointerType>(Ty)) {
Result += "p" + utostr(PTyp->getAddressSpace()) +
getMangledTypeStr(IGCLLVM::getNonOpaquePtrEltTy(PTyp));
Expand All @@ -469,7 +472,7 @@ static std::string getMangledTypeStr(Type *Ty) {
Result += "v" +
utostr(cast<IGCLLVM::FixedVectorType>(Ty)->getNumElements()) +
getMangledTypeStr(cast<VectorType>(Ty)->getElementType());
else if (Ty)
else
Result += EVT::getEVT(Ty).getEVTString();
return Result;
}
Expand Down
10 changes: 6 additions & 4 deletions visa/GraphColor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3659,10 +3659,12 @@ void Augmentation::buildLiveIntervals() {
G4_Declare *defdcl = GetTopDclFromRegRegion(dst);

if (dst->getBase()->isRegAllocPartaker()) {
if (defdcl && gra.getLocalLR(defdcl)) {
updateStartIntervalForLocal(defdcl, inst, dst);
} else {
updateStartInterval(defdcl, inst);
if (defdcl) {
if (gra.getLocalLR(defdcl)) {
updateStartIntervalForLocal(defdcl, inst, dst);
} else {
updateStartInterval(defdcl, inst);
}
}
} else if (liveAnalysis.livenessClass(G4_GRF)) {
LocalLiveRange *defdclLR;
Expand Down

0 comments on commit 3c9297c

Please sign in to comment.