Skip to content

Commit f25ecf1

Browse files
committed
Add back int check. These are invalid for AMDGPU.
1 parent 79215be commit f25ecf1

File tree

2 files changed

+21
-34
lines changed

2 files changed

+21
-34
lines changed

llvm/lib/Target/AMDGPU/AMDGPUTargetVerifier.cpp

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -46,48 +46,29 @@ class AMDGPUTargetVerify : public TargetVerify {
4646
bool run(Function &F) override;
4747
};
4848

49-
static bool isShader(CallingConv::ID CC) {
50-
switch (CC) {
51-
case CallingConv::AMDGPU_VS:
52-
case CallingConv::AMDGPU_LS:
53-
case CallingConv::AMDGPU_HS:
54-
case CallingConv::AMDGPU_ES:
55-
case CallingConv::AMDGPU_GS:
56-
case CallingConv::AMDGPU_PS:
57-
case CallingConv::AMDGPU_CS_Chain:
58-
case CallingConv::AMDGPU_CS_ChainPreserve:
59-
case CallingConv::AMDGPU_CS:
60-
return true;
61-
default:
62-
return false;
63-
}
49+
static bool IsValidInt(const Type *Ty) {
50+
return Ty->isIntegerTy(1) ||
51+
Ty->isIntegerTy(8) ||
52+
Ty->isIntegerTy(16) ||
53+
Ty->isIntegerTy(32) ||
54+
Ty->isIntegerTy(64) ||
55+
Ty->isIntegerTy(128);
6456
}
6557

6658
bool AMDGPUTargetVerify::run(Function &F) {
67-
// Ensure shader calling convention returns void
68-
if (isShader(F.getCallingConv()))
69-
Check(F.getReturnType() == Type::getVoidTy(F.getContext()),
70-
"Shaders must return void");
7159

7260
for (auto &BB : F) {
7361

7462
for (auto &I : BB) {
7563

76-
if (auto *CI = dyn_cast<CallInst>(&I)) {
77-
// Ensure no kernel to kernel calls.
78-
CallingConv::ID CalleeCC = CI->getCallingConv();
79-
if (CalleeCC == CallingConv::AMDGPU_KERNEL) {
80-
CallingConv::ID CallerCC =
81-
CI->getParent()->getParent()->getCallingConv();
82-
Check(CallerCC != CallingConv::AMDGPU_KERNEL,
83-
"A kernel may not call a kernel", CI->getParent()->getParent());
84-
}
85-
86-
// Ensure chain intrinsics are followed by unreachables.
87-
if (CI->getIntrinsicID() == Intrinsic::amdgcn_cs_chain)
88-
Check(isa_and_present<UnreachableInst>(CI->getNextNode()),
89-
"llvm.amdgcn.cs.chain must be followed by unreachable", CI);
90-
}
64+
// Ensure integral types are valid: i8, i16, i32, i64, i128
65+
if (I.getType()->isIntegerTy())
66+
Check(IsValidInt(I.getType()), "Int type is invalid.", &I);
67+
for (unsigned i = 0; i < I.getNumOperands(); ++i)
68+
if (I.getOperand(i)->getType()->isIntegerTy())
69+
Check(IsValidInt(I.getOperand(i)->getType()),
70+
"Int type is invalid.", I.getOperand(i));
71+
9172
}
9273
}
9374

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
; RUN: llc -mtriple=amdgcn -mcpu=gfx900 -amdgpu-verify-tgt -o - < %s 2>&1 | FileCheck %s
2+
3+
define amdgpu_cs i65 @invalid_int() {
4+
; CHECK: Int type is invalid.
5+
ret i65 0
6+
}

0 commit comments

Comments
 (0)