@@ -1100,6 +1100,131 @@ bb0:
1100
1100
return %4 : $()
1101
1101
}
1102
1102
1103
+ // CHECK-LABEL: @test_builtin_zeroInitializer_atomicload
1104
+ // CHECK: PAIR #0.
1105
+ // CHECK-NEXT: %2 = builtin "zeroInitializer"<C>(%1 : $*C)
1106
+ // CHECK-NEXT: %0 = alloc_stack
1107
+ // CHECK-NEXT: r=0,w=0
1108
+ // CHECK: PAIR #1.
1109
+ // CHECK-NEXT: %2 = builtin "zeroInitializer"<C>(%1 : $*C)
1110
+ // CHECK-NEXT: %1 = alloc_stack
1111
+ // CHECK-NEXT: r=0,w=1
1112
+ sil @test_builtin_zeroInitializer_atomicload : $@convention(thin) () -> Builtin.Int64 {
1113
+ bb0:
1114
+ %0 = alloc_stack $C
1115
+ %1 = alloc_stack $C
1116
+ %2 = builtin "zeroInitializer"<C>(%1 : $*C) : $()
1117
+ %3 = apply undef<C>(%1) : $@convention(thin) <C> () -> @out C
1118
+ copy_addr [take] %1 to [init] %0 : $*C
1119
+ dealloc_stack %1 : $*C
1120
+ %4 = address_to_pointer %0 : $*C to $Builtin.RawPointer
1121
+ %5 = builtin "atomicload_monotonic_Int64"(%4 : $Builtin.RawPointer) : $Builtin.Int64
1122
+ destroy_addr %0 : $*C
1123
+ dealloc_stack %0 : $*C
1124
+ return %5 : $Builtin.Int64
1125
+ }
1126
+
1127
+ // CHECK-LABEL: @test_builtin_zeroInitializer_atomicstore
1128
+ // CHECK: PAIR #0.
1129
+ // CHECK-NEXT: %2 = builtin "zeroInitializer"<C>(%1 : $*C)
1130
+ // CHECK-NEXT: %0 = alloc_stack
1131
+ // CHECK-NEXT: r=0,w=0
1132
+ // CHECK: PAIR #1.
1133
+ // CHECK-NEXT: %2 = builtin "zeroInitializer"<C>(%1 : $*C)
1134
+ // CHECK-NEXT: %1 = alloc_stack
1135
+ // CHECK-NEXT: r=0,w=1
1136
+ sil @test_builtin_zeroInitializer_atomicstore : $@convention(thin) () -> () {
1137
+ bb0:
1138
+ %0 = alloc_stack $C
1139
+ %1 = alloc_stack $C
1140
+ %2 = builtin "zeroInitializer"<C>(%1 : $*C) : $()
1141
+ %3 = apply undef<C>(%1) : $@convention(thin) <C> () -> @out C
1142
+ copy_addr [take] %1 to [init] %0 : $*C
1143
+ dealloc_stack %1 : $*C
1144
+ %4 = address_to_pointer %0 : $*C to $Builtin.RawPointer
1145
+ %5 = integer_literal $Builtin.Int64, 1
1146
+ %6 = builtin "atomicstore_monotonic_Int64"(%4 : $Builtin.RawPointer, %5 : $Builtin.Int64) : $()
1147
+ destroy_addr %0 : $*C
1148
+ dealloc_stack %0 : $*C
1149
+ %7 = tuple ()
1150
+ return %7 : $()
1151
+ }
1152
+
1153
+ // CHECK-LABEL: @test_builtin_zeroInitializer_atomicrmw
1154
+ // CHECK: PAIR #0.
1155
+ // CHECK-NEXT: %2 = builtin "zeroInitializer"<C>(%1 : $*C)
1156
+ // CHECK-NEXT: %0 = alloc_stack
1157
+ // CHECK-NEXT: r=0,w=0
1158
+ // CHECK: PAIR #1.
1159
+ // CHECK-NEXT: %2 = builtin "zeroInitializer"<C>(%1 : $*C)
1160
+ // CHECK-NEXT: %1 = alloc_stack
1161
+ // CHECK-NEXT: r=0,w=1
1162
+ sil @test_builtin_zeroInitializer_atomicrmw : $@convention(thin) () -> (Builtin.Int64, Builtin.Int64) {
1163
+ bb0:
1164
+ %0 = alloc_stack $C
1165
+ %1 = alloc_stack $C
1166
+ %2 = builtin "zeroInitializer"<C>(%1 : $*C) : $()
1167
+ %3 = apply undef<C>(%1) : $@convention(thin) <C> () -> @out C
1168
+ copy_addr [take] %1 to [init] %0 : $*C
1169
+ dealloc_stack %1 : $*C
1170
+ %4 = address_to_pointer %0 : $*C to $Builtin.RawPointer
1171
+ %5 = integer_literal $Builtin.Int64, 1
1172
+ %6 = builtin "atomicrmw_xchg_monotonic_Int64"(%4 : $Builtin.RawPointer, %5 : $Builtin.Int64) : $Builtin.Int64
1173
+ %7 = builtin "atomicrmw_add_monotonic_Int64"(%4 : $Builtin.RawPointer, %5 : $Builtin.Int64) : $Builtin.Int64
1174
+ destroy_addr %0 : $*C
1175
+ dealloc_stack %0 : $*C
1176
+ %8 = tuple (%6 : $Builtin.Int64, %7 : $Builtin.Int64)
1177
+ return %8 : $(Builtin.Int64, Builtin.Int64)
1178
+ }
1179
+
1180
+ // CHECK-LABEL: @test_builtin_zeroInitializer_cmpxchg
1181
+ // CHECK: PAIR #0.
1182
+ // CHECK-NEXT: %2 = builtin "zeroInitializer"<C>(%1 : $*C)
1183
+ // CHECK-NEXT: %0 = alloc_stack
1184
+ // CHECK-NEXT: r=0,w=0
1185
+ // CHECK: PAIR #1.
1186
+ // CHECK-NEXT: %2 = builtin "zeroInitializer"<C>(%1 : $*C)
1187
+ // CHECK-NEXT: %1 = alloc_stack
1188
+ // CHECK-NEXT: r=0,w=1
1189
+ sil @test_builtin_zeroInitializer_cmpxchg : $@convention(thin) () -> (Builtin.Int64, Builtin.Int1) {
1190
+ bb0:
1191
+ %0 = alloc_stack $C
1192
+ %1 = alloc_stack $C
1193
+ %2 = builtin "zeroInitializer"<C>(%1 : $*C) : $()
1194
+ %3 = apply undef<C>(%1) : $@convention(thin) <C> () -> @out C
1195
+ copy_addr [take] %1 to [init] %0 : $*C
1196
+ dealloc_stack %1 : $*C
1197
+ %4 = address_to_pointer %0 : $*C to $Builtin.RawPointer
1198
+ %5 = integer_literal $Builtin.Int64, 1
1199
+ %6 = builtin "cmpxchg_monotonic_monotonic_Int64"(%4 : $Builtin.RawPointer, %5 : $Builtin.Int64) : $(Builtin.Int64, Builtin.Int1)
1200
+ destroy_addr %0 : $*C
1201
+ dealloc_stack %0 : $*C
1202
+ return %6 : $(Builtin.Int64, Builtin.Int1)
1203
+ }
1204
+
1205
+ // CHECK-LABEL: @test_builtin_zeroInitializer_fence
1206
+ // CHECK: PAIR #0.
1207
+ // CHECK-NEXT: %2 = builtin "zeroInitializer"<C>(%1 : $*C)
1208
+ // CHECK-NEXT: %0 = alloc_stack
1209
+ // CHECK-NEXT: r=0,w=0
1210
+ // CHECK: PAIR #1.
1211
+ // CHECK-NEXT: %2 = builtin "zeroInitializer"<C>(%1 : $*C)
1212
+ // CHECK-NEXT: %1 = alloc_stack
1213
+ // CHECK-NEXT: r=0,w=1
1214
+ sil @test_builtin_zeroInitializer_fence : $@convention(thin) () -> () {
1215
+ bb0:
1216
+ %0 = alloc_stack $C
1217
+ %1 = alloc_stack $C
1218
+ %2 = builtin "zeroInitializer"<C>(%1 : $*C) : $()
1219
+ %3 = apply undef<C>(%1) : $@convention(thin) <C> () -> @out C
1220
+ copy_addr [take] %1 to [init] %0 : $*C
1221
+ dealloc_stack %1 : $*C
1222
+ %5 = builtin "fence_release"() : $()
1223
+ destroy_addr %0 : $*C
1224
+ dealloc_stack %0 : $*C
1225
+ return %5 : $()
1226
+ }
1227
+
1103
1228
// CHECK-LABEL: @test_stored_pointer
1104
1229
// CHECK: PAIR #3.
1105
1230
// CHECK-NEXT: %5 = apply %4(%2) : $@convention(thin) (@in Builtin.RawPointer) -> ()
0 commit comments