diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -3311,10 +3311,28 @@ "Return type cannot be x86_amx for indirect call!"); } - if (Function *F = Call.getCalledFunction()) - if (Intrinsic::ID ID = (Intrinsic::ID)F->getIntrinsicID()) + if (Function *F = Call.getCalledFunction()) { + if (Intrinsic::ID ID = F->getIntrinsicID()) visitIntrinsicCall(ID, Call); + // Verify that arguments have matching attributes as the callee's + // parameters. + for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) { + for (auto A : + {Attribute::ZExt, Attribute::SExt, Attribute::InAlloca, + Attribute::ByRef, Attribute::ByVal, Attribute::Preallocated, + Attribute::StructRet, Attribute::InReg}) { + if (F->hasParamAttribute(i, A)) { + StringRef Name = Attribute::getNameFromAttrKind(A); + Assert(Attrs.getParamAttributes(i).hasAttribute(A), + "argument to " + Name + " parameter requires " + Name + + " attribute", + Call); + } + } + } + } + // Verify that a callsite has at most one "deopt", at most one "funclet", at // most one "gc-transition", at most one "cfguardtarget", // and at most one "preallocated" operand bundle.