diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 592bb6aa90613..e17e7fafa6b6f 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -3632,8 +3632,11 @@ void Verifier::visitCallBase(CallBase &Call) { Check(Callee->getValueType() == FTy, "Intrinsic called with incompatible signature", Call); + // Find the actual CC of the callee from the Module. + CallingConv::ID CalleeCC = Call.getParent()->getParent()->getParent() + ->getFunction(Call.getCalledFunction()->getName())->getCallingConv(); // Verify if the calling convention of the callee is callable. - Check(isCallableCC(Call.getCallingConv()), + Check(isCallableCC(CalleeCC), "calling convention does not permit calls", Call); // Disallow passing/returning values with alignment higher than we can diff --git a/llvm/test/Verifier/AMDGPU/kernel-recursivecall.ll b/llvm/test/Verifier/AMDGPU/kernel-recursivecall.ll new file mode 100755 index 0000000000000..34513fcdecccf --- /dev/null +++ b/llvm/test/Verifier/AMDGPU/kernel-recursivecall.ll @@ -0,0 +1,9 @@ +; RUN: not llvm-as %s -disable-output 2>&1 | FileCheck %s + +define amdgpu_kernel void @kernel(ptr addrspace(1) %out, i32 %n) { +entry: +; CHECK: calling convention does not permit calls +; CHECK-NEXT: call void @kernel(ptr addrspace(1) %out, i32 %n) + call void @kernel(ptr addrspace(1) %out, i32 %n) + ret void +}