2018-05-17 00:19:34 +08:00
|
|
|
; RUN: llc -mtriple=amdgcn--amdhsa -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=HSA-TRAP %s
|
2017-02-10 10:15:29 +08:00
|
|
|
|
|
|
|
; RUN: llc -mtriple=amdgcn--amdhsa -mattr=+trap-handler -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=HSA-TRAP %s
|
|
|
|
; RUN: llc -mtriple=amdgcn--amdhsa -mattr=-trap-handler -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=NO-HSA-TRAP %s
|
|
|
|
; RUN: llc -mtriple=amdgcn--amdhsa -mattr=-trap-handler -verify-machineinstrs < %s 2>&1 | FileCheck -check-prefix=GCN -check-prefix=GCN-WARNING %s
|
|
|
|
|
|
|
|
; enable trap handler feature
|
|
|
|
; RUN: llc -mtriple=amdgcn-unknown-mesa3d -mattr=+trap-handler -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=NO-MESA-TRAP -check-prefix=TRAP-BIT -check-prefix=MESA-TRAP %s
|
|
|
|
; RUN: llc -mtriple=amdgcn-unknown-mesa3d -mattr=+trap-handler -verify-machineinstrs < %s 2>&1 | FileCheck -check-prefix=GCN -check-prefix=GCN-WARNING -check-prefix=TRAP-BIT %s
|
|
|
|
|
|
|
|
; disable trap handler feature
|
|
|
|
; RUN: llc -mtriple=amdgcn-unknown-mesa3d -mattr=-trap-handler -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=NO-MESA-TRAP -check-prefix=NO-TRAP-BIT -check-prefix=NOMESA-TRAP %s
|
|
|
|
; RUN: llc -mtriple=amdgcn-unknown-mesa3d -mattr=-trap-handler -verify-machineinstrs < %s 2>&1 | FileCheck -check-prefix=GCN -check-prefix=GCN-WARNING -check-prefix=NO-TRAP-BIT %s
|
|
|
|
|
|
|
|
; RUN: llc -march=amdgcn -verify-machineinstrs < %s 2>&1 | FileCheck -check-prefix=GCN -check-prefix=GCN-WARNING %s
|
2016-06-18 06:27:03 +08:00
|
|
|
|
|
|
|
declare void @llvm.trap() #0
|
2018-05-17 00:19:34 +08:00
|
|
|
declare void @llvm.debugtrap() #1
|
2017-02-10 10:15:29 +08:00
|
|
|
|
|
|
|
; MESA-TRAP: .section .AMDGPU.config
|
|
|
|
; MESA-TRAP: .long 47180
|
2018-05-17 00:19:34 +08:00
|
|
|
; MESA-TRAP-NEXT: .long 208
|
2017-02-10 10:15:29 +08:00
|
|
|
|
|
|
|
; NOMESA-TRAP: .section .AMDGPU.config
|
|
|
|
; NOMESA-TRAP: .long 47180
|
2018-05-17 00:19:34 +08:00
|
|
|
; NOMESA-TRAP-NEXT: .long 144
|
2017-02-10 10:15:29 +08:00
|
|
|
|
|
|
|
; GCN-LABEL: {{^}}hsa_trap:
|
2018-05-30 03:09:13 +08:00
|
|
|
; HSA-TRAP: enable_trap_handler = 0
|
2017-02-10 10:15:29 +08:00
|
|
|
; HSA-TRAP: s_mov_b64 s[0:1], s[4:5]
|
2017-02-23 07:22:19 +08:00
|
|
|
; HSA-TRAP: s_trap 2
|
2017-02-10 10:15:29 +08:00
|
|
|
|
|
|
|
; for llvm.trap in hsa path without ABI, direct generate s_endpgm instruction without any warning information
|
|
|
|
; NO-HSA-TRAP: enable_trap_handler = 0
|
|
|
|
; NO-HSA-TRAP: s_endpgm
|
|
|
|
; NO-HSA-TRAP: COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
|
|
|
|
|
|
|
|
; TRAP-BIT: enable_trap_handler = 1
|
|
|
|
; NO-TRAP-BIT: enable_trap_handler = 0
|
|
|
|
; NO-MESA-TRAP: s_endpgm
|
2018-05-17 00:19:34 +08:00
|
|
|
define amdgpu_kernel void @hsa_trap(i32 addrspace(1)* nocapture readonly %arg0) {
|
|
|
|
store volatile i32 1, i32 addrspace(1)* %arg0
|
2017-02-10 10:15:29 +08:00
|
|
|
call void @llvm.trap()
|
2018-05-17 00:19:34 +08:00
|
|
|
unreachable
|
|
|
|
store volatile i32 2, i32 addrspace(1)* %arg0
|
2017-02-10 10:15:29 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; MESA-TRAP: .section .AMDGPU.config
|
|
|
|
; MESA-TRAP: .long 47180
|
2018-05-17 00:19:34 +08:00
|
|
|
; MESA-TRAP-NEXT: .long 208
|
2017-02-10 10:15:29 +08:00
|
|
|
|
|
|
|
; NOMESA-TRAP: .section .AMDGPU.config
|
|
|
|
; NOMESA-TRAP: .long 47180
|
2018-05-17 00:19:34 +08:00
|
|
|
; NOMESA-TRAP-NEXT: .long 144
|
2017-02-10 10:15:29 +08:00
|
|
|
|
2018-05-17 00:19:34 +08:00
|
|
|
; GCN-WARNING: warning: <unknown>:0:0: in function hsa_debugtrap void (i32 addrspace(1)*): debugtrap handler not supported
|
2017-02-10 10:15:29 +08:00
|
|
|
; GCN-LABEL: {{^}}hsa_debugtrap:
|
2018-05-30 03:09:13 +08:00
|
|
|
; HSA-TRAP: enable_trap_handler = 0
|
2017-02-23 07:22:19 +08:00
|
|
|
; HSA-TRAP: s_trap 3
|
2018-05-17 00:19:34 +08:00
|
|
|
; HSA-TRAP: flat_store_dword v[0:1], v3
|
2017-02-10 10:15:29 +08:00
|
|
|
|
|
|
|
; for llvm.debugtrap in non-hsa path without ABI, generate a warning and a s_endpgm instruction
|
|
|
|
; NO-HSA-TRAP: enable_trap_handler = 0
|
|
|
|
; NO-HSA-TRAP: s_endpgm
|
|
|
|
|
|
|
|
; TRAP-BIT: enable_trap_handler = 1
|
|
|
|
; NO-TRAP-BIT: enable_trap_handler = 0
|
|
|
|
; NO-MESA-TRAP: s_endpgm
|
2018-05-17 00:19:34 +08:00
|
|
|
define amdgpu_kernel void @hsa_debugtrap(i32 addrspace(1)* nocapture readonly %arg0) {
|
|
|
|
store volatile i32 1, i32 addrspace(1)* %arg0
|
2017-02-10 10:15:29 +08:00
|
|
|
call void @llvm.debugtrap()
|
2018-05-17 00:19:34 +08:00
|
|
|
store volatile i32 2, i32 addrspace(1)* %arg0
|
2017-02-10 10:15:29 +08:00
|
|
|
ret void
|
|
|
|
}
|
2016-06-18 06:27:03 +08:00
|
|
|
|
2017-02-10 10:15:29 +08:00
|
|
|
; For non-HSA path
|
2016-06-18 06:27:03 +08:00
|
|
|
; GCN-LABEL: {{^}}trap:
|
2017-02-10 10:15:29 +08:00
|
|
|
; TRAP-BIT: enable_trap_handler = 1
|
|
|
|
; NO-TRAP-BIT: enable_trap_handler = 0
|
|
|
|
; NO-HSA-TRAP: s_endpgm
|
|
|
|
; NO-MESA-TRAP: s_endpgm
|
2018-05-17 00:19:34 +08:00
|
|
|
define amdgpu_kernel void @trap(i32 addrspace(1)* nocapture readonly %arg0) {
|
|
|
|
store volatile i32 1, i32 addrspace(1)* %arg0
|
2016-06-18 06:27:03 +08:00
|
|
|
call void @llvm.trap()
|
2018-05-17 00:19:34 +08:00
|
|
|
unreachable
|
|
|
|
store volatile i32 2, i32 addrspace(1)* %arg0
|
2016-06-18 06:27:03 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2017-04-25 01:49:13 +08:00
|
|
|
; GCN-LABEL: {{^}}non_entry_trap:
|
|
|
|
; TRAP-BIT: enable_trap_handler = 1
|
|
|
|
; NO-TRAP-BIT: enable_trap_handler = 0
|
|
|
|
|
2018-05-17 00:19:34 +08:00
|
|
|
; HSA-TRAP: BB{{[0-9]_[0-9]+}}: ; %trap
|
2017-04-25 01:49:13 +08:00
|
|
|
; HSA-TRAP: s_mov_b64 s[0:1], s[4:5]
|
|
|
|
; HSA-TRAP-NEXT: s_trap 2
|
2018-05-17 00:19:34 +08:00
|
|
|
define amdgpu_kernel void @non_entry_trap(i32 addrspace(1)* nocapture readonly %arg0) local_unnamed_addr {
|
2017-04-25 01:49:13 +08:00
|
|
|
entry:
|
|
|
|
%tmp29 = load volatile i32, i32 addrspace(1)* %arg0
|
|
|
|
%cmp = icmp eq i32 %tmp29, -1
|
|
|
|
br i1 %cmp, label %ret, label %trap
|
|
|
|
|
|
|
|
trap:
|
|
|
|
call void @llvm.trap()
|
|
|
|
unreachable
|
|
|
|
|
|
|
|
ret:
|
2018-05-17 00:19:34 +08:00
|
|
|
store volatile i32 3, i32 addrspace(1)* %arg0
|
2017-04-25 01:49:13 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-06-18 06:27:03 +08:00
|
|
|
attributes #0 = { nounwind noreturn }
|
2018-05-17 00:19:34 +08:00
|
|
|
attributes #1 = { nounwind }
|