llvm.org GIT mirror llvm / 6944e4a
AMDGPU: Force skips around traps git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362852 91177308-0d34-0410-b5e6-96231b3b80d8 Matt Arsenault 4 months ago
2 changed file(s) with 59 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
24902490 // given the typical code patterns.
24912491 if (Opcode == AMDGPU::S_SENDMSG || Opcode == AMDGPU::S_SENDMSGHALT ||
24922492 Opcode == AMDGPU::EXP || Opcode == AMDGPU::EXP_DONE ||
2493 Opcode == AMDGPU::DS_ORDERED_COUNT)
2493 Opcode == AMDGPU::DS_ORDERED_COUNT || Opcode == AMDGPU::S_TRAP)
24942494 return true;
24952495
24962496 if (MI.isCall() || MI.isInlineAsm())
0 ; RUN: llc -mtriple=amdgcn--amdhsa -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=GCN -check-prefix=HSA-TRAP %s
1
2 ; FIXME: merge with trap.ll
3
4 ; An s_cbranch_execnz is required to avoid trapping if all lanes are 0
5 ; GCN-LABEL: {{^}}trap_divergent_branch:
6 ; GCN: s_and_saveexec_b64
7 ; GCN: s_cbranch_execz [[ENDPGM:BB[0-9]+_[0-9]+]]
8 ; GCN: s_branch [[TRAP:BB[0-9]+_[0-9]+]]
9 ; GCN: [[ENDPGM]]:
10 ; GCN-NEXT: s_endpgm
11 ; GCN: [[TRAP]]:
12 ; GCN: s_trap 2
13 ; GCN-NEXT: s_endpgm
14 define amdgpu_kernel void @trap_divergent_branch(i32 addrspace(1)* nocapture readonly %arg) {
15 %id = call i32 @llvm.amdgcn.workitem.id.x()
16 %gep = getelementptr inbounds i32, i32 addrspace(1)* %arg, i32 %id
17 %divergent.val = load i32, i32 addrspace(1)* %gep
18 %cmp = icmp eq i32 %divergent.val, 0
19 br i1 %cmp, label %bb, label %end
20
21 bb:
22 call void @llvm.trap()
23 br label %end
24
25 end:
26 ret void
27 }
28
29 ; GCN-LABEL: {{^}}debugtrap_divergent_branch:
30 ; GCN: s_and_saveexec_b64
31 ; GCN: s_cbranch_execz [[ENDPGM:BB[0-9]+_[0-9]+]]
32 ; GCN: BB{{[0-9]+}}_{{[0-9]+}}:
33 ; GCN: s_trap 3
34 ; GCN-NEXT: [[ENDPGM]]:
35 ; GCN-NEXT: s_endpgm
36 define amdgpu_kernel void @debugtrap_divergent_branch(i32 addrspace(1)* nocapture readonly %arg) {
37 %id = call i32 @llvm.amdgcn.workitem.id.x()
38 %gep = getelementptr inbounds i32, i32 addrspace(1)* %arg, i32 %id
39 %divergent.val = load i32, i32 addrspace(1)* %gep
40 %cmp = icmp eq i32 %divergent.val, 0
41 br i1 %cmp, label %bb, label %end
42
43 bb:
44 call void @llvm.debugtrap()
45 br label %end
46
47 end:
48 ret void
49 }
50
51 declare void @llvm.trap() #0
52 declare void @llvm.debugtrap() #1
53 declare i32 @llvm.amdgcn.workitem.id.x() #2
54
55 attributes #0 = { nounwind noreturn }
56 attributes #1 = { nounwind }
57 attributes #2 = { nounwind readnone speculatable }