@@ -579,6 +579,7 @@ template <typename Ty = llvm::Value> Ty *getVal(llvm::Metadata *M) {
579
579
static llvm::MDNode *getSLMSizeMDNode (llvm::Function *F) {
580
580
llvm::NamedMDNode *Nodes =
581
581
F->getParent ()->getNamedMetadata (GENX_KERNEL_METADATA);
582
+ assert (Nodes && " invalid genx.kernels metadata" );
582
583
for (auto Node : Nodes->operands ()) {
583
584
if (Node->getNumOperands () >= 4 && getVal (Node->getOperand (0 )) == F)
584
585
return Node;
@@ -626,6 +627,8 @@ static void translateSLMInit(CallInst &CI) {
626
627
static void translatePackMask (CallInst &CI) {
627
628
using Demangler = id::ManglingParser<SimpleAllocator>;
628
629
Function *F = CI.getCalledFunction ();
630
+ assert (F && " function to translate is invalid" );
631
+
629
632
StringRef MnglName = F->getName ();
630
633
Demangler Parser (MnglName.begin (), MnglName.end ());
631
634
id::Node *AST = Parser.parse ();
@@ -665,6 +668,7 @@ static void translatePackMask(CallInst &CI) {
665
668
static void translateUnPackMask (CallInst &CI) {
666
669
using Demangler = id::ManglingParser<SimpleAllocator>;
667
670
Function *F = CI.getCalledFunction ();
671
+ assert (F && " function to translate is invalid" );
668
672
StringRef MnglName = F->getName ();
669
673
Demangler Parser (MnglName.begin (), MnglName.end ());
670
674
id::Node *AST = Parser.parse ();
@@ -729,7 +733,7 @@ static void translateGetValue(CallInst &CI) {
729
733
IRBuilder<> Builder (&CI);
730
734
auto SV =
731
735
Builder.CreatePtrToInt (opnd, IntegerType::getInt32Ty (CI.getContext ()));
732
- auto *SI = dyn_cast <CastInst>(SV);
736
+ auto *SI = cast <CastInst>(SV);
733
737
SI->setDebugLoc (CI.getDebugLoc ());
734
738
CI.replaceAllUsesWith (SI);
735
739
}
@@ -1018,6 +1022,7 @@ static void createESIMDIntrinsicArgs(const ESIMDIntrinDesc &Desc,
1018
1022
static void translateESIMDIntrinsicCall (CallInst &CI) {
1019
1023
using Demangler = id::ManglingParser<SimpleAllocator>;
1020
1024
Function *F = CI.getCalledFunction ();
1025
+ assert (F && " function to translate is invalid" );
1021
1026
StringRef MnglName = F->getName ();
1022
1027
Demangler Parser (MnglName.begin (), MnglName.end ());
1023
1028
id::Node *AST = Parser.parse ();
@@ -1039,7 +1044,7 @@ static void translateESIMDIntrinsicCall(CallInst &CI) {
1039
1044
if (!Desc.isValid ()) // TODO remove this once all intrinsics are supported
1040
1045
return ;
1041
1046
1042
- auto *FTy = CI. getCalledFunction () ->getFunctionType ();
1047
+ auto *FTy = F ->getFunctionType ();
1043
1048
std::string Suffix = getESIMDIntrinSuffix (FE, FTy, Desc.SuffixRule );
1044
1049
auto ID = GenXIntrinsic::lookupGenXIntrinsicID (
1045
1050
GenXIntrinsic::getGenXIntrinsicPrefix () + Desc.GenXSpelling + Suffix);
0 commit comments