Skip to content

Commit ab04ed5

Browse files
smilczekigcbot
authored andcommitted
Add missing assersions
Throughout the codebase there are some places that could use some asserts to ensure out of bouds accesses are not being made or invalid pointers are not being dereferenced. This commit adds some such asserts.
1 parent 8fd1e57 commit ab04ed5

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

visa/BuildIR.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,18 +406,22 @@ class IR_Builder {
406406
class PreDefinedVars {
407407
public:
408408
void setHasPredefined(PreDefinedVarsInternal id, bool val) {
409+
vASSERT(id < PreDefinedVarsInternal::VAR_LAST);
409410
hasPredefined[static_cast<int>(id)] = val;
410411
}
411412

412413
bool isHasPredefined(PreDefinedVarsInternal id) const {
414+
vASSERT(id < PreDefinedVarsInternal::VAR_LAST);
413415
return hasPredefined[static_cast<int>(id)];
414416
}
415417

416418
void setPredefinedVar(PreDefinedVarsInternal id, G4_Declare *dcl) {
419+
vASSERT(id < PreDefinedVarsInternal::VAR_LAST);
417420
predefinedVars[static_cast<int>(id)] = dcl;
418421
}
419422

420423
G4_Declare *getPreDefinedVar(PreDefinedVarsInternal id) const {
424+
vASSERT(id < PreDefinedVarsInternal::VAR_LAST);
421425
if (id >= PreDefinedVarsInternal::VAR_LAST) {
422426
return nullptr;
423427
}

visa/BuildIRImpl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ void IR_Builder::createPreDefinedVars() {
633633
break;
634634
}
635635
default: {
636+
vISA_ASSERT(false, "Invalid PreDefinedVarsInternal value");
636637
break;
637638
}
638639
}

visa/Rematerialization.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ G4_SrcRegRegion *Rematerialization::rematerialize(G4_SrcRegRegion *src,
861861
}
862862

863863
auto samplerDefIt = samplerHeaderMap.find(uniqueDef->first);
864+
vASSERT(samplerDefIt != samplerHeaderMap.end());
864865
auto prevHeaderMov = (*samplerDefIt).second;
865866

866867
src0 = dstInst->getSrc(0);

0 commit comments

Comments
 (0)