@@ -104,3 +104,54 @@ llvm.func @self_reference() {
104104// CHECK-DAG: ![[SCOPES]] = !{![[SCOPE]]}
105105// CHECK-DAG: = !DISubroutineType(types: ![[TYPES:[0-9]+]])
106106// CHECK-DAG: ![[TYPES]] = !{null}
107+
108+ // -----
109+
110+ llvm.func @foo (%arg0: !llvm.ptr )
111+
112+ #alias_scope_domain = #llvm.alias_scope_domain <id = " domain1" , description = " The domain" >
113+ #alias_scope1 = #llvm.alias_scope <id = " scope1" , domain = #alias_scope_domain , description = " The first scope" >
114+ #alias_scope2 = #llvm.alias_scope <id = " scope2" , domain = #alias_scope_domain >
115+ #alias_scope3 = #llvm.alias_scope <id = " scope3" , domain = #alias_scope_domain >
116+
117+ // CHECK-LABEL: @alias_scopes
118+ llvm.func @alias_scopes (%arg1 : !llvm.ptr ) {
119+ %0 = llvm.mlir.constant (0 : i32 ) : i32
120+ // CHECK: call void @llvm.experimental.noalias.scope.decl(metadata ![[SCOPES1:[0-9]+]])
121+ llvm.intr.experimental.noalias.scope.decl #alias_scope1
122+ // CHECK: store {{.*}}, !alias.scope ![[SCOPES1]], !noalias ![[SCOPES23:[0-9]+]]
123+ llvm.store %0 , %arg1 {alias_scopes = [#alias_scope1 ], noalias_scopes = [#alias_scope2 , #alias_scope3 ]} : i32 , !llvm.ptr
124+ // CHECK: load {{.*}}, !alias.scope ![[SCOPES2:[0-9]+]], !noalias ![[SCOPES13:[0-9]+]]
125+ %1 = llvm.load %arg1 {alias_scopes = [#alias_scope2 ], noalias_scopes = [#alias_scope1 , #alias_scope3 ]} : !llvm.ptr -> i32
126+ // CHECK: atomicrmw {{.*}}, !alias.scope ![[SCOPES3:[0-9]+]], !noalias ![[SCOPES12:[0-9]+]]
127+ %2 = llvm.atomicrmw add %arg1 , %0 monotonic {alias_scopes = [#alias_scope3 ], noalias_scopes = [#alias_scope1 , #alias_scope2 ]} : !llvm.ptr , i32
128+ // CHECK: cmpxchg {{.*}}, !alias.scope ![[SCOPES3]]
129+ %3 = llvm.cmpxchg %arg1 , %1 , %2 acq_rel monotonic {alias_scopes = [#alias_scope3 ]} : !llvm.ptr , i32
130+ %5 = llvm.mlir.constant (42 : i8 ) : i8
131+ // CHECK: llvm.memcpy{{.*}}, !alias.scope ![[SCOPES3]]
132+ " llvm.intr.memcpy" (%arg1 , %arg1 , %0 ) <{isVolatile = false }> {alias_scopes = [#alias_scope3 ]} : (!llvm.ptr , !llvm.ptr , i32 ) -> ()
133+ // CHECK: llvm.memset{{.*}}, !noalias ![[SCOPES3]]
134+ " llvm.intr.memset" (%arg1 , %5 , %0 ) <{isVolatile = false }> {noalias_scopes = [#alias_scope3 ]} : (!llvm.ptr , i8 , i32 ) -> ()
135+ // CHECK: call void @foo({{.*}} !alias.scope ![[SCOPES3]]
136+ llvm.call @foo (%arg1 ) {alias_scopes = [#alias_scope3 ]} : (!llvm.ptr ) -> ()
137+ // CHECK: call void @foo({{.*}} !noalias ![[SCOPES3]]
138+ llvm.call @foo (%arg1 ) {noalias_scopes = [#alias_scope3 ]} : (!llvm.ptr ) -> ()
139+ llvm.return
140+ }
141+
142+ // Check the intrinsic declarations.
143+ // CHECK-DAG: declare void @llvm.experimental.noalias.scope.decl(metadata)
144+ // CHECK-DAG: declare void @llvm.memcpy.p0.p0.i32(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i32, i1 immarg)
145+ // CHECK-DAG: declare void @llvm.memset.p0.i32(ptr nocapture writeonly, i8, i32, i1 immarg)
146+
147+ // Check the translated metadata.
148+ // CHECK-DAG: ![[DOMAIN:[0-9]+]] = !{!"domain1", !"The domain"}
149+ // CHECK-DAG: ![[SCOPE1:[0-9]+]] = !{!"scope1", ![[DOMAIN]], !"The first scope"}
150+ // CHECK-DAG: ![[SCOPE2:[0-9]+]] = !{!"scope2", ![[DOMAIN]]}
151+ // CHECK-DAG: ![[SCOPE3:[0-9]+]] = !{!"scope3", ![[DOMAIN]]}
152+ // CHECK-DAG: ![[SCOPES1]] = !{![[SCOPE1]]}
153+ // CHECK-DAG: ![[SCOPES2]] = !{![[SCOPE2]]}
154+ // CHECK-DAG: ![[SCOPES3]] = !{![[SCOPE3]]}
155+ // CHECK-DAG: ![[SCOPES12]] = !{![[SCOPE1]], ![[SCOPE2]]}
156+ // CHECK-DAG: ![[SCOPES13]] = !{![[SCOPE1]], ![[SCOPE3]]}
157+ // CHECK-DAG: ![[SCOPES23]] = !{![[SCOPE2]], ![[SCOPE3]]}
0 commit comments