Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions llvm/lib/IR/Verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6369,6 +6369,14 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
"VGPR arguments must not have the `inreg` attribute", &Call);
break;
}
case Intrinsic::amdgcn_init_exec_from_input: {
const Argument *Arg = dyn_cast<Argument>(Call.getOperand(0));
Check(Arg && Arg->hasInRegAttr(),
"only inreg arguments to the parent function are valid as inputs to "
"this intrinsic",
&Call);
break;
}
case Intrinsic::amdgcn_set_inactive_chain_arg: {
auto CallerCC = Call.getCaller()->getCallingConv();
switch (CallerCC) {
Expand Down
19 changes: 19 additions & 0 deletions llvm/test/Verifier/AMDGPU/intrinsic-amdgpu-init-exec-from-input.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; RUN: not llvm-as -o /dev/null 2>&1 %s | FileCheck %s

; Function Attrs: convergent nocallback nofree nounwind willreturn
declare void @llvm.amdgcn.init.exec.from.input(i32, i32 immarg) #0
attributes #0 = { convergent nocallback nofree nounwind willreturn }

; CHECK: only inreg arguments to the parent function are valid as inputs to this intrinsic
; CHECK-NEXT: call void @llvm.amdgcn.init.exec.from.input(i32 0, i32 0)
define amdgpu_ps void @init_exec_from_input_fail_immarg(i32 inreg %a, i32 %b) {
call void @llvm.amdgcn.init.exec.from.input(i32 0, i32 0)
ret void
}

; CHECK: only inreg arguments to the parent function are valid as inputs to this intrinsic
; CHECK-NEXT: call void @llvm.amdgcn.init.exec.from.input(i32 %b, i32 0)
define amdgpu_ps void @init_exec_from_input_fail_not_inreg(i32 inreg %a, i32 %b) {
call void @llvm.amdgcn.init.exec.from.input(i32 %b, i32 0)
ret void
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also test a case where it's not an argument (try one with a constant and one with an instruction)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I added another check for the case that the operand is an instruction!
Isn't the constant case covered by the first function?

Loading