Index: llvm/lib/IR/Function.cpp =================================================================== --- llvm/lib/IR/Function.cpp +++ llvm/lib/IR/Function.cpp @@ -1180,7 +1180,7 @@ case IITDescriptor::Quad: return !Ty->isFP128Ty(); case IITDescriptor::Integer: return !Ty->isIntegerTy(D.Integer_Width); case IITDescriptor::Vector: { - VectorType *VT = dyn_cast(Ty); + FixedVectorType *VT = dyn_cast(Ty); return !VT || VT->getNumElements() != D.Vector_Width || matchIntrinsicType(VT->getElementType(), Infos, ArgTys, DeferredChecks, IsDeferredCheck); @@ -1357,7 +1357,11 @@ case IITDescriptor::ScalableVecArgument: { if (!isa(Ty)) return true; - return matchIntrinsicType(Ty, Infos, ArgTys, DeferredChecks, + ScalableVectorType *STy = cast(Ty); + unsigned MinElts = STy->getMinNumElements(); + FixedVectorType *FVTy = + FixedVectorType::get(STy->getElementType(), MinElts); + return matchIntrinsicType(FVTy, Infos, ArgTys, DeferredChecks, IsDeferredCheck); } case IITDescriptor::VecOfBitcastsToInt: { Index: llvm/test/CodeGen/AArch64/sve-bad-intrinsics.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/AArch64/sve-bad-intrinsics.ll @@ -0,0 +1,13 @@ +; RUN: not llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t +; RUN: FileCheck --check-prefix=CHECK-ERROR %s <%t + +; CHECK-ERROR: error: invalid forward reference to function 'llvm.aarch64.sve.add.nxv2i64' with wrong type + +define <2 x i64> @add_i64_invalid(<2 x i1> %pg, <2 x i64> %a, <2 x i64> %b) { + %out = call <2 x i64> @llvm.aarch64.sve.add.nxv2i64(<2 x i1> %pg, + <2 x i64> %a, + <2 x i64> %b) + ret <2 x i64> %out +} + +declare @llvm.aarch64.sve.add.nxv2i64(, , )