1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

Verifier: Check byref address space for AMDGPU calling conventions

This commit is contained in:
Matt Arsenault 2020-06-29 10:37:15 -04:00
parent 413b267e1e
commit b7a779e13a
2 changed files with 18 additions and 1 deletions

View File

@ -2314,13 +2314,24 @@ void Verifier::visitFunction(const Function &F) {
Assert(!F.hasStructRetAttr(),
"Calling convention does not allow sret", &F);
if (F.getCallingConv() != CallingConv::SPIR_KERNEL) {
for (unsigned i = 0, e = F.arg_size(); i != e; ++i) {
const unsigned StackAS = DL.getAllocaAddrSpace();
unsigned i = 0;
for (const Argument &Arg : F.args()) {
Assert(!Attrs.hasParamAttribute(i, Attribute::ByVal),
"Calling convention disallows byval", &F);
Assert(!Attrs.hasParamAttribute(i, Attribute::Preallocated),
"Calling convention disallows preallocated", &F);
Assert(!Attrs.hasParamAttribute(i, Attribute::InAlloca),
"Calling convention disallows inalloca", &F);
if (Attrs.hasParamAttribute(i, Attribute::ByRef)) {
// FIXME: Should also disallow LDS and GDS, but we don't have the enum
// value here.
Assert(Arg.getType()->getPointerAddressSpace() != StackAS,
"Calling convention disallows stack byref", &F);
}
++i;
}
}

View File

@ -121,3 +121,9 @@ define amdgpu_kernel void @preallocated_as0_cc_amdgpu_kernel(i32* preallocated(i
define amdgpu_kernel void @inalloca_as0_cc_amdgpu_kernel(i32* inalloca %ptr) {
ret void
}
; CHECK: Calling convention disallows stack byref
; CHECK-NEXT: void (i32 addrspace(5)*)* @byref_as5_cc_amdgpu_kernel
define amdgpu_kernel void @byref_as5_cc_amdgpu_kernel(i32 addrspace(5)* byref(i32) %ptr) {
ret void
}