xref: /llvm-project/llvm/test/CodeGen/NVPTX/unreachable.ll (revision 4583f6d3443c8dc6605c868724e3743161954210)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2; RUN: llc < %s -mtriple=nvptx -mcpu=sm_20 -verify-machineinstrs -trap-unreachable=false \
3; RUN:     | FileCheck %s --check-prefixes=CHECK,NO-TRAP-UNREACHABLE
4; RUN: llc < %s -mtriple=nvptx64 -mcpu=sm_20 -verify-machineinstrs -trap-unreachable=false \
5; RUN:     | FileCheck %s --check-prefixes=CHECK,NO-TRAP-UNREACHABLE
6; RUN: llc < %s -mtriple=nvptx -mcpu=sm_20 -verify-machineinstrs -trap-unreachable -no-trap-after-noreturn \
7; RUN:     | FileCheck %s --check-prefixes=CHECK,NO-TRAP-AFTER-NORETURN
8; RUN: llc < %s -mtriple=nvptx64 -mcpu=sm_20 -verify-machineinstrs -trap-unreachable -no-trap-after-noreturn \
9; RUN:     | FileCheck %s --check-prefixes=CHECK,NO-TRAP-AFTER-NORETURN
10; RUN: llc < %s -mtriple=nvptx -mcpu=sm_20 -verify-machineinstrs -trap-unreachable -no-trap-after-noreturn=false \
11; RUN:     | FileCheck %s --check-prefixes=CHECK,TRAP
12; RUN: llc < %s -mtriple=nvptx64 -mcpu=sm_20 -verify-machineinstrs -trap-unreachable -no-trap-after-noreturn=false \
13; RUN:     | FileCheck %s --check-prefixes=CHECK,TRAP
14; RUN: llc < %s -mtriple=nvptx64 -mcpu=sm_20 -verify-machineinstrs -trap-unreachable -mattr=+ptx83 \
15; RUN:     | FileCheck %s --check-prefixes=BUG-FIXED
16; RUN: %if ptxas && !ptxas-12.0 %{ llc < %s -mtriple=nvptx -mcpu=sm_20 -verify-machineinstrs | %ptxas-verify %}
17; RUN: %if ptxas %{ llc < %s -mtriple=nvptx64 -mcpu=sm_20 -verify-machineinstrs | %ptxas-verify %}
18
19target triple = "nvptx-unknown-cuda"
20
21declare void @throw() #0
22declare void @llvm.trap() #0
23
24define ptx_kernel void @kernel_func() {
25; NO-TRAP-UNREACHABLE-LABEL: kernel_func(
26; NO-TRAP-UNREACHABLE:       {
27; NO-TRAP-UNREACHABLE-EMPTY:
28; NO-TRAP-UNREACHABLE-EMPTY:
29; NO-TRAP-UNREACHABLE-NEXT:  // %bb.0:
30; NO-TRAP-UNREACHABLE-NEXT:    { // callseq 0, 0
31; NO-TRAP-UNREACHABLE-NEXT:    call.uni
32; NO-TRAP-UNREACHABLE-NEXT:    throw,
33; NO-TRAP-UNREACHABLE-NEXT:    (
34; NO-TRAP-UNREACHABLE-NEXT:    );
35; NO-TRAP-UNREACHABLE-NEXT:    } // callseq 0
36; NO-TRAP-UNREACHABLE-NEXT:    // begin inline asm
37; NO-TRAP-UNREACHABLE-NEXT:    exit;
38; NO-TRAP-UNREACHABLE-NEXT:    // end inline asm
39;
40; NO-TRAP-AFTER-NORETURN-LABEL: kernel_func(
41; NO-TRAP-AFTER-NORETURN:       {
42; NO-TRAP-AFTER-NORETURN-EMPTY:
43; NO-TRAP-AFTER-NORETURN-EMPTY:
44; NO-TRAP-AFTER-NORETURN-NEXT:  // %bb.0:
45; NO-TRAP-AFTER-NORETURN-NEXT:    { // callseq 0, 0
46; NO-TRAP-AFTER-NORETURN-NEXT:    call.uni
47; NO-TRAP-AFTER-NORETURN-NEXT:    throw,
48; NO-TRAP-AFTER-NORETURN-NEXT:    (
49; NO-TRAP-AFTER-NORETURN-NEXT:    );
50; NO-TRAP-AFTER-NORETURN-NEXT:    } // callseq 0
51; NO-TRAP-AFTER-NORETURN-NEXT:    // begin inline asm
52; NO-TRAP-AFTER-NORETURN-NEXT:    exit;
53; NO-TRAP-AFTER-NORETURN-NEXT:    // end inline asm
54; NO-TRAP-AFTER-NORETURN-NEXT:    trap; exit;
55;
56; TRAP-LABEL: kernel_func(
57; TRAP:       {
58; TRAP-EMPTY:
59; TRAP-EMPTY:
60; TRAP-NEXT:  // %bb.0:
61; TRAP-NEXT:    { // callseq 0, 0
62; TRAP-NEXT:    call.uni
63; TRAP-NEXT:    throw,
64; TRAP-NEXT:    (
65; TRAP-NEXT:    );
66; TRAP-NEXT:    } // callseq 0
67; TRAP-NEXT:    trap; exit;
68;
69; BUG-FIXED-LABEL: kernel_func(
70; BUG-FIXED:       {
71; BUG-FIXED-EMPTY:
72; BUG-FIXED-EMPTY:
73; BUG-FIXED-NEXT:  // %bb.0:
74; BUG-FIXED-NEXT:    { // callseq 0, 0
75; BUG-FIXED-NEXT:    call.uni
76; BUG-FIXED-NEXT:    throw,
77; BUG-FIXED-NEXT:    (
78; BUG-FIXED-NEXT:    );
79; BUG-FIXED-NEXT:    } // callseq 0
80; BUG-FIXED-NEXT:    trap;
81  call void @throw()
82  unreachable
83}
84
85define void @kernel_func_2() {
86; CHECK-LABEL: kernel_func_2(
87; CHECK:       {
88; CHECK-EMPTY:
89; CHECK-EMPTY:
90; CHECK-NEXT:  // %bb.0:
91; CHECK-NEXT:    trap; exit;
92;
93; BUG-FIXED-LABEL: kernel_func_2(
94; BUG-FIXED:       {
95; BUG-FIXED-EMPTY:
96; BUG-FIXED-EMPTY:
97; BUG-FIXED-NEXT:  // %bb.0:
98; BUG-FIXED-NEXT:    trap;
99  call void @llvm.trap()
100; Make sure we avoid emitting two trap instructions.
101  unreachable
102}
103
104attributes #0 = { noreturn }
105