Skip to content

Commit f181a1a

Browse files
[SYCL][NFC] Fixed static analysis warnings in LowerESIMD.cpp
1 parent bc8f0a4 commit f181a1a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

llvm/lib/SYCLLowerIR/LowerESIMD.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ template <typename Ty = llvm::Value> Ty *getVal(llvm::Metadata *M) {
579579
static llvm::MDNode *getSLMSizeMDNode(llvm::Function *F) {
580580
llvm::NamedMDNode *Nodes =
581581
F->getParent()->getNamedMetadata(GENX_KERNEL_METADATA);
582+
assert(Nodes && "invalid genx.kernels metadata");
582583
for (auto Node : Nodes->operands()) {
583584
if (Node->getNumOperands() >= 4 && getVal(Node->getOperand(0)) == F)
584585
return Node;
@@ -626,6 +627,8 @@ static void translateSLMInit(CallInst &CI) {
626627
static void translatePackMask(CallInst &CI) {
627628
using Demangler = id::ManglingParser<SimpleAllocator>;
628629
Function *F = CI.getCalledFunction();
630+
assert(F && "function to translate is invalid");
631+
629632
StringRef MnglName = F->getName();
630633
Demangler Parser(MnglName.begin(), MnglName.end());
631634
id::Node *AST = Parser.parse();
@@ -665,6 +668,7 @@ static void translatePackMask(CallInst &CI) {
665668
static void translateUnPackMask(CallInst &CI) {
666669
using Demangler = id::ManglingParser<SimpleAllocator>;
667670
Function *F = CI.getCalledFunction();
671+
assert(F && "function to translate is invalid");
668672
StringRef MnglName = F->getName();
669673
Demangler Parser(MnglName.begin(), MnglName.end());
670674
id::Node *AST = Parser.parse();
@@ -729,7 +733,7 @@ static void translateGetValue(CallInst &CI) {
729733
IRBuilder<> Builder(&CI);
730734
auto SV =
731735
Builder.CreatePtrToInt(opnd, IntegerType::getInt32Ty(CI.getContext()));
732-
auto *SI = dyn_cast<CastInst>(SV);
736+
auto *SI = cast<CastInst>(SV);
733737
SI->setDebugLoc(CI.getDebugLoc());
734738
CI.replaceAllUsesWith(SI);
735739
}
@@ -1018,6 +1022,7 @@ static void createESIMDIntrinsicArgs(const ESIMDIntrinDesc &Desc,
10181022
static void translateESIMDIntrinsicCall(CallInst &CI) {
10191023
using Demangler = id::ManglingParser<SimpleAllocator>;
10201024
Function *F = CI.getCalledFunction();
1025+
assert(F && "function to translate is invalid");
10211026
StringRef MnglName = F->getName();
10221027
Demangler Parser(MnglName.begin(), MnglName.end());
10231028
id::Node *AST = Parser.parse();
@@ -1039,7 +1044,7 @@ static void translateESIMDIntrinsicCall(CallInst &CI) {
10391044
if (!Desc.isValid()) // TODO remove this once all intrinsics are supported
10401045
return;
10411046

1042-
auto *FTy = CI.getCalledFunction()->getFunctionType();
1047+
auto *FTy = F->getFunctionType();
10431048
std::string Suffix = getESIMDIntrinSuffix(FE, FTy, Desc.SuffixRule);
10441049
auto ID = GenXIntrinsic::lookupGenXIntrinsicID(
10451050
GenXIntrinsic::getGenXIntrinsicPrefix() + Desc.GenXSpelling + Suffix);

0 commit comments

Comments
 (0)