@@ -2251,3 +2251,47 @@ bb0:
2251
2251
%9999 = tuple()
2252
2252
return %9999 : $()
2253
2253
}
2254
+
2255
+ //===----------------------------------------------------------------------===//
2256
+ // Test invoking EscapeAnalysis:mayReleaseContent on a builtin that takes
2257
+ // an address. This should simply not assert.
2258
+ //
2259
+ // <rdar://problem/60190962> Escape analysis crashes with
2260
+ // "an address is never a reference" error with -O -thread=sanitize
2261
+ //===----------------------------------------------------------------------===//
2262
+
2263
+ // bufferMemory
2264
+ sil_global hidden @$s4test12bufferMemorySpys5UInt8VGvp : $UnsafeMutablePointer<UInt8>
2265
+
2266
+ // x
2267
+ sil_global hidden @$s4test1xypvp : $Any
2268
+
2269
+ sil [serialized] [always_inline] [readonly] [_semantics "string.makeUTF8"] @$sSS21_builtinStringLiteral17utf8CodeUnitCount7isASCIISSBp_BwBi1_tcfC : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> @owned String
2270
+
2271
+ // CHECK-LABEL: sil @testTsanInoutAccess : $@convention(thin) () -> () {
2272
+ // CHECK: alloc_global @$s4test12bufferMemorySpys5UInt8VGvp
2273
+ // CHECK: [[GLOBAL:%.*]] = global_addr @$s4test12bufferMemorySpys5UInt8VGvp : $*UnsafeMutablePointer<UInt8>
2274
+ // CHECK: [[ACCESS:%.*]] = begin_access [modify] [dynamic] [[GLOBAL]] : $*UnsafeMutablePointer<UInt8>
2275
+ // CHECK: builtin "tsanInoutAccess"([[ACCESS]] : $*UnsafeMutablePointer<UInt8>) : $()
2276
+ // CHECK-LABEL: } // end sil function 'testTsanInoutAccess'
2277
+ sil @testTsanInoutAccess : $@convention(thin) () -> () {
2278
+ bb0:
2279
+ alloc_global @$s4test12bufferMemorySpys5UInt8VGvp
2280
+ %1 = global_addr @$s4test12bufferMemorySpys5UInt8VGvp : $*UnsafeMutablePointer<UInt8>
2281
+ %2 = integer_literal $Builtin.Int1, -1
2282
+ alloc_global @$s4test1xypvp
2283
+ %4 = global_addr @$s4test1xypvp : $*Any
2284
+ %5 = string_literal utf8 ""
2285
+ %6 = integer_literal $Builtin.Word, 0
2286
+ %7 = metatype $@thin String.Type
2287
+ // function_ref String.init(_builtinStringLiteral:utf8CodeUnitCount:isASCII:)
2288
+ %8 = function_ref @$sSS21_builtinStringLiteral17utf8CodeUnitCount7isASCIISSBp_BwBi1_tcfC : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> @owned String
2289
+ %9 = apply %8(%5, %6, %2, %7) : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> @owned String
2290
+ %10 = init_existential_addr %4 : $*Any, $String
2291
+ store %9 to %10 : $*String
2292
+ %12 = begin_access [modify] [dynamic] %1 : $*UnsafeMutablePointer<UInt8>
2293
+ %13 = builtin "tsanInoutAccess"(%12 : $*UnsafeMutablePointer<UInt8>) : $()
2294
+ end_access %12 : $*UnsafeMutablePointer<UInt8>
2295
+ %15 = tuple ()
2296
+ return %15 : $()
2297
+ }
0 commit comments