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 @@ -3323,8 +3323,9 @@ Attribute::ByRef}; AttrBuilder Copy; for (auto AK : ABIAttrs) { - if (Attrs.hasParamAttribute(I, AK)) - Copy.addAttribute(AK); + Attribute Attr = Attrs.getParamAttributes(I).getAttribute(AK); + if (Attr.isValid()) + Copy.addAttribute(Attr); } // `align` is ABI-affecting only in combination with `byval` or `byref`. diff --git a/llvm/test/Verifier/musttail-invalid.ll b/llvm/test/Verifier/musttail-invalid.ll --- a/llvm/test/Verifier/musttail-invalid.ll +++ b/llvm/test/Verifier/musttail-invalid.ll @@ -46,6 +46,13 @@ ret void } +declare void @mismatched_byval_callee2(ptr byval(i32)) +define void @mismatched_byval2(ptr byval(i64) %a) { +; CHECK: mismatched ABI impacting function attributes + musttail call void @mismatched_byval_callee2(ptr byval(i32) %a) + ret void +} + declare void @mismatched_inreg_callee(i32 inreg) define void @mismatched_inreg(i32 %a) { ; CHECK: mismatched ABI impacting function attributes