1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
2 // REQUIRES: amdgpu-registered-target
3 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x hip -emit-llvm -fcuda-is-device \
4 // RUN: -o - %s | FileCheck --check-prefix=AMDGCN --enable-var-scope %s
5 // RUN: %clang_cc1 -triple spirv64-amd-amdhsa -x hip -emit-llvm -fcuda-is-device \
6 // RUN: -o - %s | FileCheck --check-prefix=AMDGCNSPIRV --enable-var-scope %s
8 #define __device__ __attribute__((device))
10 extern "C" __device__
int printf(const char *format
, ...);
12 // AMDGCN-LABEL: define dso_local noundef i32 @_Z4foo1v(
13 // AMDGCN-SAME: ) #[[ATTR0:[0-9]+]] {
14 // AMDGCN-NEXT: [[ENTRY:.*]]:
15 // AMDGCN-NEXT: [[RETVAL:%.*]] = alloca i32, align 4, addrspace(5)
16 // AMDGCN-NEXT: [[S:%.*]] = alloca ptr, align 8, addrspace(5)
17 // AMDGCN-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
18 // AMDGCN-NEXT: [[S_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[S]] to ptr
19 // AMDGCN-NEXT: store ptr addrspacecast (ptr addrspace(4) @.str to ptr), ptr [[S_ASCAST]], align 8
20 // AMDGCN-NEXT: [[TMP0:%.*]] = load ptr, ptr [[S_ASCAST]], align 8
21 // AMDGCN-NEXT: [[TMP1:%.*]] = load ptr, ptr [[S_ASCAST]], align 8
22 // AMDGCN-NEXT: [[TMP2:%.*]] = call i64 @__ockl_printf_begin(i64 0)
23 // AMDGCN-NEXT: [[TMP3:%.*]] = icmp eq ptr addrspacecast (ptr addrspace(4) @.str.1 to ptr), null
24 // AMDGCN-NEXT: br i1 [[TMP3]], label %[[STRLEN_JOIN:.*]], label %[[STRLEN_WHILE:.*]]
25 // AMDGCN: [[STRLEN_WHILE]]:
26 // AMDGCN-NEXT: [[TMP4:%.*]] = phi ptr [ addrspacecast (ptr addrspace(4) @.str.1 to ptr), %[[ENTRY]] ], [ [[TMP5:%.*]], %[[STRLEN_WHILE]] ]
27 // AMDGCN-NEXT: [[TMP5]] = getelementptr i8, ptr [[TMP4]], i64 1
28 // AMDGCN-NEXT: [[TMP6:%.*]] = load i8, ptr [[TMP4]], align 1
29 // AMDGCN-NEXT: [[TMP7:%.*]] = icmp eq i8 [[TMP6]], 0
30 // AMDGCN-NEXT: br i1 [[TMP7]], label %[[STRLEN_WHILE_DONE:.*]], label %[[STRLEN_WHILE]]
31 // AMDGCN: [[STRLEN_WHILE_DONE]]:
32 // AMDGCN-NEXT: [[TMP8:%.*]] = ptrtoint ptr [[TMP4]] to i64
33 // AMDGCN-NEXT: [[TMP9:%.*]] = sub i64 [[TMP8]], ptrtoint (ptr addrspacecast (ptr addrspace(4) @.str.1 to ptr) to i64)
34 // AMDGCN-NEXT: [[TMP10:%.*]] = add i64 [[TMP9]], 1
35 // AMDGCN-NEXT: br label %[[STRLEN_JOIN]]
36 // AMDGCN: [[STRLEN_JOIN]]:
37 // AMDGCN-NEXT: [[TMP11:%.*]] = phi i64 [ [[TMP10]], %[[STRLEN_WHILE_DONE]] ], [ 0, %[[ENTRY]] ]
38 // AMDGCN-NEXT: [[TMP12:%.*]] = call i64 @__ockl_printf_append_string_n(i64 [[TMP2]], ptr addrspacecast (ptr addrspace(4) @.str.1 to ptr), i64 [[TMP11]], i32 0)
39 // AMDGCN-NEXT: [[TMP13:%.*]] = call i64 @__ockl_printf_append_args(i64 [[TMP12]], i32 1, i64 8, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i32 0)
40 // AMDGCN-NEXT: [[TMP14:%.*]] = call i64 @__ockl_printf_append_args(i64 [[TMP13]], i32 1, i64 4614256650576692846, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i32 0)
41 // AMDGCN-NEXT: [[TMP15:%.*]] = call i64 @__ockl_printf_append_args(i64 [[TMP14]], i32 1, i64 8, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i32 0)
42 // AMDGCN-NEXT: [[TMP16:%.*]] = call i64 @__ockl_printf_append_args(i64 [[TMP15]], i32 1, i64 4, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i32 0)
43 // AMDGCN-NEXT: [[TMP17:%.*]] = icmp eq ptr [[TMP0]], null
44 // AMDGCN-NEXT: br i1 [[TMP17]], label %[[STRLEN_JOIN1:.*]], label %[[STRLEN_WHILE2:.*]]
45 // AMDGCN: [[STRLEN_WHILE2]]:
46 // AMDGCN-NEXT: [[TMP18:%.*]] = phi ptr [ [[TMP0]], %[[STRLEN_JOIN]] ], [ [[TMP19:%.*]], %[[STRLEN_WHILE2]] ]
47 // AMDGCN-NEXT: [[TMP19]] = getelementptr i8, ptr [[TMP18]], i64 1
48 // AMDGCN-NEXT: [[TMP20:%.*]] = load i8, ptr [[TMP18]], align 1
49 // AMDGCN-NEXT: [[TMP21:%.*]] = icmp eq i8 [[TMP20]], 0
50 // AMDGCN-NEXT: br i1 [[TMP21]], label %[[STRLEN_WHILE_DONE3:.*]], label %[[STRLEN_WHILE2]]
51 // AMDGCN: [[STRLEN_WHILE_DONE3]]:
52 // AMDGCN-NEXT: [[TMP22:%.*]] = ptrtoint ptr [[TMP0]] to i64
53 // AMDGCN-NEXT: [[TMP23:%.*]] = ptrtoint ptr [[TMP18]] to i64
54 // AMDGCN-NEXT: [[TMP24:%.*]] = sub i64 [[TMP23]], [[TMP22]]
55 // AMDGCN-NEXT: [[TMP25:%.*]] = add i64 [[TMP24]], 1
56 // AMDGCN-NEXT: br label %[[STRLEN_JOIN1]]
57 // AMDGCN: [[STRLEN_JOIN1]]:
58 // AMDGCN-NEXT: [[TMP26:%.*]] = phi i64 [ [[TMP25]], %[[STRLEN_WHILE_DONE3]] ], [ 0, %[[STRLEN_JOIN]] ]
59 // AMDGCN-NEXT: [[TMP27:%.*]] = call i64 @__ockl_printf_append_string_n(i64 [[TMP16]], ptr [[TMP0]], i64 [[TMP26]], i32 0)
60 // AMDGCN-NEXT: [[TMP28:%.*]] = ptrtoint ptr [[TMP1]] to i64
61 // AMDGCN-NEXT: [[TMP29:%.*]] = call i64 @__ockl_printf_append_args(i64 [[TMP27]], i32 1, i64 [[TMP28]], i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i32 1)
62 // AMDGCN-NEXT: [[TMP30:%.*]] = trunc i64 [[TMP29]] to i32
63 // AMDGCN-NEXT: ret i32 [[TMP30]]
65 // AMDGCNSPIRV-LABEL: define spir_func noundef i32 @_Z4foo1v(
66 // AMDGCNSPIRV-SAME: ) addrspace(4) #[[ATTR0:[0-9]+]] {
67 // AMDGCNSPIRV-NEXT: [[ENTRY:.*]]:
68 // AMDGCNSPIRV-NEXT: [[RETVAL:%.*]] = alloca i32, align 4
69 // AMDGCNSPIRV-NEXT: [[S:%.*]] = alloca ptr addrspace(4), align 8
70 // AMDGCNSPIRV-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr [[RETVAL]] to ptr addrspace(4)
71 // AMDGCNSPIRV-NEXT: [[S_ASCAST:%.*]] = addrspacecast ptr [[S]] to ptr addrspace(4)
72 // AMDGCNSPIRV-NEXT: store ptr addrspace(4) addrspacecast (ptr addrspace(1) @.str to ptr addrspace(4)), ptr addrspace(4) [[S_ASCAST]], align 8
73 // AMDGCNSPIRV-NEXT: [[TMP0:%.*]] = load ptr addrspace(4), ptr addrspace(4) [[S_ASCAST]], align 8
74 // AMDGCNSPIRV-NEXT: [[TMP1:%.*]] = load ptr addrspace(4), ptr addrspace(4) [[S_ASCAST]], align 8
75 // AMDGCNSPIRV-NEXT: [[TMP2:%.*]] = call addrspace(4) i64 @__ockl_printf_begin(i64 0)
76 // AMDGCNSPIRV-NEXT: [[TMP3:%.*]] = icmp eq ptr addrspace(4) addrspacecast (ptr addrspace(1) @.str.1 to ptr addrspace(4)), null
77 // AMDGCNSPIRV-NEXT: br i1 [[TMP3]], label %[[STRLEN_JOIN:.*]], label %[[STRLEN_WHILE:.*]]
78 // AMDGCNSPIRV: [[STRLEN_WHILE]]:
79 // AMDGCNSPIRV-NEXT: [[TMP4:%.*]] = phi ptr addrspace(4) [ addrspacecast (ptr addrspace(1) @.str.1 to ptr addrspace(4)), %[[ENTRY]] ], [ [[TMP5:%.*]], %[[STRLEN_WHILE]] ]
80 // AMDGCNSPIRV-NEXT: [[TMP5]] = getelementptr i8, ptr addrspace(4) [[TMP4]], i64 1
81 // AMDGCNSPIRV-NEXT: [[TMP6:%.*]] = load i8, ptr addrspace(4) [[TMP4]], align 1
82 // AMDGCNSPIRV-NEXT: [[TMP7:%.*]] = icmp eq i8 [[TMP6]], 0
83 // AMDGCNSPIRV-NEXT: br i1 [[TMP7]], label %[[STRLEN_WHILE_DONE:.*]], label %[[STRLEN_WHILE]]
84 // AMDGCNSPIRV: [[STRLEN_WHILE_DONE]]:
85 // AMDGCNSPIRV-NEXT: [[TMP8:%.*]] = ptrtoint ptr addrspace(4) [[TMP4]] to i64
86 // AMDGCNSPIRV-NEXT: [[TMP9:%.*]] = sub i64 [[TMP8]], ptrtoint (ptr addrspace(4) addrspacecast (ptr addrspace(1) @.str.1 to ptr addrspace(4)) to i64)
87 // AMDGCNSPIRV-NEXT: [[TMP10:%.*]] = add i64 [[TMP9]], 1
88 // AMDGCNSPIRV-NEXT: br label %[[STRLEN_JOIN]]
89 // AMDGCNSPIRV: [[STRLEN_JOIN]]:
90 // AMDGCNSPIRV-NEXT: [[TMP11:%.*]] = phi i64 [ [[TMP10]], %[[STRLEN_WHILE_DONE]] ], [ 0, %[[ENTRY]] ]
91 // AMDGCNSPIRV-NEXT: [[TMP12:%.*]] = call addrspace(4) i64 @__ockl_printf_append_string_n(i64 [[TMP2]], ptr addrspace(4) addrspacecast (ptr addrspace(1) @.str.1 to ptr addrspace(4)), i64 [[TMP11]], i32 0)
92 // AMDGCNSPIRV-NEXT: [[TMP13:%.*]] = call addrspace(4) i64 @__ockl_printf_append_args(i64 [[TMP12]], i32 1, i64 8, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i32 0)
93 // AMDGCNSPIRV-NEXT: [[TMP14:%.*]] = call addrspace(4) i64 @__ockl_printf_append_args(i64 [[TMP13]], i32 1, i64 4614256650576692846, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i32 0)
94 // AMDGCNSPIRV-NEXT: [[TMP15:%.*]] = call addrspace(4) i64 @__ockl_printf_append_args(i64 [[TMP14]], i32 1, i64 8, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i32 0)
95 // AMDGCNSPIRV-NEXT: [[TMP16:%.*]] = call addrspace(4) i64 @__ockl_printf_append_args(i64 [[TMP15]], i32 1, i64 4, i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i32 0)
96 // AMDGCNSPIRV-NEXT: [[TMP17:%.*]] = icmp eq ptr addrspace(4) [[TMP0]], null
97 // AMDGCNSPIRV-NEXT: br i1 [[TMP17]], label %[[STRLEN_JOIN1:.*]], label %[[STRLEN_WHILE2:.*]]
98 // AMDGCNSPIRV: [[STRLEN_WHILE2]]:
99 // AMDGCNSPIRV-NEXT: [[TMP18:%.*]] = phi ptr addrspace(4) [ [[TMP0]], %[[STRLEN_JOIN]] ], [ [[TMP19:%.*]], %[[STRLEN_WHILE2]] ]
100 // AMDGCNSPIRV-NEXT: [[TMP19]] = getelementptr i8, ptr addrspace(4) [[TMP18]], i64 1
101 // AMDGCNSPIRV-NEXT: [[TMP20:%.*]] = load i8, ptr addrspace(4) [[TMP18]], align 1
102 // AMDGCNSPIRV-NEXT: [[TMP21:%.*]] = icmp eq i8 [[TMP20]], 0
103 // AMDGCNSPIRV-NEXT: br i1 [[TMP21]], label %[[STRLEN_WHILE_DONE3:.*]], label %[[STRLEN_WHILE2]]
104 // AMDGCNSPIRV: [[STRLEN_WHILE_DONE3]]:
105 // AMDGCNSPIRV-NEXT: [[TMP22:%.*]] = ptrtoint ptr addrspace(4) [[TMP0]] to i64
106 // AMDGCNSPIRV-NEXT: [[TMP23:%.*]] = ptrtoint ptr addrspace(4) [[TMP18]] to i64
107 // AMDGCNSPIRV-NEXT: [[TMP24:%.*]] = sub i64 [[TMP23]], [[TMP22]]
108 // AMDGCNSPIRV-NEXT: [[TMP25:%.*]] = add i64 [[TMP24]], 1
109 // AMDGCNSPIRV-NEXT: br label %[[STRLEN_JOIN1]]
110 // AMDGCNSPIRV: [[STRLEN_JOIN1]]:
111 // AMDGCNSPIRV-NEXT: [[TMP26:%.*]] = phi i64 [ [[TMP25]], %[[STRLEN_WHILE_DONE3]] ], [ 0, %[[STRLEN_JOIN]] ]
112 // AMDGCNSPIRV-NEXT: [[TMP27:%.*]] = call addrspace(4) i64 @__ockl_printf_append_string_n(i64 [[TMP16]], ptr addrspace(4) [[TMP0]], i64 [[TMP26]], i32 0)
113 // AMDGCNSPIRV-NEXT: [[TMP28:%.*]] = ptrtoint ptr addrspace(4) [[TMP1]] to i64
114 // AMDGCNSPIRV-NEXT: [[TMP29:%.*]] = call addrspace(4) i64 @__ockl_printf_append_args(i64 [[TMP27]], i32 1, i64 [[TMP28]], i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i32 1)
115 // AMDGCNSPIRV-NEXT: [[TMP30:%.*]] = trunc i64 [[TMP29]] to i32
116 // AMDGCNSPIRV-NEXT: ret i32 [[TMP30]]
118 __device__
int foo1() {
119 const char *s
= "hello world";
120 return printf("%.*f %*.*s %p\n", 8, 3.14159, 8, 4, s
, s
);
123 __device__
char *dstr
;
125 // AMDGCN-LABEL: define dso_local noundef i32 @_Z4foo2v(
126 // AMDGCN-SAME: ) #[[ATTR0:[0-9]+]] {
127 // AMDGCN-NEXT: [[ENTRY:.*]]:
128 // AMDGCN-NEXT: [[RETVAL:%.*]] = alloca i32, align 4, addrspace(5)
129 // AMDGCN-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
130 // AMDGCN-NEXT: [[TMP0:%.*]] = load ptr, ptr addrspacecast (ptr addrspace(1) @dstr to ptr), align 8
131 // AMDGCN-NEXT: [[TMP1:%.*]] = load ptr, ptr addrspacecast (ptr addrspace(1) @dstr to ptr), align 8
132 // AMDGCN-NEXT: [[TMP2:%.*]] = call i64 @__ockl_printf_begin(i64 0)
133 // AMDGCN-NEXT: [[TMP3:%.*]] = icmp eq ptr addrspacecast (ptr addrspace(4) @.str.2 to ptr), null
134 // AMDGCN-NEXT: br i1 [[TMP3]], label %[[STRLEN_JOIN:.*]], label %[[STRLEN_WHILE:.*]]
135 // AMDGCN: [[STRLEN_WHILE]]:
136 // AMDGCN-NEXT: [[TMP4:%.*]] = phi ptr [ addrspacecast (ptr addrspace(4) @.str.2 to ptr), %[[ENTRY]] ], [ [[TMP5:%.*]], %[[STRLEN_WHILE]] ]
137 // AMDGCN-NEXT: [[TMP5]] = getelementptr i8, ptr [[TMP4]], i64 1
138 // AMDGCN-NEXT: [[TMP6:%.*]] = load i8, ptr [[TMP4]], align 1
139 // AMDGCN-NEXT: [[TMP7:%.*]] = icmp eq i8 [[TMP6]], 0
140 // AMDGCN-NEXT: br i1 [[TMP7]], label %[[STRLEN_WHILE_DONE:.*]], label %[[STRLEN_WHILE]]
141 // AMDGCN: [[STRLEN_WHILE_DONE]]:
142 // AMDGCN-NEXT: [[TMP8:%.*]] = ptrtoint ptr [[TMP4]] to i64
143 // AMDGCN-NEXT: [[TMP9:%.*]] = sub i64 [[TMP8]], ptrtoint (ptr addrspacecast (ptr addrspace(4) @.str.2 to ptr) to i64)
144 // AMDGCN-NEXT: [[TMP10:%.*]] = add i64 [[TMP9]], 1
145 // AMDGCN-NEXT: br label %[[STRLEN_JOIN]]
146 // AMDGCN: [[STRLEN_JOIN]]:
147 // AMDGCN-NEXT: [[TMP11:%.*]] = phi i64 [ [[TMP10]], %[[STRLEN_WHILE_DONE]] ], [ 0, %[[ENTRY]] ]
148 // AMDGCN-NEXT: [[TMP12:%.*]] = call i64 @__ockl_printf_append_string_n(i64 [[TMP2]], ptr addrspacecast (ptr addrspace(4) @.str.2 to ptr), i64 [[TMP11]], i32 0)
149 // AMDGCN-NEXT: [[TMP13:%.*]] = icmp eq ptr [[TMP0]], null
150 // AMDGCN-NEXT: br i1 [[TMP13]], label %[[STRLEN_JOIN1:.*]], label %[[STRLEN_WHILE2:.*]]
151 // AMDGCN: [[STRLEN_WHILE2]]:
152 // AMDGCN-NEXT: [[TMP14:%.*]] = phi ptr [ [[TMP0]], %[[STRLEN_JOIN]] ], [ [[TMP15:%.*]], %[[STRLEN_WHILE2]] ]
153 // AMDGCN-NEXT: [[TMP15]] = getelementptr i8, ptr [[TMP14]], i64 1
154 // AMDGCN-NEXT: [[TMP16:%.*]] = load i8, ptr [[TMP14]], align 1
155 // AMDGCN-NEXT: [[TMP17:%.*]] = icmp eq i8 [[TMP16]], 0
156 // AMDGCN-NEXT: br i1 [[TMP17]], label %[[STRLEN_WHILE_DONE3:.*]], label %[[STRLEN_WHILE2]]
157 // AMDGCN: [[STRLEN_WHILE_DONE3]]:
158 // AMDGCN-NEXT: [[TMP18:%.*]] = ptrtoint ptr [[TMP0]] to i64
159 // AMDGCN-NEXT: [[TMP19:%.*]] = ptrtoint ptr [[TMP14]] to i64
160 // AMDGCN-NEXT: [[TMP20:%.*]] = sub i64 [[TMP19]], [[TMP18]]
161 // AMDGCN-NEXT: [[TMP21:%.*]] = add i64 [[TMP20]], 1
162 // AMDGCN-NEXT: br label %[[STRLEN_JOIN1]]
163 // AMDGCN: [[STRLEN_JOIN1]]:
164 // AMDGCN-NEXT: [[TMP22:%.*]] = phi i64 [ [[TMP21]], %[[STRLEN_WHILE_DONE3]] ], [ 0, %[[STRLEN_JOIN]] ]
165 // AMDGCN-NEXT: [[TMP23:%.*]] = call i64 @__ockl_printf_append_string_n(i64 [[TMP12]], ptr [[TMP0]], i64 [[TMP22]], i32 0)
166 // AMDGCN-NEXT: [[TMP24:%.*]] = ptrtoint ptr [[TMP1]] to i64
167 // AMDGCN-NEXT: [[TMP25:%.*]] = call i64 @__ockl_printf_append_args(i64 [[TMP23]], i32 1, i64 [[TMP24]], i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i32 1)
168 // AMDGCN-NEXT: [[TMP26:%.*]] = trunc i64 [[TMP25]] to i32
169 // AMDGCN-NEXT: ret i32 [[TMP26]]
171 // AMDGCNSPIRV-LABEL: define spir_func noundef i32 @_Z4foo2v(
172 // AMDGCNSPIRV-SAME: ) addrspace(4) #[[ATTR0:[0-9]+]] {
173 // AMDGCNSPIRV-NEXT: [[ENTRY:.*]]:
174 // AMDGCNSPIRV-NEXT: [[RETVAL:%.*]] = alloca i32, align 4
175 // AMDGCNSPIRV-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr [[RETVAL]] to ptr addrspace(4)
176 // AMDGCNSPIRV-NEXT: [[TMP0:%.*]] = load ptr addrspace(4), ptr addrspace(4) addrspacecast (ptr addrspace(1) @dstr to ptr addrspace(4)), align 8
177 // AMDGCNSPIRV-NEXT: [[TMP1:%.*]] = load ptr addrspace(4), ptr addrspace(4) addrspacecast (ptr addrspace(1) @dstr to ptr addrspace(4)), align 8
178 // AMDGCNSPIRV-NEXT: [[TMP2:%.*]] = call addrspace(4) i64 @__ockl_printf_begin(i64 0)
179 // AMDGCNSPIRV-NEXT: [[TMP3:%.*]] = icmp eq ptr addrspace(4) addrspacecast (ptr addrspace(1) @.str.2 to ptr addrspace(4)), null
180 // AMDGCNSPIRV-NEXT: br i1 [[TMP3]], label %[[STRLEN_JOIN:.*]], label %[[STRLEN_WHILE:.*]]
181 // AMDGCNSPIRV: [[STRLEN_WHILE]]:
182 // AMDGCNSPIRV-NEXT: [[TMP4:%.*]] = phi ptr addrspace(4) [ addrspacecast (ptr addrspace(1) @.str.2 to ptr addrspace(4)), %[[ENTRY]] ], [ [[TMP5:%.*]], %[[STRLEN_WHILE]] ]
183 // AMDGCNSPIRV-NEXT: [[TMP5]] = getelementptr i8, ptr addrspace(4) [[TMP4]], i64 1
184 // AMDGCNSPIRV-NEXT: [[TMP6:%.*]] = load i8, ptr addrspace(4) [[TMP4]], align 1
185 // AMDGCNSPIRV-NEXT: [[TMP7:%.*]] = icmp eq i8 [[TMP6]], 0
186 // AMDGCNSPIRV-NEXT: br i1 [[TMP7]], label %[[STRLEN_WHILE_DONE:.*]], label %[[STRLEN_WHILE]]
187 // AMDGCNSPIRV: [[STRLEN_WHILE_DONE]]:
188 // AMDGCNSPIRV-NEXT: [[TMP8:%.*]] = ptrtoint ptr addrspace(4) [[TMP4]] to i64
189 // AMDGCNSPIRV-NEXT: [[TMP9:%.*]] = sub i64 [[TMP8]], ptrtoint (ptr addrspace(4) addrspacecast (ptr addrspace(1) @.str.2 to ptr addrspace(4)) to i64)
190 // AMDGCNSPIRV-NEXT: [[TMP10:%.*]] = add i64 [[TMP9]], 1
191 // AMDGCNSPIRV-NEXT: br label %[[STRLEN_JOIN]]
192 // AMDGCNSPIRV: [[STRLEN_JOIN]]:
193 // AMDGCNSPIRV-NEXT: [[TMP11:%.*]] = phi i64 [ [[TMP10]], %[[STRLEN_WHILE_DONE]] ], [ 0, %[[ENTRY]] ]
194 // AMDGCNSPIRV-NEXT: [[TMP12:%.*]] = call addrspace(4) i64 @__ockl_printf_append_string_n(i64 [[TMP2]], ptr addrspace(4) addrspacecast (ptr addrspace(1) @.str.2 to ptr addrspace(4)), i64 [[TMP11]], i32 0)
195 // AMDGCNSPIRV-NEXT: [[TMP13:%.*]] = icmp eq ptr addrspace(4) [[TMP0]], null
196 // AMDGCNSPIRV-NEXT: br i1 [[TMP13]], label %[[STRLEN_JOIN1:.*]], label %[[STRLEN_WHILE2:.*]]
197 // AMDGCNSPIRV: [[STRLEN_WHILE2]]:
198 // AMDGCNSPIRV-NEXT: [[TMP14:%.*]] = phi ptr addrspace(4) [ [[TMP0]], %[[STRLEN_JOIN]] ], [ [[TMP15:%.*]], %[[STRLEN_WHILE2]] ]
199 // AMDGCNSPIRV-NEXT: [[TMP15]] = getelementptr i8, ptr addrspace(4) [[TMP14]], i64 1
200 // AMDGCNSPIRV-NEXT: [[TMP16:%.*]] = load i8, ptr addrspace(4) [[TMP14]], align 1
201 // AMDGCNSPIRV-NEXT: [[TMP17:%.*]] = icmp eq i8 [[TMP16]], 0
202 // AMDGCNSPIRV-NEXT: br i1 [[TMP17]], label %[[STRLEN_WHILE_DONE3:.*]], label %[[STRLEN_WHILE2]]
203 // AMDGCNSPIRV: [[STRLEN_WHILE_DONE3]]:
204 // AMDGCNSPIRV-NEXT: [[TMP18:%.*]] = ptrtoint ptr addrspace(4) [[TMP0]] to i64
205 // AMDGCNSPIRV-NEXT: [[TMP19:%.*]] = ptrtoint ptr addrspace(4) [[TMP14]] to i64
206 // AMDGCNSPIRV-NEXT: [[TMP20:%.*]] = sub i64 [[TMP19]], [[TMP18]]
207 // AMDGCNSPIRV-NEXT: [[TMP21:%.*]] = add i64 [[TMP20]], 1
208 // AMDGCNSPIRV-NEXT: br label %[[STRLEN_JOIN1]]
209 // AMDGCNSPIRV: [[STRLEN_JOIN1]]:
210 // AMDGCNSPIRV-NEXT: [[TMP22:%.*]] = phi i64 [ [[TMP21]], %[[STRLEN_WHILE_DONE3]] ], [ 0, %[[STRLEN_JOIN]] ]
211 // AMDGCNSPIRV-NEXT: [[TMP23:%.*]] = call addrspace(4) i64 @__ockl_printf_append_string_n(i64 [[TMP12]], ptr addrspace(4) [[TMP0]], i64 [[TMP22]], i32 0)
212 // AMDGCNSPIRV-NEXT: [[TMP24:%.*]] = ptrtoint ptr addrspace(4) [[TMP1]] to i64
213 // AMDGCNSPIRV-NEXT: [[TMP25:%.*]] = call addrspace(4) i64 @__ockl_printf_append_args(i64 [[TMP23]], i32 1, i64 [[TMP24]], i64 0, i64 0, i64 0, i64 0, i64 0, i64 0, i32 1)
214 // AMDGCNSPIRV-NEXT: [[TMP26:%.*]] = trunc i64 [[TMP25]] to i32
215 // AMDGCNSPIRV-NEXT: ret i32 [[TMP26]]
217 __device__
int foo2() {
218 return printf("%s %p\n", dstr
, dstr
);