@@ -649,7 +649,12 @@ SPIRVType *LLVMToSPIRVBase::transSPIRVJointMatrixINTELType(
649649
650650 auto ParseInteger = [this ](StringRef Postfix) -> ConstantInt * {
651651 unsigned long long N = 0 ;
652- consumeUnsignedInteger (Postfix, 10 , N);
652+ if (consumeUnsignedInteger (Postfix, 10 , N)) {
653+ BM->getErrorLog ().checkError (
654+ false , SPIRVEC_InvalidLlvmModule,
655+ " TypeJointMatrixINTEL expects integer parameters" );
656+ return 0 ;
657+ }
653658 return getUInt32 (M, N);
654659 };
655660 std::vector<SPIRVValue *> Args;
@@ -2886,17 +2891,17 @@ void processAnnotationString(IntrinsicInst *II, std::string &AnnotationString) {
28862891 auto *StrValTy = StrVal->getType ();
28872892 if (StrValTy->isOpaquePointerTy ()) {
28882893 StringRef StrRef;
2889- getConstantStringInfo (dyn_cast<Constant>(StrVal), StrRef);
2890- AnnotationString += StrRef.str ();
2894+ if ( getConstantStringInfo (dyn_cast<Constant>(StrVal), StrRef))
2895+ AnnotationString += StrRef.str ();
28912896 if (auto *C = dyn_cast_or_null<Constant>(II->getArgOperand (4 )))
28922897 processOptionalAnnotationInfo (C, AnnotationString);
28932898 return ;
28942899 }
28952900 if (auto *GEP = dyn_cast<GetElementPtrInst>(StrVal)) {
28962901 if (auto *C = dyn_cast<Constant>(GEP->getOperand (0 ))) {
28972902 StringRef StrRef;
2898- getConstantStringInfo (C, StrRef);
2899- AnnotationString += StrRef.str ();
2903+ if ( getConstantStringInfo (C, StrRef))
2904+ AnnotationString += StrRef.str ();
29002905 }
29012906 }
29022907 if (auto *Cast = dyn_cast<BitCastInst>(II->getArgOperand (4 )))
@@ -3821,7 +3826,8 @@ SPIRVValue *LLVMToSPIRVBase::transIntrinsicInst(IntrinsicInst *II,
38213826 return nullptr ;
38223827 Constant *C = cast<Constant>(GEP->getOperand (0 ));
38233828 StringRef AnnotationString;
3824- getConstantStringInfo (C, AnnotationString);
3829+ if (!getConstantStringInfo (C, AnnotationString))
3830+ return nullptr ;
38253831
38263832 if (AnnotationString == kOCLBuiltinName ::FPGARegIntel) {
38273833 if (BM->isAllowedToUseExtension (ExtensionID::SPV_INTEL_fpga_reg))
@@ -4316,7 +4322,10 @@ void LLVMToSPIRVBase::transGlobalAnnotation(GlobalVariable *V) {
43164322 cast<GlobalVariable>(CS->getOperand (1 )->stripPointerCasts ());
43174323
43184324 StringRef AnnotationString;
4319- getConstantStringInfo (GV, AnnotationString);
4325+ if (!getConstantStringInfo (GV, AnnotationString)) {
4326+ assert (!" Annotation string missing" );
4327+ return ;
4328+ }
43204329 DecorationsInfoVec Decorations =
43214330 tryParseAnnotationString (BM, AnnotationString).MemoryAttributesVec ;
43224331
0 commit comments