Skip to content

Commit 3c9297c

Browse files
fda0igcbot
authored andcommitted
Fix null dereferences
Refactor potential null dereferences or assert that values aren't null in suspicious places.
1 parent 26e89c1 commit 3c9297c

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXLowering.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4486,6 +4486,7 @@ bool GenXLowering::lowerLogicalThreadID(CallInst *CI) {
44864486

44874487
if (!isPowerOf2_32(NumThreads)) {
44884488
IGC_ASSERT_EXIT(Res);
4489+
IGC_ASSERT_EXIT(TID);
44894490
auto *Mul = IRB.CreateMul(Res, ConstantInt::get(Ty, NumThreads));
44904491
Res = IRB.CreateAdd(Mul, TID);
44914492
}

IGC/VectorCompiler/lib/InternalIntrinsics/InternalIntrinsics.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,9 @@ getIntrinsicInfoTableEntries(InternalIntrinsic::ID id,
443443
/// parse ffXX as f(fXX) or f(fX)X. (X is a placeholder for any other type.)
444444
static std::string getMangledTypeStr(Type *Ty) {
445445
std::string Result;
446+
if (!Ty)
447+
return Result;
448+
446449
if (PointerType *PTyp = dyn_cast<PointerType>(Ty)) {
447450
Result += "p" + utostr(PTyp->getAddressSpace()) +
448451
getMangledTypeStr(IGCLLVM::getNonOpaquePtrEltTy(PTyp));
@@ -469,7 +472,7 @@ static std::string getMangledTypeStr(Type *Ty) {
469472
Result += "v" +
470473
utostr(cast<IGCLLVM::FixedVectorType>(Ty)->getNumElements()) +
471474
getMangledTypeStr(cast<VectorType>(Ty)->getElementType());
472-
else if (Ty)
475+
else
473476
Result += EVT::getEVT(Ty).getEVTString();
474477
return Result;
475478
}

visa/GraphColor.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3659,10 +3659,12 @@ void Augmentation::buildLiveIntervals() {
36593659
G4_Declare *defdcl = GetTopDclFromRegRegion(dst);
36603660

36613661
if (dst->getBase()->isRegAllocPartaker()) {
3662-
if (defdcl && gra.getLocalLR(defdcl)) {
3663-
updateStartIntervalForLocal(defdcl, inst, dst);
3664-
} else {
3665-
updateStartInterval(defdcl, inst);
3662+
if (defdcl) {
3663+
if (gra.getLocalLR(defdcl)) {
3664+
updateStartIntervalForLocal(defdcl, inst, dst);
3665+
} else {
3666+
updateStartInterval(defdcl, inst);
3667+
}
36663668
}
36673669
} else if (liveAnalysis.livenessClass(G4_GRF)) {
36683670
LocalLiveRange *defdclLR;

0 commit comments

Comments
 (0)