1 // RUN: mlir-opt %s -inline -split-input-file | FileCheck %s
3 #alias_scope_domain = #llvm.alias_scope_domain<id = distinct[0]<>, description = "foo">
4 #alias_scope = #llvm.alias_scope<id = distinct[1]<>, domain = #alias_scope_domain, description = "foo load">
5 #alias_scope1 = #llvm.alias_scope<id = distinct[2]<>, domain = #alias_scope_domain, description = "foo store">
7 // CHECK-DAG: #[[FOO_DOMAIN:.*]] = #llvm.alias_scope_domain<{{.*}}>
8 // CHECK-DAG: #[[$FOO_LOAD:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[FOO_DOMAIN]], description = {{.*}}>
9 // CHECK-DAG: #[[$FOO_STORE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[FOO_DOMAIN]], description = {{.*}}>
11 // CHECK-DAG: #[[BAR_DOMAIN:.*]] = #llvm.alias_scope_domain<{{.*}}>
12 // CHECK-DAG: #[[$BAR_LOAD:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[BAR_DOMAIN]], description = {{.*}}>
13 // CHECK-DAG: #[[$BAR_STORE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[BAR_DOMAIN]], description = {{.*}}>
15 // CHECK-LABEL: llvm.func @foo
16 // CHECK: llvm.intr.experimental.noalias.scope.decl #[[$FOO_LOAD]]
18 // CHECK-SAME: alias_scopes = [#[[$FOO_LOAD]]]
19 // CHECK-SAME: noalias_scopes = [#[[$FOO_STORE]]]
21 // CHECK-SAME: alias_scopes = [#[[$FOO_STORE]]]
22 // CHECK-SAME: noalias_scopes = [#[[$FOO_LOAD]]]
23 llvm.func @foo(%arg0: !llvm.ptr, %arg1: !llvm.ptr) {
24 %0 = llvm.mlir.constant(5 : i64) : i64
25 llvm.intr.experimental.noalias.scope.decl #alias_scope
26 %2 = llvm.load %arg1 {alias_scopes = [#alias_scope], alignment = 4 : i64, noalias_scopes = [#alias_scope1]} : !llvm.ptr -> f32
27 "test.one_region_op"() ({
28 %3 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, f32
29 llvm.store %2, %3 {alias_scopes = [#alias_scope1], alignment = 4 : i64, noalias_scopes = [#alias_scope]} : f32, !llvm.ptr
30 "test.terminator"() : () -> ()
35 // CHECK-LABEL: llvm.func @clone_alias_scopes
36 // CHECK: llvm.intr.experimental.noalias.scope.decl #[[$BAR_LOAD]]
38 // CHECK-SAME: alias_scopes = [#[[$BAR_LOAD]]]
39 // CHECK-SAME: noalias_scopes = [#[[$BAR_STORE]]]
41 // CHECK-SAME: alias_scopes = [#[[$BAR_STORE]]]
42 // CHECK-SAME: noalias_scopes = [#[[$BAR_LOAD]]]
43 llvm.func @clone_alias_scopes(%arg0: !llvm.ptr, %arg1: !llvm.ptr) {
44 llvm.call @foo(%arg0, %arg1) : (!llvm.ptr, !llvm.ptr) -> ()
50 #alias_scope_domain = #llvm.alias_scope_domain<id = distinct[0]<>, description = "hello2">
51 #alias_scope_domain1 = #llvm.alias_scope_domain<id = distinct[1]<>, description = "hello">
52 #alias_scope = #llvm.alias_scope<id = distinct[2]<>, domain = #alias_scope_domain, description = "hello2: %a">
53 #alias_scope1 = #llvm.alias_scope<id = distinct[3]<>, domain = #alias_scope_domain, description = "hello2: %b">
54 #alias_scope2 = #llvm.alias_scope<id = distinct[4]<>, domain = #alias_scope_domain1, description = "hello: %a">
56 // CHECK-DAG: #[[WITH_DOMAIN:.*]] = #llvm.alias_scope_domain<{{.*}}>
57 // CHECK-DAG: #[[$WITH_DOMAIN_SCOPE1:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[WITH_DOMAIN]], description = {{.*}}>
58 // CHECK-DAG: #[[$WITH_DOMAIN_SCOPE2:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[WITH_DOMAIN]], description = {{.*}}>
60 // CHECK-DAG: #[[CALL_DOMAIN:.*]] = #llvm.alias_scope_domain<{{.*}}>
61 // CHECK-DAG: #[[$CALL_DOMAIN_SCOPE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[CALL_DOMAIN]], description = {{.*}}>
63 // CHECK-DAG: #[[WITH_DOMAIN_NO_ALIAS:.*]] = #llvm.alias_scope_domain<{{.*}}>
64 // CHECK-DAG: #[[$WITH_DOMAIN_NO_ALIAS_SCOPE1:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[WITH_DOMAIN_NO_ALIAS]], description = {{.*}}>
65 // CHECK-DAG: #[[$WITH_DOMAIN_NO_ALIAS_SCOPE2:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[WITH_DOMAIN_NO_ALIAS]], description = {{.*}}>
67 // CHECK-DAG: #[[WITH_DOMAIN_ALIAS:.*]] = #llvm.alias_scope_domain<{{.*}}>
68 // CHECK-DAG: #[[$WITH_DOMAIN_ALIAS_SCOPE1:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[WITH_DOMAIN_ALIAS]], description = {{.*}}>
69 // CHECK-DAG: #[[$WITH_DOMAIN_ALIAS_SCOPE2:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[WITH_DOMAIN_ALIAS]], description = {{.*}}>
71 // CHECK-LABEL: llvm.func @callee_with_metadata(
73 // CHECK-SAME: noalias_scopes = [#[[$WITH_DOMAIN_SCOPE1]], #[[$WITH_DOMAIN_SCOPE2]]]
75 // CHECK-SAME: alias_scopes = [#[[$WITH_DOMAIN_SCOPE1]]]
76 // CHECK-SAME: noalias_scopes = [#[[$WITH_DOMAIN_SCOPE2]]]
78 // CHECK-SAME: alias_scopes = [#[[$WITH_DOMAIN_SCOPE2]]]
79 // CHECK-SAME: noalias_scopes = [#[[$WITH_DOMAIN_SCOPE1]]]
81 // CHECK-NOT: {{(no)?}}alias_scopes =
83 // CHECK-NOT: {{(no)?}}alias_scopes =
84 llvm.func @callee_with_metadata(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) {
85 %0 = llvm.mlir.constant(5 : i64) : i64
86 %1 = llvm.mlir.constant(8 : i64) : i64
87 %2 = llvm.mlir.constant(7 : i64) : i64
88 %3 = llvm.load %arg2 {alignment = 4 : i64, noalias_scopes = [#alias_scope, #alias_scope1]} : !llvm.ptr -> f32
89 %4 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, f32
90 llvm.store %3, %4 {alias_scopes = [#alias_scope], alignment = 4 : i64, noalias_scopes = [#alias_scope1]} : f32, !llvm.ptr
91 %5 = llvm.getelementptr inbounds %arg1[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32
92 llvm.store %3, %5 {alias_scopes = [#alias_scope1], alignment = 4 : i64, noalias_scopes = [#alias_scope]} : f32, !llvm.ptr
93 "test.one_region_op"() ({
94 %6 = llvm.load %arg2 {alignment = 4 : i64} : !llvm.ptr -> f32
95 %7 = llvm.getelementptr inbounds %arg0[%2] : (!llvm.ptr, i64) -> !llvm.ptr, f32
96 llvm.store %6, %7 {alignment = 4 : i64} : f32, !llvm.ptr
97 "test.terminator"() : () -> ()
102 // CHECK-LABEL: llvm.func @callee_without_metadata(
103 // CHECK-NOT: {{(no)?}}alias_scopes =
105 llvm.func @callee_without_metadata(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) {
106 %0 = llvm.mlir.constant(5 : i64) : i64
107 %1 = llvm.mlir.constant(8 : i64) : i64
108 %2 = llvm.mlir.constant(7 : i64) : i64
109 %3 = llvm.load %arg2 {alignment = 4 : i64} : !llvm.ptr -> f32
110 %4 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, f32
111 llvm.store %3, %4 {alignment = 4 : i64} : f32, !llvm.ptr
112 %5 = llvm.getelementptr inbounds %arg1[%1] : (!llvm.ptr, i64) -> !llvm.ptr, f32
113 llvm.store %3, %5 {alignment = 4 : i64} : f32, !llvm.ptr
114 "test.one_region_op"() ({
115 %6 = llvm.load %arg2 {alignment = 4 : i64} : !llvm.ptr -> f32
116 %7 = llvm.getelementptr inbounds %arg0[%2] : (!llvm.ptr, i64) -> !llvm.ptr, f32
117 llvm.store %6, %7 {alignment = 4 : i64} : f32, !llvm.ptr
118 "test.terminator"() : () -> ()
124 // CHECK-LABEL: llvm.func @caller(
126 // CHECK-SAME: alias_scopes = [#[[$CALL_DOMAIN_SCOPE]]]
127 // CHECK-NOT: noalias_scopes
129 // Inlining @callee_with_metadata with noalias_scopes.
132 // CHECK-SAME: noalias_scopes = [#[[$WITH_DOMAIN_NO_ALIAS_SCOPE1]], #[[$WITH_DOMAIN_NO_ALIAS_SCOPE2]], #[[$CALL_DOMAIN_SCOPE]]]
134 // CHECK-SAME: alias_scopes = [#[[$WITH_DOMAIN_NO_ALIAS_SCOPE1]]]
135 // CHECK-SAME: noalias_scopes = [#[[$WITH_DOMAIN_NO_ALIAS_SCOPE2]], #[[$CALL_DOMAIN_SCOPE]]]
137 // CHECK-SAME: alias_scopes = [#[[$WITH_DOMAIN_NO_ALIAS_SCOPE2]]]
138 // CHECK-SAME: noalias_scopes = [#[[$WITH_DOMAIN_NO_ALIAS_SCOPE1]], #[[$CALL_DOMAIN_SCOPE]]]
140 // CHECK-NOT: alias_scopes
141 // CHECK-SAME: noalias_scopes = [#[[$CALL_DOMAIN_SCOPE]]]
143 // CHECK-NOT: alias_scopes
144 // CHECK-SAME: noalias_scopes = [#[[$CALL_DOMAIN_SCOPE]]]
146 // Inlining @callee_with_metadata with alias_scopes.
149 // CHECK-SAME: alias_scopes = [#[[$CALL_DOMAIN_SCOPE]]]
150 // CHECK-SAME: noalias_scopes = [#[[$WITH_DOMAIN_ALIAS_SCOPE1]], #[[$WITH_DOMAIN_ALIAS_SCOPE2]]]
152 // CHECK-SAME: alias_scopes = [#[[$WITH_DOMAIN_ALIAS_SCOPE1]], #[[$CALL_DOMAIN_SCOPE]]]
153 // CHECK-SAME: noalias_scopes = [#[[$WITH_DOMAIN_ALIAS_SCOPE2]]]
155 // CHECK-SAME: alias_scopes = [#[[$WITH_DOMAIN_ALIAS_SCOPE2]], #[[$CALL_DOMAIN_SCOPE]]]
156 // CHECK-SAME: noalias_scopes = [#[[$WITH_DOMAIN_ALIAS_SCOPE1]]]
158 // CHECK-SAME: alias_scopes = [#[[$CALL_DOMAIN_SCOPE]]]
159 // CHECK-NOT: noalias_scopes
161 // CHECK-SAME: alias_scopes = [#[[$CALL_DOMAIN_SCOPE]]]
162 // CHECK-NOT: noalias_scopes
164 // Inlining @callee_without_metadata with noalias_scopes.
167 // CHECK-NOT: alias_scopes
168 // CHECK-SAME: noalias_scopes = [#[[$CALL_DOMAIN_SCOPE]]]
170 // CHECK-NOT: alias_scopes
171 // CHECK-SAME: noalias_scopes = [#[[$CALL_DOMAIN_SCOPE]]]
173 // CHECK-NOT: alias_scopes
174 // CHECK-SAME: noalias_scopes = [#[[$CALL_DOMAIN_SCOPE]]]
176 // CHECK-NOT: alias_scopes
177 // CHECK-SAME: noalias_scopes = [#[[$CALL_DOMAIN_SCOPE]]]
179 // CHECK-NOT: alias_scopes
180 // CHECK-SAME: noalias_scopes = [#[[$CALL_DOMAIN_SCOPE]]]
182 // Inlining @callee_without_metadata with alias_scopes.
185 // CHECK-SAME: alias_scopes = [#[[$CALL_DOMAIN_SCOPE]]]
186 // CHECK-NOT: noalias_scopes
188 // CHECK-SAME: alias_scopes = [#[[$CALL_DOMAIN_SCOPE]]]
189 // CHECK-NOT: noalias_scopes
191 // CHECK-SAME: alias_scopes = [#[[$CALL_DOMAIN_SCOPE]]]
192 // CHECK-NOT: noalias_scopes
194 // CHECK-SAME: alias_scopes = [#[[$CALL_DOMAIN_SCOPE]]]
195 // CHECK-NOT: noalias_scopes
197 // CHECK-SAME: alias_scopes = [#[[$CALL_DOMAIN_SCOPE]]]
198 // CHECK-NOT: noalias_scopes
200 llvm.func @caller(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) {
201 %0 = llvm.load %arg2 {alias_scopes = [#alias_scope2], alignment = 8 : i64} : !llvm.ptr -> !llvm.ptr
202 llvm.call @callee_with_metadata(%arg0, %arg1, %0) {noalias_scopes = [#alias_scope2]} : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
203 llvm.call @callee_with_metadata(%arg1, %arg1, %arg0) {alias_scopes = [#alias_scope2]} : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
204 llvm.call @callee_without_metadata(%arg0, %arg1, %0) {noalias_scopes = [#alias_scope2]} : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
205 llvm.call @callee_without_metadata(%arg1, %arg1, %arg0) {alias_scopes = [#alias_scope2]} : (!llvm.ptr, !llvm.ptr, !llvm.ptr) -> ()
211 // CHECK-DAG: #[[DOMAIN:.*]] = #llvm.alias_scope_domain<{{.*}}>
212 // CHECK-DAG: #[[$ARG0_SCOPE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[DOMAIN]]{{(,.*)?}}>
213 // CHECK-DAG: #[[$ARG1_SCOPE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[DOMAIN]]{{(,.*)?}}>
215 llvm.func @foo(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) {
216 %0 = llvm.mlir.constant(5 : i64) : i64
217 %1 = llvm.load %arg1 {alignment = 4 : i64} : !llvm.ptr -> f32
218 %2 = llvm.getelementptr inbounds %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, f32
219 llvm.store %1, %2 {alignment = 4 : i64} : f32, !llvm.ptr
223 // CHECK-LABEL: llvm.func @bar
225 // CHECK-SAME: alias_scopes = [#[[$ARG1_SCOPE]]]
226 // CHECK-SAME: noalias_scopes = [#[[$ARG0_SCOPE]]]
228 // CHECK-SAME: alias_scopes = [#[[$ARG0_SCOPE]]]
229 // CHECK-SAME: noalias_scopes = [#[[$ARG1_SCOPE]]]
230 llvm.func @bar(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) {
231 llvm.call @foo(%arg0, %arg2) : (!llvm.ptr, !llvm.ptr) -> ()
237 // CHECK-DAG: #[[DOMAIN:.*]] = #llvm.alias_scope_domain<{{.*}}>
238 // CHECK-DAG: #[[$ARG_SCOPE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[DOMAIN]]{{(,.*)?}}>
240 llvm.func @foo(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr) {
241 %0 = llvm.mlir.constant(5 : i64) : i64
242 %1 = llvm.load %arg0 {alignment = 4 : i64} : !llvm.ptr -> f32
243 %2 = llvm.getelementptr inbounds %arg1[%0] : (!llvm.ptr, i64) -> !llvm.ptr, f32
244 llvm.store %1, %2 {alignment = 4 : i64} : f32, !llvm.ptr
248 // CHECK-LABEL: llvm.func @missing_noalias_on_one_ptr
250 // CHECK-SAME: alias_scopes = [#[[$ARG_SCOPE]]]
252 // CHECK-SAME: noalias_scopes = [#[[$ARG_SCOPE]]]
253 llvm.func @missing_noalias_on_one_ptr(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) {
254 llvm.call @foo(%arg0, %arg2) : (!llvm.ptr, !llvm.ptr) -> ()
260 // CHECK-DAG: #[[DOMAIN:.*]] = #llvm.alias_scope_domain<{{.*}}>
261 // CHECK-DAG: #[[$ARG0_SCOPE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[DOMAIN]]{{(,.*)?}}>
262 // CHECK-DAG: #[[$ARG1_SCOPE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[DOMAIN]]{{(,.*)?}}>
264 llvm.func @might_return_arg_derived(!llvm.ptr) -> !llvm.ptr
266 llvm.func @foo(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) {
267 %0 = llvm.mlir.constant(5 : i64) : i32
268 %1 = llvm.call @might_return_arg_derived(%arg0) : (!llvm.ptr) -> !llvm.ptr
269 llvm.store %0, %1 : i32, !llvm.ptr
273 // CHECK-LABEL: llvm.func @bar
275 // CHECK-NOT: alias_scopes
276 // CHECK-SAME: noalias_scopes = [#[[$ARG1_SCOPE]]]
278 // CHECK-NOT: alias_scopes
279 // CHECK-NOT: noalias_scopes
280 llvm.func @bar(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) {
281 llvm.call @foo(%arg0, %arg2) : (!llvm.ptr, !llvm.ptr) -> ()
287 // CHECK-DAG: #[[DOMAIN:.*]] = #llvm.alias_scope_domain<{{.*}}>
288 // CHECK-DAG: #[[$ARG0_SCOPE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[DOMAIN]]{{(,.*)?}}>
289 // CHECK-DAG: #[[$ARG1_SCOPE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[DOMAIN]]{{(,.*)?}}>
291 llvm.func @random() -> i1
293 llvm.func @block_arg(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) {
294 %0 = llvm.mlir.constant(5 : i64) : i32
295 %1 = llvm.call @random() : () -> i1
296 llvm.cond_br %1, ^bb0(%arg0 : !llvm.ptr), ^bb0(%arg1 : !llvm.ptr)
298 ^bb0(%arg2: !llvm.ptr):
299 llvm.store %0, %arg2 : i32, !llvm.ptr
303 // CHECK-LABEL: llvm.func @bar
305 // CHECK-NOT: alias_scopes
306 // CHECK-SAME: noalias_scopes = [#[[$ARG0_SCOPE]], #[[$ARG1_SCOPE]]]
308 // CHECK: alias_scopes = [#[[$ARG0_SCOPE]], #[[$ARG1_SCOPE]]]
309 llvm.func @bar(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) {
310 llvm.call @block_arg(%arg0, %arg2) : (!llvm.ptr, !llvm.ptr) -> ()
316 // CHECK-DAG: #[[DOMAIN:.*]] = #llvm.alias_scope_domain<{{.*}}>
317 // CHECK-DAG: #[[$ARG0_SCOPE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[DOMAIN]]{{(,.*)?}}>
318 // CHECK-DAG: #[[$ARG1_SCOPE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[DOMAIN]]{{(,.*)?}}>
320 llvm.func @random() -> i1
322 llvm.func @region_branch(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) {
323 %0 = llvm.mlir.constant(5 : i64) : i32
324 test.region_if %arg0: !llvm.ptr -> !llvm.ptr then {
325 ^bb0(%arg2: !llvm.ptr):
326 test.region_if_yield %arg0 : !llvm.ptr
328 ^bb0(%arg2: !llvm.ptr):
329 test.region_if_yield %arg0 : !llvm.ptr
331 ^bb0(%arg2: !llvm.ptr):
332 llvm.store %0, %arg2 : i32, !llvm.ptr
333 test.region_if_yield %arg0 : !llvm.ptr
338 // CHECK-LABEL: llvm.func @region_branch_inlining
340 // CHECK-SAME: alias_scopes = [#[[$ARG0_SCOPE]]]
341 // CHECK-SAME: noalias_scopes = [#[[$ARG1_SCOPE]]]
342 llvm.func @region_branch_inlining(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) {
343 llvm.call @region_branch(%arg0, %arg2) : (!llvm.ptr, !llvm.ptr) -> ()
349 llvm.func @missing_region_branch(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) {
350 %0 = llvm.mlir.constant(5 : i64) : i32
351 "test.one_region_op"() ({
352 ^bb0(%arg2: !llvm.ptr):
353 llvm.store %0, %arg2 : i32, !llvm.ptr
354 "test.terminator"() : () -> ()
359 // CHECK-LABEL: llvm.func @missing_region_branch_inlining
361 // CHECK-NOT: alias_scopes
362 // CHECK-NOT: noalias_scopes
363 llvm.func @missing_region_branch_inlining(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) {
364 llvm.call @missing_region_branch(%arg0, %arg2) : (!llvm.ptr, !llvm.ptr) -> ()
370 // CHECK-DAG: #[[DOMAIN:.*]] = #llvm.alias_scope_domain<{{.*}}>
371 // CHECK-DAG: #[[$ARG0_SCOPE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[DOMAIN]]{{(,.*)?}}>
372 // CHECK-DAG: #[[$ARG1_SCOPE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[DOMAIN]]{{(,.*)?}}>
374 llvm.func @random() -> i1
376 llvm.func @block_arg(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) {
377 %0 = llvm.mlir.constant(5 : i64) : i32
378 %1 = llvm.mlir.constant(1 : i64) : i64
379 %2 = llvm.alloca %1 x i32 : (i64) -> !llvm.ptr
380 %3 = llvm.call @random() : () -> i1
381 llvm.cond_br %3, ^bb0(%arg0 : !llvm.ptr), ^bb0(%2 : !llvm.ptr)
383 ^bb0(%arg2: !llvm.ptr):
384 llvm.store %0, %arg2 : i32, !llvm.ptr
388 // CHECK-LABEL: llvm.func @bar
390 // CHECK-NOT: alias_scopes
391 // CHECK-SAME: noalias_scopes = [#[[$ARG0_SCOPE]], #[[$ARG1_SCOPE]]]
393 // CHECK-NOT: alias_scopes
394 // CHECK-SAME: noalias_scopes = [#[[$ARG1_SCOPE]]]
395 llvm.func @bar(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) {
396 llvm.call @block_arg(%arg0, %arg2) : (!llvm.ptr, !llvm.ptr) -> ()
402 // CHECK-DAG: #[[DOMAIN:.*]] = #llvm.alias_scope_domain<{{.*}}>
403 // CHECK-DAG: #[[$ARG0_SCOPE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[DOMAIN]]{{(,.*)?}}>
404 // CHECK-DAG: #[[$ARG1_SCOPE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[DOMAIN]]{{(,.*)?}}>
406 llvm.func @unknown() -> !llvm.ptr
407 llvm.func @random() -> i1
409 llvm.func @unknown_object(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) {
410 %0 = llvm.mlir.constant(5 : i64) : i32
411 %1 = llvm.call @random() : () -> i1
412 %2 = llvm.call @unknown() : () -> !llvm.ptr
413 llvm.cond_br %1, ^bb0(%arg0 : !llvm.ptr), ^bb0(%2 : !llvm.ptr)
415 ^bb0(%arg2: !llvm.ptr):
416 llvm.store %0, %arg2 : i32, !llvm.ptr
420 // CHECK-LABEL: llvm.func @bar
422 // CHECK-NOT: alias_scopes
423 // CHECK-SAME: noalias_scopes = [#[[$ARG0_SCOPE]], #[[$ARG1_SCOPE]]]
425 // CHECK-NOT: alias_scopes
426 // CHECK-SAME: noalias_scopes = [#[[$ARG0_SCOPE]], #[[$ARG1_SCOPE]]]
428 // CHECK-NOT: alias_scopes
429 // CHECK-NOT: noalias_scopes
430 llvm.func @bar(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) {
431 llvm.call @unknown_object(%arg0, %arg2) : (!llvm.ptr, !llvm.ptr) -> ()
437 // CHECK-DAG: #[[DOMAIN:.*]] = #llvm.alias_scope_domain<{{.*}}>
438 // CHECK-DAG: #[[$ARG0_SCOPE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[DOMAIN]]{{(,.*)?}}>
439 // CHECK-DAG: #[[$ARG1_SCOPE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[DOMAIN]]{{(,.*)?}}>
441 llvm.func @supported_operations(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr {llvm.noalias}) {
442 %0 = llvm.mlir.constant(5 : i64) : i32
443 llvm.store %0, %arg1 : i32, !llvm.ptr
444 %1 = llvm.load %arg1 : !llvm.ptr -> i32
445 "llvm.intr.memcpy"(%arg0, %arg1, %1) <{ isVolatile = false }> : (!llvm.ptr, !llvm.ptr, i32) -> ()
446 "llvm.intr.memmove"(%arg0, %arg1, %1) <{ isVolatile = false }> : (!llvm.ptr, !llvm.ptr, i32) -> ()
447 "llvm.intr.memcpy.inline"(%arg0, %arg1) <{ isVolatile = false, len = 4 : i32}> : (!llvm.ptr, !llvm.ptr) -> ()
448 %2 = llvm.trunc %0 : i32 to i8
449 "llvm.intr.memset"(%arg0, %2, %1) <{ isVolatile = false}> : (!llvm.ptr, i8, i32) -> ()
450 %3 = llvm.cmpxchg %arg0, %0, %1 seq_cst seq_cst : !llvm.ptr, i32
451 %4 = llvm.atomicrmw add %arg0, %0 seq_cst : !llvm.ptr, i32
455 // CHECK-LABEL: llvm.func @bar
457 // CHECK-SAME: alias_scopes = [#[[$ARG1_SCOPE]]]
458 // CHECK-SAME: noalias_scopes = [#[[$ARG0_SCOPE]]]
460 // CHECK-SAME: alias_scopes = [#[[$ARG1_SCOPE]]]
461 // CHECK-SAME: noalias_scopes = [#[[$ARG0_SCOPE]]]
462 // CHECK: "llvm.intr.memcpy"
463 // CHECK-SAME: alias_scopes = [#[[$ARG0_SCOPE]], #[[$ARG1_SCOPE]]]
464 // CHECK-NOT: noalias_scopes
465 // CHECK: "llvm.intr.memmove"
466 // CHECK-SAME: alias_scopes = [#[[$ARG0_SCOPE]], #[[$ARG1_SCOPE]]]
467 // CHECK-NOT: noalias_scopes
468 // CHECK: "llvm.intr.memcpy.inline"
469 // CHECK-SAME: alias_scopes = [#[[$ARG0_SCOPE]], #[[$ARG1_SCOPE]]]
470 // CHECK-NOT: noalias_scopes
471 // CHECK: "llvm.intr.memset"
472 // CHECK-SAME: alias_scopes = [#[[$ARG0_SCOPE]]]
473 // CHECK-SAME: noalias_scopes = [#[[$ARG1_SCOPE]]]
474 // CHECK: llvm.cmpxchg
475 // CHECK-SAME: alias_scopes = [#[[$ARG0_SCOPE]]]
476 // CHECK-SAME: noalias_scopes = [#[[$ARG1_SCOPE]]]
477 // CHECK: llvm.atomicrmw
478 // CHECK-SAME: alias_scopes = [#[[$ARG0_SCOPE]]]
479 // CHECK-SAME: noalias_scopes = [#[[$ARG1_SCOPE]]]
480 llvm.func @bar(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr) {
481 llvm.call @supported_operations(%arg0, %arg2) : (!llvm.ptr, !llvm.ptr) -> ()
487 // CHECK-DAG: #[[DOMAIN:.*]] = #llvm.alias_scope_domain<{{.*}}>
488 // CHECK-DAG: #[[$ARG_SCOPE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[DOMAIN]]{{(,.*)?}}>
490 llvm.func @foo(%arg: i32)
492 llvm.func @region(%arg0: !llvm.ptr {llvm.noalias}) {
493 "test.one_region_op"() ({
494 %1 = llvm.load %arg0 : !llvm.ptr -> i32
495 llvm.call @foo(%1) : (i32) -> ()
496 "test.terminator"() : () -> ()
501 // CHECK-LABEL: llvm.func @noalias_with_region
503 // CHECK-SAME: alias_scopes = [#[[$ARG_SCOPE]]]
505 // CHECK-NOT: alias_scopes
506 // CHECK-SAME: noalias_scopes = [#[[$ARG_SCOPE]]]
507 llvm.func @noalias_with_region(%arg0: !llvm.ptr) {
508 llvm.call @region(%arg0) : (!llvm.ptr) -> ()
514 // CHECK-DAG: #[[DOMAIN:.*]] = #llvm.alias_scope_domain<{{.*}}>
515 // CHECK-DAG: #[[$ARG_SCOPE:.*]] = #llvm.alias_scope<id = {{.*}}, domain = #[[DOMAIN]]{{(,.*)?}}>
517 llvm.func @foo(%arg: i32)
519 llvm.func @func(%arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr) {
520 %cond = llvm.load %arg1 : !llvm.ptr -> i1
521 %1 = llvm.getelementptr inbounds %arg0[1] : (!llvm.ptr) -> !llvm.ptr, f32
522 %selected = llvm.select %cond, %arg0, %1 : i1, !llvm.ptr
523 %2 = llvm.load %selected : !llvm.ptr -> i32
524 llvm.call @foo(%2) : (i32) -> ()
528 // CHECK-LABEL: llvm.func @selects
530 // CHECK-NOT: alias_scopes
531 // CHECK-SAME: noalias_scopes = [#[[$ARG_SCOPE]]]
533 // CHECK-SAME: alias_scopes = [#[[$ARG_SCOPE]]]
534 llvm.func @selects(%arg0: !llvm.ptr, %arg1: !llvm.ptr) {
535 llvm.call @func(%arg0, %arg1) : (!llvm.ptr, !llvm.ptr) -> ()
541 llvm.func @foo(%arg: i32)
543 llvm.func @func(%cond: i1, %arg0: !llvm.ptr {llvm.noalias}, %arg1: !llvm.ptr) {
544 %selected = llvm.select %cond, %arg0, %arg1 : i1, !llvm.ptr
545 %2 = llvm.load %selected : !llvm.ptr -> i32
546 llvm.call @foo(%2) : (i32) -> ()
550 // CHECK-LABEL: llvm.func @multi_ptr_select
552 // CHECK-NOT: alias_scopes
553 // CHECK-NOT: noalias_scopes
554 // CHECK: llvm.call @foo
555 llvm.func @multi_ptr_select(%cond: i1, %arg0: !llvm.ptr, %arg1: !llvm.ptr) {
556 llvm.call @func(%cond, %arg0, %arg1) : (i1, !llvm.ptr, !llvm.ptr) -> ()