From 60169ed613050252d074ca2fb9294a96aa7c4367 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Mon, 16 Sep 2019 00:33:00 +0000 Subject: [PATCH] AMDGPU/GlobalISel: Set type on vgpr live in special arguments Fixes assertion with workitem ID intrinsics used in non-kernel functions. llvm-svn: 371951 --- llvm/lib/Target/AMDGPU/SIISelLowering.cpp | 3 ++- .../AMDGPU/GlobalISel/llvm.amdgcn.workitem.id.ll | 27 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp index 73aa5cd..6607b1a 100644 --- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp +++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp @@ -1671,7 +1671,8 @@ static ArgDescriptor allocateVGPR32Input(CCState &CCInfo, unsigned Mask = ~0u, assert(Reg != AMDGPU::NoRegister); MachineFunction &MF = CCInfo.getMachineFunction(); - MF.addLiveIn(Reg, &AMDGPU::VGPR_32RegClass); + Register LiveInVReg = MF.addLiveIn(Reg, &AMDGPU::VGPR_32RegClass); + MF.getRegInfo().setType(LiveInVReg, LLT::scalar(32)); return ArgDescriptor::createRegister(Reg, Mask); } diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.workitem.id.ll b/llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.workitem.id.ll index 5d59c58..fb5f881 100644 --- a/llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.workitem.id.ll +++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.workitem.id.ll @@ -88,5 +88,32 @@ bb2: ret void } +; ALL-LABEL: {{^}}test_workitem_id_x_func: +; ALL: v_lshrrev_b32_e32 v2, 0, v2 +; ALL-NEXT: v_and_b32_e32 v2, 0x3ff, v2 +define void @test_workitem_id_x_func(i32 addrspace(1)* %out) #1 { + %id = call i32 @llvm.amdgcn.workitem.id.x() + store i32 %id, i32 addrspace(1)* %out + ret void +} + +; ALL-LABEL: {{^}}test_workitem_id_y_func: +; ALL: v_lshrrev_b32_e32 v2, 10, v2 +; ALL-NEXT: v_and_b32_e32 v2, 0x3ff, v2 +define void @test_workitem_id_y_func(i32 addrspace(1)* %out) #1 { + %id = call i32 @llvm.amdgcn.workitem.id.y() + store i32 %id, i32 addrspace(1)* %out + ret void +} + +; ALL-LABEL: {{^}}test_workitem_id_z_func: +; ALL: v_lshrrev_b32_e32 v2, 20, v2 +; ALL-NEXT: v_and_b32_e32 v2, 0x3ff, v2 +define void @test_workitem_id_z_func(i32 addrspace(1)* %out) #1 { + %id = call i32 @llvm.amdgcn.workitem.id.z() + store i32 %id, i32 addrspace(1)* %out + ret void +} + attributes #0 = { nounwind readnone } attributes #1 = { nounwind } -- 2.7.4