[llvm] 1f8d3fd - [Verifier] Check byval/etc type when comparing ABI attributes
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 20 11:19:57 PDT 2021
Author: Nikita Popov
Date: 2021-07-20T20:19:47+02:00
New Revision: 1f8d3fd42b7c183f8fef438255e10e4e0f71d7d4
URL: https://github.com/llvm/llvm-project/commit/1f8d3fd42b7c183f8fef438255e10e4e0f71d7d4
DIFF: https://github.com/llvm/llvm-project/commit/1f8d3fd42b7c183f8fef438255e10e4e0f71d7d4.diff
LOG: [Verifier] Check byval/etc type when comparing ABI attributes
For musttail calls, ABI attributes between the function and the
musttail call must match. The current check discards the type of
type attributes like byval, which means that it will consider
byval(i32) and byval(i64) (or similar) as compatible.
I assume this is a leftover from before these attributes had a
type argument. Ran into this while trying to tighten an assertion
in AttrBuilder.
Differential Revision: https://reviews.llvm.org/D105841
Added:
Modified:
llvm/lib/IR/Verifier.cpp
llvm/test/Verifier/musttail-invalid.ll
Removed:
################################################################################
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index c86536f505f16..758205a39eb32 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -3323,8 +3323,9 @@ static AttrBuilder getParameterABIAttributes(int I, AttributeList Attrs) {
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
index 32d86ba746055..64a378c3767da 100644
--- a/llvm/test/Verifier/musttail-invalid.ll
+++ b/llvm/test/Verifier/musttail-invalid.ll
@@ -46,6 +46,13 @@ define void @mismatched_byval({ i32 }* byval({ i32 }) %a) {
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
More information about the llvm-commits
mailing list