diff --git a/IGC/AdaptorOCL/OCL/sp/spp_g8.cpp b/IGC/AdaptorOCL/OCL/sp/spp_g8.cpp index 29972082f65d..3e32b2347999 100644 --- a/IGC/AdaptorOCL/OCL/sp/spp_g8.cpp +++ b/IGC/AdaptorOCL/OCL/sp/spp_g8.cpp @@ -393,7 +393,10 @@ static std::string getTempFileName(const IGC::COpenCLKernel* kernel) EC = sys::fs::getPotentiallyUniqueTempFileName("ze", "elf", FileName); if (EC) { IGC::CodeGenContext* ctx = kernel->GetContext(); - ctx->EmitError((std::string("unable to create temporary file for kernel: ") + kernel->m_kernelInfo.m_kernelName).c_str(), nullptr); + if (ctx) + { + ctx->EmitError((std::string("unable to create temporary file for kernel: ") + kernel->m_kernelInfo.m_kernelName).c_str(), nullptr); + } return ""; } return FileName.c_str(); @@ -623,7 +626,10 @@ bool CGen8OpenCLProgram::GetZEBinary( } else { - ctx->EmitError((std::string("failed to open ELF file: ") + elfFileNameStr).c_str(), nullptr); + if (ctx) + { + ctx->EmitError((std::string("failed to open ELF file: ") + elfFileNameStr).c_str(), nullptr); + } elfTmpFilesError = true; // Handle this error at the end of this function break; } @@ -722,23 +728,32 @@ bool CGen8OpenCLProgram::GetZEBinary( else { ECfileOpen = MBOrErr.getError(); - ctx->EmitError("ELF linked file cannot be buffered", nullptr); - ctx->EmitError(ECfileOpen.message().c_str(), nullptr); + if (ctx) + { + ctx->EmitError("ELF linked file cannot be buffered", nullptr); + ctx->EmitError(ECfileOpen.message().c_str(), nullptr); + } elfTmpFilesError = true; // Handle this error also below } } else { ECfileOpen = errorToErrorCode(FDOrErr.takeError()); - ctx->EmitError("ELF linked file cannot be opened", nullptr); - ctx->EmitError(ECfileOpen.message().c_str(), nullptr); + if (ctx) + { + ctx->EmitError("ELF linked file cannot be opened", nullptr); + ctx->EmitError(ECfileOpen.message().c_str(), nullptr); + } elfTmpFilesError = true; // Handle this error also below } } else { - ctx->EmitError("ELF linked file size error", nullptr); + if (ctx) + { + ctx->EmitError("ELF linked file size error", nullptr); + } elfTmpFilesError = true; // Handle this error also below } } @@ -751,7 +766,10 @@ bool CGen8OpenCLProgram::GetZEBinary( #endif // LLVM_VERSION_MAJOR if (!linkErrStr.empty()) { - ctx->EmitError(linkErrStr.c_str(), nullptr); + if (ctx) + { + ctx->EmitError(linkErrStr.c_str(), nullptr); + } elfTmpFilesError = true; // Handle this error also below } } @@ -761,7 +779,10 @@ bool CGen8OpenCLProgram::GetZEBinary( if (elfTmpFilesError) { // Nothing to do with the linker when any error with temporary files occured. - ctx->EmitError("ZeBinary will not contain correct debug info due to an ELF temporary files error", nullptr); + if (ctx) + { + ctx->EmitError("ZeBinary will not contain correct debug info due to an ELF temporary files error", nullptr); + } retValue = false; } diff --git a/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp b/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp index 152f0d14901f..132d22289f9b 100644 --- a/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp +++ b/IGC/Compiler/CISACodeGen/EmitVISAPass.cpp @@ -20299,11 +20299,11 @@ void EmitPass::emitDpas(GenIntrinsicInst* GII, const SSource* Sources, const Dst } // float dpas uses short as bfloat16 for either input or dst. - ConstantInt* pa = dyn_cast(GII->getOperand(3)); // Activation's precision - ConstantInt* pb = dyn_cast(GII->getOperand(4)); // Weight's precision - ConstantInt* sdepth = dyn_cast(GII->getOperand(5)); - ConstantInt* rcount = dyn_cast(GII->getOperand(6)); - ConstantInt* dpasw = dyn_cast(GII->getOperand(7)); + ConstantInt* pa = cast(GII->getOperand(3)); // Activation's precision + ConstantInt* pb = cast(GII->getOperand(4)); // Weight's precision + ConstantInt* sdepth = cast(GII->getOperand(5)); + ConstantInt* rcount = cast(GII->getOperand(6)); + ConstantInt* dpasw = cast(GII->getOperand(7)); int PA = (int)pa->getSExtValue(); int PB = (int)pb->getSExtValue(); int SD = (int)sdepth->getSExtValue(); diff --git a/IGC/Metrics/IGCMetricImpl.cpp b/IGC/Metrics/IGCMetricImpl.cpp index 81240e0d98df..3e1ac4ee0f6f 100644 --- a/IGC/Metrics/IGCMetricImpl.cpp +++ b/IGC/Metrics/IGCMetricImpl.cpp @@ -954,16 +954,13 @@ namespace IGCMetrics llvm::MetadataAsValue* MDValue = makeMDasVal(New); llvm::Instruction* insertAfter = nullptr; - if (llvm::isa(New)) + if (auto arg = llvm::dyn_cast(New)) { - auto firstInstr = &*llvm::dyn_cast(New) - ->getParent()->getEntryBlock().begin(); - - insertAfter = firstInstr; + insertAfter = &*arg->getParent()->getEntryBlock().begin(); } - else if (llvm::isa(New)) + else if (auto instruction = llvm::dyn_cast(New)) { - insertAfter = llvm::dyn_cast(New); + insertAfter = instruction; } else { diff --git a/visa/GraphColor.cpp b/visa/GraphColor.cpp index 49ea61fc98f2..2e2d40e7f4c4 100644 --- a/visa/GraphColor.cpp +++ b/visa/GraphColor.cpp @@ -3298,7 +3298,7 @@ void Augmentation::markNonDefaultDstRgn(G4_INST *inst, G4_Operand *opnd) { } // Handle dst - if (inst->isCall() || inst->isCallerSave()) { + if (dst && (inst->isCall() || inst->isCallerSave())) { const G4_Declare *dcl = dst->getBase()->asRegVar()->getDeclare(); if (dcl && liveAnalysis.livenessClass(dcl->getRegFile())) { gra.setAugmentationMask(dcl->getRootDeclare(), diff --git a/visa/PointsToAnalysis.cpp b/visa/PointsToAnalysis.cpp index ad37044ca306..96aab0da8c77 100644 --- a/visa/PointsToAnalysis.cpp +++ b/visa/PointsToAnalysis.cpp @@ -439,6 +439,7 @@ void PointsToAnalysis::doPointsToAnalysis(FlowGraph &fg) { G4_VarBase *srcPtr = src->isSrcRegRegion() ? src->asSrcRegRegion()->getBase() : nullptr; + vASSERT(srcPtr); // case: arithmetic-op A0 A1 src1 // merge the two addr's points-to set together G4_RegVar *ptrVar = ptr->asRegVar(); diff --git a/visa/RADebug.cpp b/visa/RADebug.cpp index c8a928592257..71db5b454771 100644 --- a/visa/RADebug.cpp +++ b/visa/RADebug.cpp @@ -809,7 +809,7 @@ bool VerifyAugmentation::isClobbered(LiveRange *lr, std::string &msg) { if (oiDst && oiDst->isDstRegRegion() && oiDst->getTopDcl()) { unsigned oilb = 0, oirb = 0; auto oiLR = DclLRMap[oiDst->getTopDcl()]; - if (oiLR && !oiLR->getPhyReg()) + if (!oiLR->getPhyReg()) continue; oilb = oiLR->getPhyReg()->asGreg()->getRegNum() * diff --git a/visa/VisaToG4/TranslateSendLdStLegacy.cpp b/visa/VisaToG4/TranslateSendLdStLegacy.cpp index 63ee82666a2b..54928d741d46 100644 --- a/visa/VisaToG4/TranslateSendLdStLegacy.cpp +++ b/visa/VisaToG4/TranslateSendLdStLegacy.cpp @@ -1235,6 +1235,8 @@ int IR_Builder::translateVISADwordAtomicInst( ((atomicOp != ATOMIC_FADD) && (atomicOp != ATOMIC_FSUB)), "FADD/FSUB atomic operations are only supported on this devices"); + vASSERT(surface); + VISA_Exec_Size instExecSize = execSize; execSize = roundUpExecSize(execSize); @@ -1256,7 +1258,7 @@ int IR_Builder::translateVISADwordAtomicInst( unsigned len = 0; bool useHeader = - needsA32MsgHeader() && surface && isStatelessSurface(surface); + needsA32MsgHeader() && isStatelessSurface(surface); if (useHeader) { G4_Declare *dcl = createSendPayloadDcl(getGenxDataportIOSize(), Type_UD);