llvm/llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-trap.mir

# 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)

...