
Here we introduce three new GMIR instructions to cover a set of trap intrinsics. The idea behind it is that generic intrinsics shouldn't be used with G_INTRINSIC opcode. These new instructions can match perfectly with existing trap ISD nodes. It allows X86, AArch64, RISCV and Mips to reuse SelectionDAG patterns for selection and avoid manual selection. However AMDGPU is an exception. It selects traps during legalization regardless SelectionDAG or GlobalISel. Since there are not many places where traps are used, this change attempts to clean up all the usages of G_INTRINSIC with trap intrinsics. So, there is no stage when both G_TRAP and G_INTRINSIC_W_SIDE_EFFECTS(@llvm.trap) are allowed.
65 lines
1.8 KiB
YAML
65 lines
1.8 KiB
YAML
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2
|
|
# RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=tahiti -run-pass=legalizer -o - %s | FileCheck -check-prefix=GCN %s
|
|
|
|
# Check edge cases for trap legalization
|
|
|
|
---
|
|
name: test_fallthrough_after_trap
|
|
body: |
|
|
; GCN-LABEL: name: test_fallthrough_after_trap
|
|
; GCN: bb.0:
|
|
; GCN-NEXT: successors: %bb.1(0x80000000), %bb.2(0x00000000)
|
|
; GCN-NEXT: {{ $}}
|
|
; GCN-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
|
|
; GCN-NEXT: [[C1:%[0-9]+]]:_(p1) = G_CONSTANT i64 0
|
|
; GCN-NEXT: S_CBRANCH_EXECNZ %bb.2, implicit $exec
|
|
; GCN-NEXT: {{ $}}
|
|
; GCN-NEXT: bb.1:
|
|
; GCN-NEXT: successors:
|
|
; GCN-NEXT: {{ $}}
|
|
; GCN-NEXT: G_STORE [[C]](s32), [[C1]](p1) :: (store (s8), addrspace 1)
|
|
; GCN-NEXT: {{ $}}
|
|
; GCN-NEXT: bb.2:
|
|
; GCN-NEXT: S_ENDPGM 0
|
|
bb.0:
|
|
%0:_(s8) = G_CONSTANT i8 0
|
|
%1:_(p1) = G_CONSTANT i64 0
|
|
G_TRAP
|
|
|
|
bb.1:
|
|
G_STORE %0, %1 :: (store 1, addrspace 1)
|
|
|
|
...
|
|
|
|
---
|
|
name: test_def_fallthrough_after_trap
|
|
body: |
|
|
; GCN-LABEL: name: test_def_fallthrough_after_trap
|
|
; GCN: bb.0:
|
|
; GCN-NEXT: successors: %bb.2(0x40000000), %bb.3(0x40000000)
|
|
; GCN-NEXT: {{ $}}
|
|
; GCN-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
|
|
; GCN-NEXT: S_CBRANCH_EXECNZ %bb.3, implicit $exec
|
|
; GCN-NEXT: {{ $}}
|
|
; GCN-NEXT: bb.2:
|
|
; GCN-NEXT: successors: %bb.1(0x80000000)
|
|
; GCN-NEXT: {{ $}}
|
|
; GCN-NEXT: [[C1:%[0-9]+]]:_(p1) = G_CONSTANT i64 0
|
|
; GCN-NEXT: {{ $}}
|
|
; GCN-NEXT: bb.1:
|
|
; GCN-NEXT: successors:
|
|
; GCN-NEXT: {{ $}}
|
|
; GCN-NEXT: G_STORE [[C]](s32), [[C1]](p1) :: (store (s8), addrspace 1)
|
|
; GCN-NEXT: {{ $}}
|
|
; GCN-NEXT: bb.3:
|
|
; GCN-NEXT: S_ENDPGM 0
|
|
bb.0:
|
|
%0:_(s8) = G_CONSTANT i8 0
|
|
G_TRAP
|
|
%1:_(p1) = G_CONSTANT i64 0
|
|
|
|
bb.1:
|
|
G_STORE %0, %1 :: (store 1, addrspace 1)
|
|
|
|
...
|