Skip to content

Commit b545b8c

Browse files
fda0igcbot
authored andcommitted
Add asserts, checks, guard against null dereference
Add asserts, checks, guard against null dereference.
1 parent 0b97863 commit b545b8c

33 files changed

+73
-55
lines changed

IGC/AdaptorCommon/AddImplicitArgs.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,7 @@ void AddImplicitArgs::replaceAllUsesWithNewOCLBuiltinFunction(llvm::Function* ol
415415

416416
// tracing it on parent function argument list
417417
Value* callArg = ValueTracker::track(cInst, argImpToExpNum[&(*new_arg_iter)]);
418-
Argument* arg = dyn_cast<Argument>(callArg);
419-
420-
IGC_ASSERT_MESSAGE(arg, "Not supported");
418+
Argument* arg = cast<Argument>(callArg);
421419

422420
// build info
423421

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3228,6 +3228,7 @@ namespace IGC
32283228
{
32293229
tempVar = GetRawSource(dst);
32303230
}
3231+
IGC_ASSERT(tempVar);
32313232

32323233
MEDIA_LD_mod modi = (MEDIA_LD_mod)modifier;
32333234
CISA_PLANE_ID planeVar = (CISA_PLANE_ID)plane;

IGC/Compiler/CISACodeGen/CShader.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,7 @@ llvm::Constant* CShader::findCommonConstant(llvm::Constant* C, uint elts, uint c
18511851
// check if the constant can be packed in vf.
18521852
if (!isa<UndefValue>(constC) && elts >= 4)
18531853
{
1854-
llvm::VectorType* VTy = llvm::dyn_cast<llvm::VectorType>(C->getType());
1854+
llvm::VectorType* VTy = llvm::cast<llvm::VectorType>(C->getType());
18551855
uint8_t encoding = 0;
18561856
if (VTy->getScalarType()->isFloatTy() &&
18571857
!getByteFloatEncoding(cast<ConstantFP>(constC), encoding))
@@ -2388,8 +2388,8 @@ static e_alignment GetPreferredAlignmentOnUse(llvm::Value* V, WIAnalysis* WIA,
23882388
// Only oprd1 could be uniform and its alignment could
23892389
// be less than GRF. All the others are GRF-aligned.
23902390
if (aV == GII->getArgOperand(1)) {
2391-
ConstantInt* pa = dyn_cast<ConstantInt>(GII->getOperand(3)); // oprd1's precision
2392-
ConstantInt* sdepth = dyn_cast<ConstantInt>(GII->getOperand(5));
2391+
ConstantInt* pa = cast<ConstantInt>(GII->getOperand(3)); // oprd1's precision
2392+
ConstantInt* sdepth = cast<ConstantInt>(GII->getOperand(5));
23932393

23942394
int PA = (int)pa->getSExtValue();
23952395
int SD = (int)sdepth->getSExtValue();
@@ -3722,7 +3722,7 @@ void CShader::GetPayloadElementSymbols(llvm::Value* inst, CVariable* payload[],
37223722
int count = 0;
37233723
//Gather elements of vector
37243724
while (ie != NULL) {
3725-
int64_t iOffset = llvm::dyn_cast<llvm::ConstantInt>(ie->getOperand(2))->getSExtValue();
3725+
int64_t iOffset = llvm::cast<llvm::ConstantInt>(ie->getOperand(2))->getSExtValue();
37263726
IGC_ASSERT(iOffset >= 0);
37273727
IGC_ASSERT(iOffset < vecWidth);
37283728

IGC/Compiler/CISACodeGen/CoalescingEngine.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,10 +1039,10 @@ namespace IGC
10391039
while (index < numOperands)
10401040
{
10411041
Value* val = GetPayloadElementToValueMapping(inst, index);
1042-
1043-
if (!isa<Constant>(val) && GetValueCCTupleMapping(val))
1042+
CoalescingEngine::CCTuple* ccTupleCheck = GetValueCCTupleMapping(val);
1043+
if (!isa<Constant>(val) && ccTupleCheck)
10441044
{
1045-
ccTuple = GetValueCCTupleMapping(val);
1045+
ccTuple = ccTupleCheck;
10461046

10471047
Value* valRoot = getRegRoot(val);
10481048
IGC_ASSERT(valRoot);

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14838,9 +14838,9 @@ void EmitPass::emitTypedWrite(llvm::Instruction* pInsn)
1483814838
void EmitPass::emitThreadGroupNamedBarriersInit(llvm::Instruction* inst)
1483914839
{
1484014840
CVariable* barrierID = m_currShader->ImmToVariable(
14841-
dyn_cast<llvm::ConstantInt>(inst->getOperand(0))->getSExtValue(), ISA_TYPE_UD);
14841+
cast<llvm::ConstantInt>(inst->getOperand(0))->getSExtValue(), ISA_TYPE_UD);
1484214842
CVariable* barrierCount = m_currShader->ImmToVariable(
14843-
dyn_cast<llvm::ConstantInt>(inst->getOperand(1))->getSExtValue(), ISA_TYPE_UD);
14843+
cast<llvm::ConstantInt>(inst->getOperand(1))->getSExtValue(), ISA_TYPE_UD);
1484414844

1484514845
m_encoder->NamedBarrier(EBARRIER_SIGNAL, barrierID, barrierCount);
1484614846
m_encoder->Push();
@@ -14849,7 +14849,7 @@ void EmitPass::emitThreadGroupNamedBarriersInit(llvm::Instruction* inst)
1484914849
void EmitPass::emitThreadGroupNamedBarriersBarrier(llvm::Instruction* inst)
1485014850
{
1485114851
CVariable* barrierID = m_currShader->ImmToVariable(
14852-
dyn_cast<llvm::ConstantInt>(inst->getOperand(0))->getSExtValue(), ISA_TYPE_UD);
14852+
cast<llvm::ConstantInt>(inst->getOperand(0))->getSExtValue(), ISA_TYPE_UD);
1485314853

1485414854
m_encoder->NamedBarrier(EBARRIER_WAIT, barrierID, nullptr);
1485514855
m_encoder->Push();
@@ -19805,7 +19805,7 @@ static void GetReductionOp(WaveOps op, Type* opndTy, uint64_t& identity, e_opcod
1980519805
case WaveOps::FMAX:
1980619806
opcode = EOPCODE_MAX;
1980719807
type = getISAType(opndTy);
19808-
identity = dyn_cast<ConstantFP>(ConstantFP::getInfinity(opndTy, true))->getValueAPF().bitcastToAPInt().getZExtValue();
19808+
identity = cast<ConstantFP>(ConstantFP::getInfinity(opndTy, true))->getValueAPF().bitcastToAPInt().getZExtValue();
1980919809
break;
1981019810
default:
1981119811
IGC_ASSERT(0);
@@ -20922,6 +20922,7 @@ void EmitPass::emitLscIntrinsicLoad(llvm::GenIntrinsicInst* inst)
2092220922
// Operand 2 - [immediate] data size, (LSC_DATA_SIZE enum)
2092320923
// Operand 3 - [immediate] vector size, (LSC_DATA_ELEMS enum)
2092420924
// Operand 4 - [immediate] cache options (LSC_CACHE_OPT enum)
20925+
IGC_ASSERT(inst);
2092520926
Value* Ptr = inst->getArgOperand(0);
2092620927

2092720928
PointerType* ptrType = cast<PointerType>(Ptr->getType());
@@ -20944,11 +20945,8 @@ void EmitPass::emitLscIntrinsicLoad(llvm::GenIntrinsicInst* inst)
2094420945

2094520946
LSC_CACHE_OPTS cacheOpts = translateLSCCacheControlsFromValue(inst->getOperand(4), true);
2094620947

20947-
if (inst)
20948-
{
20949-
if (auto Opts = setCacheOptionsForConstantBufferLoads(*inst))
20950-
cacheOpts = *Opts;
20951-
}
20948+
if (auto Opts = setCacheOptionsForConstantBufferLoads(*inst))
20949+
cacheOpts = *Opts;
2095220950

2095320951
emitLscIntrinsicFragments(m_destination, dataSize, dataElems, immOffset,
2095420952
[&] (CVariable* gatherDst, int fragIx, LSC_DATA_ELEMS fragElems, int fragImmOffset) {

IGC/Compiler/CISACodeGen/MemOpt.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2669,8 +2669,7 @@ AddressModel LdStInfo::getAddressModel(CodeGenContext* Ctx) const
26692669
IGC_ASSERT_MESSAGE(false, "Not support yet");
26702670
}
26712671

2672-
PointerType* PTy = dyn_cast<PointerType>(Ptr->getType());
2673-
IGC_ASSERT(PTy);
2672+
PointerType* PTy = cast<PointerType>(Ptr->getType());
26742673
const uint32_t AS = PTy->getPointerAddressSpace();
26752674
uint bufferIndex = 0;
26762675
bool directIndexing = false;
@@ -2807,7 +2806,7 @@ void LdStCombine::getOrCreateElements(
28072806
if (!IEI || !isa<ConstantInt>(IEI->getOperand(2))) {
28082807
break;
28092808
}
2810-
ConstantInt* CInt = dyn_cast<ConstantInt>(IEI->getOperand(2));
2809+
ConstantInt* CInt = cast<ConstantInt>(IEI->getOperand(2));
28112810
uint32_t idx = (uint32_t)CInt->getZExtValue();
28122811

28132812
// Make sure the last IEI will be recorded if an element is

IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3490,7 +3490,7 @@ namespace IGC
34903490
MetaDataUtils* pMdUtils,
34913491
SIMDMode simdMode)
34923492
{
3493-
IGC_ASSERT(pShader != nullptr);
3493+
IGC_ASSERT(pShader && pKernel);
34943494
pShader->FillKernel(simdMode);
34953495
SProgramOutput* pOutput = pShader->ProgramOutput();
34963496

@@ -3501,14 +3501,13 @@ namespace IGC
35013501
// ignoring case for multi-simd compilation, or if kernel has stackcalls
35023502
if (!((ctx->m_DriverInfo.sendMultipleSIMDModes() || ctx->m_enableSimdVariantCompilation)
35033503
&& (ctx->getModuleMetaData()->csInfo.forcedSIMDSize == 0)) &&
3504-
pKernel.get() != nullptr &&
35053504
!(program->HasStackCalls() || program->IsIntelSymbolTableVoidProgram()))
35063505
{
35073506
isWorstThanPrv =
35083507
!ctx->m_retryManager.IsBetterThanPrevious(pKernel.get());
35093508
}
35103509

3511-
auto pPreviousKernel = ctx->m_retryManager.GetPrevious(&*pKernel);
3510+
auto pPreviousKernel = ctx->m_retryManager.GetPrevious(pKernel.get());
35123511

35133512
if(pPreviousKernel &&
35143513
exceedMaxScratchUse(program, ctx))
@@ -3551,7 +3550,7 @@ namespace IGC
35513550
MetaDataUtils* pMdUtils,
35523551
SIMDMode simdMode)
35533552
{
3554-
IGC_ASSERT_EXIT(ctx != nullptr && pShader != nullptr && pFunc != nullptr && pMdUtils != nullptr);
3553+
IGC_ASSERT_EXIT(ctx && pShader && pKernel && pFunc && pMdUtils);
35553554

35563555
CShaderProgram::UPtr pSelectedKernel;
35573556
switch (auto retryType = NeedsRetry(ctx, pShader, pKernel, pFunc, pMdUtils, simdMode))
@@ -3611,7 +3610,7 @@ namespace IGC
36113610
case RetryType::NO_Retry:
36123611
{
36133612
// Save the shader program to the state processor to be handled later
3614-
if (!pSelectedKernel && pKernel)
3613+
if (!pSelectedKernel)
36153614
{
36163615
pSelectedKernel = std::move(pKernel);
36173616
}

IGC/Compiler/CISACodeGen/PatternMatchPass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,7 +2390,7 @@ namespace IGC
23902390
if (isa<ConstantInt>(V))
23912391
{
23922392
// only 16-bit int immediate is supported
2393-
APInt val = dyn_cast<ConstantInt>(V)->getValue();
2393+
APInt val = cast<ConstantInt>(V)->getValue();
23942394
return val.sge(SHRT_MIN) && val.sle(SHRT_MAX);
23952395
}
23962396
// Trace the def-use chain and return the first non up-cast related value.
@@ -4529,8 +4529,8 @@ namespace IGC
45294529
Value* src2 = I.getOperand(2); // weight. operand(4) is its precision
45304530
//ConstantInt* pa = dyn_cast<ConstantInt>(I.getOperand(3));
45314531
//ConstantInt* pb = dyn_cast<ConstantInt>(I.getOperand(4));
4532-
ConstantInt* sdepth = dyn_cast<ConstantInt>(I.getOperand(5));
4533-
ConstantInt* rcount = dyn_cast<ConstantInt>(I.getOperand(6));
4532+
ConstantInt* sdepth = cast<ConstantInt>(I.getOperand(5));
4533+
ConstantInt* rcount = cast<ConstantInt>(I.getOperand(6));
45344534
int SD = (int)sdepth->getZExtValue();
45354535
int RC = (int)rcount->getZExtValue();
45364536

IGC/Compiler/CISACodeGen/SLMConstProp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ bool SLMConstProp::isLinearFuncOfLocalIds(SymExpr* SE)
762762
sysVal->getIntrinsicID() != GenISAIntrinsic::GenISA_DCL_SystemValue) {
763763
return false;
764764
}
765-
SGVUsage usage = static_cast<SGVUsage>(dyn_cast<ConstantInt>(sysVal->getOperand(0))->getZExtValue());
765+
SGVUsage usage = static_cast<SGVUsage>(cast<ConstantInt>(sysVal->getOperand(0))->getZExtValue());
766766
if (usage != THREAD_ID_IN_GROUP_X && usage != THREAD_ID_IN_GROUP_Y && usage != THREAD_ID_IN_GROUP_Z)
767767
{
768768
return false;

IGC/Compiler/CISACodeGen/VectorPreProcess.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ bool VectorPreProcess::isValueCreatedOnlyByIEI(Value* V, InsertElementInst** IEI
427427
{
428428
return false;
429429
}
430-
ConstantInt* CInt = dyn_cast<ConstantInt>(IEI->getOperand(2));
430+
ConstantInt* CInt = cast<ConstantInt>(IEI->getOperand(2));
431431
uint32_t idx = (uint32_t)CInt->getZExtValue();
432432

433433
// Make sure the last IEI will be recorded if an element is
@@ -454,7 +454,7 @@ bool VectorPreProcess::isValueUsedOnlyByEEI(Value* V, ExtractElementInst** EEIns
454454
{
455455
return false;
456456
}
457-
ConstantInt* CInt = dyn_cast<ConstantInt>(EEI->getOperand(1));
457+
ConstantInt* CInt = cast<ConstantInt>(EEI->getOperand(1));
458458
uint32_t idx = (uint32_t)CInt->getZExtValue();
459459

460460
// Quit if there are multiple extract from the same index.

IGC/Compiler/CISACodeGen/helper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,7 +1796,7 @@ namespace IGC
17961796

17971797
llvm::InsertElementInst* ie = llvm::dyn_cast<llvm::InsertElementInst>(inst);
17981798
while (ie != NULL) {
1799-
int64_t iOffset = llvm::dyn_cast<llvm::ConstantInt>(ie->getOperand(2))->getSExtValue();
1799+
int64_t iOffset = llvm::cast<llvm::ConstantInt>(ie->getOperand(2))->getSExtValue();
18001800
IGC_ASSERT(iOffset >= 0);
18011801
if (iOffset == pos) {
18021802
return ie->getOperand(1);
@@ -1825,7 +1825,7 @@ namespace IGC
18251825
int count = 0;
18261826
llvm::InsertElementInst* ie = llvm::dyn_cast<llvm::InsertElementInst>(inst);
18271827
while (ie != NULL) {
1828-
int64_t iOffset = llvm::dyn_cast<llvm::ConstantInt>(ie->getOperand(2))->getSExtValue();
1828+
int64_t iOffset = llvm::cast<llvm::ConstantInt>(ie->getOperand(2))->getSExtValue();
18291829
IGC_ASSERT(iOffset >= 0);
18301830
if (elem[iOffset] == NULL) {
18311831
elem[iOffset] = ie->getOperand(1);

IGC/Compiler/CodeGenContext.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ namespace IGC
262262
}
263263
}
264264

265+
IGC_ASSERT(currentShader);
266+
IGC_ASSERT(previousShader);
267+
265268
// Check if current shader has more than 200% of previous spill size
266269
bool spillSizeBigger =
267270
currentShader->m_spillSize > previousShader->m_spillSize << 1;

IGC/Compiler/CustomLoopOpt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ void CustomLoopVersioning::hoistSeg2Invariant(Loop* loop,
319319

320320
for (auto* UI : fmul->users())
321321
{
322-
IntrinsicInst* intrin = dyn_cast<IntrinsicInst>(UI);
322+
IntrinsicInst* intrin = cast<IntrinsicInst>(UI);
323323
if (intrin->getIntrinsicID() == Intrinsic::fabs &&
324324
intrin->hasOneUse())
325325
{

IGC/Compiler/CustomSafeOptPass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,7 +2246,7 @@ void TrivialLocalMemoryOpsElimination::findNextThreadGroupBarrierInst(Instructio
22462246
auto nextInst = I.getNextNonDebugInstruction();
22472247
if (isa<GenIntrinsicInst>(nextInst))
22482248
{
2249-
GenIntrinsicInst* II = dyn_cast<GenIntrinsicInst>(nextInst);
2249+
GenIntrinsicInst* II = cast<GenIntrinsicInst>(nextInst);
22502250
if (II->getIntrinsicID() == GenISAIntrinsic::GenISA_threadgroupbarrier)
22512251
{
22522252
m_LocalFencesBariersToRemove.push_back(dyn_cast<CallInst>(nextInst));
@@ -2325,7 +2325,7 @@ void TrivialLocalMemoryOpsElimination::visitCallInst(CallInst& I)
23252325

23262326
if (isa<GenIntrinsicInst>(I))
23272327
{
2328-
GenIntrinsicInst* II = dyn_cast<GenIntrinsicInst>(&I);
2328+
GenIntrinsicInst* II = cast<GenIntrinsicInst>(&I);
23292329
if (II->getIntrinsicID() == GenISAIntrinsic::GenISA_memoryfence)
23302330
{
23312331
if (isLocalBarrier(I))

IGC/Compiler/CustomUnsafeOptPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1992,7 +1992,7 @@ void CustomUnsafeOptPass::matchMixOperation(llvm::BinaryOperator& I)
19921992
if ((fSubOpIdx == 1) ||
19931993
((fSubOpIdx == 0) && !llvm::isa<llvm::ConstantFP>(I.getOperand(1))))
19941994
{
1995-
llvm::ConstantFP* fSubOpConst = llvm::dyn_cast<llvm::ConstantFP>(I.getOperand(fSubOpIdx));
1995+
llvm::ConstantFP* fSubOpConst = llvm::cast<llvm::ConstantFP>(I.getOperand(fSubOpIdx));
19961996
const APFloat& APF = fSubOpConst->getValueAPF();
19971997
bool isInf = APF.isInfinity();
19981998
bool isNaN = APF.isNaN();

IGC/Compiler/Legalizer/PeepholeTypeLegalizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ void PeepholeTypeLegalizer::legalizePhiInstruction(Instruction& I)
207207
unsigned quotient = 0, promoteToInt = 0;
208208
promoteInt(srcWidth, quotient, promoteToInt, DL->getLargestLegalIntTypeSizeInBits());
209209

210-
PHINode* oldPhi = dyn_cast<PHINode>(&I);
210+
PHINode* oldPhi = cast<PHINode>(&I);
211211
Value* result = nullptr;
212212

213213
if (quotient > 1)

IGC/Compiler/Optimizer/OpenCLPasses/AlignmentAnalysis/AlignmentAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ bool AlignmentAnalysis::processInstruction(llvm::Instruction* I)
187187
// If a pointer is specifically given an 'align' field in the MD, use it.
188188
MDNode* alignmentMD = I->getMetadata("align");
189189
if (alignmentMD)
190-
newAlign = (alignment_t)mdconst::dyn_extract<ConstantInt>(alignmentMD->getOperand(0))->getZExtValue();
190+
newAlign = (alignment_t)mdconst::extract<ConstantInt>(alignmentMD->getOperand(0))->getZExtValue();
191191
}
192192
if (!newAlign)
193193
{

IGC/Compiler/Optimizer/OpenCLPasses/JointMatrixFuncsResolutionPass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,13 +1353,13 @@ Value *JointMatrixFuncsResolutionPass::ResolveGeneric(Instruction *OldInst)
13531353

13541354
if (GetElementPtrInst *NewGEPI = dyn_cast<GetElementPtrInst>(NewInst))
13551355
{
1356-
GetElementPtrInst *OldGEPI = dyn_cast<GetElementPtrInst>(OldInst);
1356+
GetElementPtrInst *OldGEPI = cast<GetElementPtrInst>(OldInst);
13571357
NewGEPI->setSourceElementType(ResolveTypes(OldGEPI->getSourceElementType()));
13581358
NewGEPI->setResultElementType(ResolveTypes(OldGEPI->getResultElementType()));
13591359
}
13601360
else if (AllocaInst *NewAlloca = dyn_cast<AllocaInst>(NewInst))
13611361
{
1362-
AllocaInst *OldAlloca = dyn_cast<AllocaInst>(OldInst);
1362+
AllocaInst *OldAlloca = cast<AllocaInst>(OldInst);
13631363
NewAlloca->setAllocatedType(ResolveTypes(OldAlloca->getAllocatedType()));
13641364
}
13651365

IGC/Compiler/Optimizer/OpenCLPasses/KernelArgs.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,8 +1089,13 @@ KernelArgs::KernelArgs(const Function& F, const DataLayout* DL, MetaDataUtils* p
10891089
const unsigned int numExplicitArgs = F.arg_size() - numImplicitArgs - numRuntimeValue;
10901090
llvm::Function::const_arg_iterator funcArg = F.arg_begin();
10911091

1092-
auto it = moduleMD->FuncMD.find(const_cast<Function*>(&F));
1093-
FunctionMetaData* funcMD = it != moduleMD->FuncMD.end() ? &it->second : nullptr;
1092+
FunctionMetaData* funcMD = nullptr;
1093+
if (moduleMD) {
1094+
auto it = moduleMD->FuncMD.find(const_cast<Function*>(&F));
1095+
if (it != moduleMD->FuncMD.end()) {
1096+
funcMD = &it->second;
1097+
}
1098+
}
10941099

10951100
FunctionInfoMetaDataHandle funcInfoMD = pMdUtils->getFunctionsInfoItem(const_cast<llvm::Function*>(&F));
10961101
// Explicit function args
@@ -1100,7 +1105,7 @@ KernelArgs::KernelArgs(const Function& F, const DataLayout* DL, MetaDataUtils* p
11001105
if (moduleMD && moduleMD->UseBindlessImage)
11011106
{
11021107
// Check for bindless images which require allocation
1103-
FunctionMetaData* funcMD = &moduleMD->FuncMD[const_cast<llvm::Function*>(&F)];
1108+
funcMD = &moduleMD->FuncMD[const_cast<llvm::Function*>(&F)];
11041109
ResourceAllocMD* resAllocMD = &funcMD->resAllocMD;
11051110
if (resAllocMD->argAllocMDList.size() > funcArg->getArgNo())
11061111
{

IGC/Compiler/Optimizer/OpenCLPasses/LSCFuncs/LSCFuncsResolution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ Constant *LSCFuncsResolution::getCacheControlOpts(int i, bool isAtomic)
859859

860860
if (isAtomic)
861861
{
862-
ConstantInt* ci = dyn_cast<ConstantInt>(c);
862+
ConstantInt* ci = cast<ConstantInt>(c);
863863
switch (ci->getZExtValue())
864864
{
865865
case LSC_L1DEF_L3DEF:

IGC/Compiler/Optimizer/OpenCLPasses/NamedBarriers/NamedBarriersResolution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void NamedBarriersResolution::HandleNamedBarrierSyncHW(CallInst& NBarrierSyncCal
242242
Value* trueValue = IRB.getInt1(true);
243243
Value* falseValue = IRB.getInt1(false);
244244

245-
ConstantInt* memFenceType = dyn_cast<ConstantInt>(NBarrierSyncCall.getArgOperand(1));
245+
ConstantInt* memFenceType = cast<ConstantInt>(NBarrierSyncCall.getArgOperand(1));
246246
// LOCAL = 1
247247
// GLOBAL = 2
248248
Value* isGlobal = ( (int)memFenceType->getValue().getSExtValue() & 2 ) == 2 ? trueValue : falseValue;

IGC/Compiler/Optimizer/OpenCLPasses/StatelessToStateful/StatelessToStateful.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ void StatelessToStateful::promoteIntrinsic(InstructionInfo& II)
587587
}
588588
}
589589

590+
IGC_ASSERT(statefulInst);
590591
statefulInst->setDebugLoc(DL);
591592
I->replaceAllUsesWith(statefulInst);
592593
I->eraseFromParent();

IGC/Compiler/Optimizer/Scalarizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ void ScalarizeFunction::scalarizeInstruction(GetElementPtrInst* GI)
10051005
width = int_cast<unsigned>(dyn_cast<IGCLLVM::FixedVectorType>(baseValue->getType())->getNumElements());
10061006
// Obtain the scalarized operands
10071007
obtainScalarizedValues(operand1, NULL, baseValue, GI);
1008-
ptrTy = dyn_cast<VectorType>(baseValue->getType())->getElementType();
1008+
ptrTy = cast<VectorType>(baseValue->getType())->getElementType();
10091009
}
10101010
else
10111011
{

IGC/Compiler/PromoteStatelessToBindless.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ void PromoteStatelessToBindless::PromoteStatelessToBindlessBuffers(Function& F)
197197
// Get the base bindless pointer
198198
IGCIRBuilder<> builder(accessInst);
199199
Value* resourcePtr = IGC::GetBufferOperand(accessInst);
200+
IGC_ASSERT(resourcePtr);
200201
unsigned bindlessAS = IGC::EncodeAS4GFXResource(*UndefValue::get(builder.getInt32Ty()), IGC::BINDLESS);
201202
PointerType* basePointerType = PointerType::get(IGCLLVM::getNonOpaquePtrEltTy(resourcePtr->getType()), bindlessAS);
202203
Value* bufferOffset = builder.CreatePtrToInt(resourcePtr, builder.getInt32Ty());

IGC/GenISAIntrinsics/GenIntrinsics.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,8 @@ std::string GenISAIntrinsic::getName(GenISAIntrinsic::ID id, ArrayRef<Type*> Tys
442442
#include "IntrinsicGenISA.gen"
443443
#undef GET_INTRINSIC_NAME_TABLE
444444
};
445+
446+
IGC_ASSERT(id < ARRAY_COUNT(Table));
445447
if (Tys.empty())
446448
return Table[id];
447449
std::string Result(Table[id]);

0 commit comments

Comments
 (0)