@@ -254,6 +254,8 @@ func testArrayUninitializedIntrinsic(_ x: Float, _ y: Float) -> [Float] {
254
254
// CHECK: [ACTIVE] %9 = pointer_to_address %8 : $Builtin.RawPointer to [strict] $*Float
255
255
// CHECK: [VARIED] %11 = integer_literal $Builtin.Word, 1
256
256
// CHECK: [ACTIVE] %12 = index_addr %9 : $*Float, %11 : $Builtin.Word
257
+ // CHECK: [NONE] // function_ref _finalizeUninitializedArray<A>(_:)
258
+ // CHECK: [ACTIVE] %15 = apply %14<Float>(%7) : $@convention(thin) <τ_0_0> (@owned Array<τ_0_0>) -> @owned Array<τ_0_0>
257
259
258
260
@differentiable ( where T: Differentiable)
259
261
func testArrayUninitializedIntrinsicGeneric< T> ( _ x: T , _ y: T ) -> [ T ] {
@@ -271,6 +273,8 @@ func testArrayUninitializedIntrinsicGeneric<T>(_ x: T, _ y: T) -> [T] {
271
273
// CHECK: [ACTIVE] %9 = pointer_to_address %8 : $Builtin.RawPointer to [strict] $*T
272
274
// CHECK: [VARIED] %11 = integer_literal $Builtin.Word, 1
273
275
// CHECK: [ACTIVE] %12 = index_addr %9 : $*T, %11 : $Builtin.Word
276
+ // CHECK: [NONE] // function_ref _finalizeUninitializedArray<A>(_:)
277
+ // CHECK: [ACTIVE] %15 = apply %14<T>(%7) : $@convention(thin) <τ_0_0> (@owned Array<τ_0_0>) -> @owned Array<τ_0_0>
274
278
275
279
// TF-952: Test array literal initialized from an address (e.g. `var`).
276
280
@differentiable
@@ -298,6 +302,8 @@ func testArrayUninitializedIntrinsicAddress(_ x: Float, _ y: Float) -> [Float] {
298
302
// CHECK: [VARIED] %24 = integer_literal $Builtin.Word, 1
299
303
// CHECK: [ACTIVE] %25 = index_addr %20 : $*Float, %24 : $Builtin.Word
300
304
// CHECK: [ACTIVE] %26 = begin_access [read] [static] %4 : $*Float
305
+ // CHECK: [NONE] // function_ref _finalizeUninitializedArray<A>(_:)
306
+ // CHECK: [ACTIVE] %30 = apply %29<Float>(%18) : $@convention(thin) <τ_0_0> (@owned Array<τ_0_0>) -> @owned Array<τ_0_0>
301
307
302
308
// TF-952: Test array literal initialized with `apply` direct results.
303
309
@differentiable
@@ -320,6 +326,8 @@ func testArrayUninitializedIntrinsicFunctionResult(_ x: Float, _ y: Float) -> [F
320
326
// CHECK: [USEFUL] %16 = metatype $@thin Float.Type
321
327
// CHECK: [NONE] // function_ref static Float.* infix(_:_:)
322
328
// CHECK: [ACTIVE] %18 = apply %17(%0, %1, %16) : $@convention(method) (Float, Float, @thin Float.Type) -> Float
329
+ // CHECK: [NONE] // function_ref _finalizeUninitializedArray<A>(_:)
330
+ // CHECK: [ACTIVE] %21 = apply %20<Float>(%7) : $@convention(thin) <τ_0_0> (@owned Array<τ_0_0>) -> @owned Array<τ_0_0>
323
331
324
332
// TF-975: Test nested array literals.
325
333
@differentiable
@@ -338,28 +346,32 @@ func testArrayUninitializedIntrinsicNested(_ x: Float, _ y: Float) -> [Float] {
338
346
// CHECK: [ACTIVE] %9 = pointer_to_address %8 : $Builtin.RawPointer to [strict] $*Float
339
347
// CHECK: [VARIED] %11 = integer_literal $Builtin.Word, 1
340
348
// CHECK: [ACTIVE] %12 = index_addr %9 : $*Float, %11 : $Builtin.Word
341
- // CHECK: [USEFUL] %15 = integer_literal $Builtin.Word, 2
349
+ // CHECK: [NONE] // function_ref _finalizeUninitializedArray<A>(_:)
350
+ // CHECK: [ACTIVE] %15 = apply %14<Float>(%7) : $@convention(thin) <τ_0_0> (@owned Array<τ_0_0>) -> @owned Array<τ_0_0>
351
+ // CHECK: [USEFUL] %17 = integer_literal $Builtin.Word, 2
342
352
// CHECK: [NONE] // function_ref _allocateUninitializedArray<A>(_:)
343
- // CHECK: [ACTIVE] %17 = apply %16 <Float>(%15 ) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer)
344
- // CHECK: [ACTIVE] (**%18 **, %19 ) = destructure_tuple %17 : $(Array<Float>, Builtin.RawPointer)
345
- // CHECK: [VARIED] (%18 , **%19 **) = destructure_tuple %17 : $(Array<Float>, Builtin.RawPointer)
346
- // CHECK: [ACTIVE] %20 = pointer_to_address %19 : $Builtin.RawPointer to [strict] $*Float
347
- // CHECK: [ACTIVE] %21 = begin_borrow %7 : $Array<Float>
348
- // CHECK: [USEFUL] %22 = integer_literal $Builtin.IntLiteral, 0
349
- // CHECK: [USEFUL] %23 = metatype $@thin Int.Type
353
+ // CHECK: [ACTIVE] %19 = apply %18 <Float>(%17 ) : $@convention(thin) <τ_0_0> (Builtin.Word) -> (@owned Array<τ_0_0>, Builtin.RawPointer)
354
+ // CHECK: [ACTIVE] (**%20 **, %21 ) = destructure_tuple %19 : $(Array<Float>, Builtin.RawPointer)
355
+ // CHECK: [VARIED] (%20 , **%21 **) = destructure_tuple %19 : $(Array<Float>, Builtin.RawPointer)
356
+ // CHECK: [ACTIVE] %22 = pointer_to_address %21 : $Builtin.RawPointer to [strict] $*Float
357
+ // CHECK: [ACTIVE] %23 = begin_borrow %15 : $Array<Float>
358
+ // CHECK: [USEFUL] %24 = integer_literal $Builtin.IntLiteral, 0
359
+ // CHECK: [USEFUL] %25 = metatype $@thin Int.Type
350
360
// CHECK: [NONE] // function_ref Int.init(_builtinIntegerLiteral:)
351
- // CHECK: [USEFUL] %25 = apply %24(%22 , %23 ) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int
361
+ // CHECK: [USEFUL] %27 = apply %26(%24 , %25 ) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int
352
362
// CHECK: [NONE] // function_ref Array.subscript.getter
353
- // CHECK: [NONE] %27 = apply %26 <Float>(%20 , %25 , %21 ) : $@convention(method) <τ_0_0> (Int, @guaranteed Array<τ_0_0>) -> @out τ_0_0
354
- // CHECK: [VARIED] %28 = integer_literal $Builtin.Word, 1
355
- // CHECK: [ACTIVE] %29 = index_addr %20 : $*Float, %28 : $Builtin.Word
356
- // CHECK: [ACTIVE] %30 = begin_borrow %7 : $Array<Float>
357
- // CHECK: [USEFUL] %31 = integer_literal $Builtin.IntLiteral, 1
358
- // CHECK: [USEFUL] %32 = metatype $@thin Int.Type
363
+ // CHECK: [NONE] %29 = apply %28 <Float>(%22 , %27 , %23 ) : $@convention(method) <τ_0_0> (Int, @guaranteed Array<τ_0_0>) -> @out τ_0_0
364
+ // CHECK: [VARIED] %30 = integer_literal $Builtin.Word, 1
365
+ // CHECK: [ACTIVE] %31 = index_addr %22 : $*Float, %30 : $Builtin.Word
366
+ // CHECK: [ACTIVE] %32 = begin_borrow %15 : $Array<Float>
367
+ // CHECK: [USEFUL] %33 = integer_literal $Builtin.IntLiteral, 1
368
+ // CHECK: [USEFUL] %34 = metatype $@thin Int.Type
359
369
// CHECK: [NONE] // function_ref Int.init(_builtinIntegerLiteral:)
360
- // CHECK: [USEFUL] %34 = apply %33(%31 , %32 ) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int
370
+ // CHECK: [USEFUL] %36 = apply %35(%33 , %34 ) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int
361
371
// CHECK: [NONE] // function_ref Array.subscript.getter
362
- // CHECK: [NONE] %36 = apply %35<Float>(%29, %34, %30) : $@convention(method) <τ_0_0> (Int, @guaranteed Array<τ_0_0>) -> @out τ_0_0
372
+ // CHECK: [NONE] %38 = apply %37<Float>(%31, %36, %32) : $@convention(method) <τ_0_0> (Int, @guaranteed Array<τ_0_0>) -> @out τ_0_0
373
+ // CHECK: [NONE] // function_ref _finalizeUninitializedArray<A>(_:)
374
+ // CHECK: [ACTIVE] %40 = apply %39<Float>(%20) : $@convention(thin) <τ_0_0> (@owned Array<τ_0_0>) -> @owned Array<τ_0_0>
363
375
364
376
// TF-978: Test array literal initialized with `apply` indirect results.
365
377
struct Wrapper < T: Differentiable > : Differentiable {
@@ -388,6 +400,8 @@ func testArrayUninitializedIntrinsicApplyIndirectResult<T>(_ x: T, _ y: T) -> [W
388
400
// CHECK: [ACTIVE] %19 = alloc_stack $T
389
401
// CHECK: [NONE] // function_ref Wrapper.init(value:)
390
402
// CHECK: [NONE] %22 = apply %21<T>(%17, %19, %18) : $@convention(method) <τ_0_0 where τ_0_0 : Differentiable> (@in τ_0_0, @thin Wrapper<τ_0_0>.Type) -> @out Wrapper<τ_0_0>
403
+ // CHECK: [NONE] // function_ref _finalizeUninitializedArray<A>(_:)
404
+ // CHECK: [ACTIVE] %25 = apply %24<Wrapper<T>>(%7) : $@convention(thin) <τ_0_0> (@owned Array<τ_0_0>) -> @owned Array<τ_0_0>
391
405
392
406
//===----------------------------------------------------------------------===//
393
407
// `inout` argument differentiation
@@ -647,24 +661,26 @@ func testBeginApplyActiveButInitiallyNonactiveInoutArgument(x: Float) -> Float {
647
661
// CHECK: [USEFUL] %10 = metatype $@thin Float.Type
648
662
// CHECK: [NONE] // function_ref Float.init(_builtinIntegerLiteral:)
649
663
// CHECK: [USEFUL] %12 = apply %11(%9, %10) : $@convention(method) (Builtin.IntLiteral, @thin Float.Type) -> Float
650
- // CHECK: [USEFUL] %15 = integer_literal $Builtin.IntLiteral, 0
651
- // CHECK: [USEFUL] %16 = metatype $@thin Int.Type
664
+ // CHECK: [NONE] // function_ref _finalizeUninitializedArray<A>(_:)
665
+ // CHECK: [USEFUL] %15 = apply %14<Float>(%6) : $@convention(thin) <τ_0_0> (@owned Array<τ_0_0>) -> @owned Array<τ_0_0>
666
+ // CHECK: [USEFUL] %17 = integer_literal $Builtin.IntLiteral, 0
667
+ // CHECK: [USEFUL] %18 = metatype $@thin Int.Type
652
668
// CHECK: [NONE] // function_ref Int.init(_builtinIntegerLiteral:)
653
- // CHECK: [USEFUL] %18 = apply %17(%15 , %16 ) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int
654
- // CHECK: [ACTIVE] %19 = begin_access [modify] [static] %2 : $*Array<Float>
669
+ // CHECK: [USEFUL] %20 = apply %19(%17 , %18 ) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int
670
+ // CHECK: [ACTIVE] %21 = begin_access [modify] [static] %2 : $*Array<Float>
655
671
// CHECK: [NONE] // function_ref Array.subscript.modify
656
- // CHECK: [ACTIVE] (**%21 **, %22 ) = begin_apply %20 <Float>(%18 , %19 ) : $@yield_once @convention(method) <τ_0_0> (Int, @inout Array<τ_0_0>) -> @yields @inout τ_0_0
657
- // CHECK: [VARIED] (%21 , **%22 **) = begin_apply %20 <Float>(%18 , %19 ) : $@yield_once @convention(method) <τ_0_0> (Int, @inout Array<τ_0_0>) -> @yields @inout τ_0_0
658
- // CHECK: [USEFUL] %26 = integer_literal $Builtin.IntLiteral, 0
659
- // CHECK: [USEFUL] %27 = metatype $@thin Int.Type
672
+ // CHECK: [ACTIVE] (**%23 **, %24 ) = begin_apply %22 <Float>(%20 , %21 ) : $@yield_once @convention(method) <τ_0_0> (Int, @inout Array<τ_0_0>) -> @yields @inout τ_0_0
673
+ // CHECK: [VARIED] (%23 , **%24 **) = begin_apply %22 <Float>(%20 , %21 ) : $@yield_once @convention(method) <τ_0_0> (Int, @inout Array<τ_0_0>) -> @yields @inout τ_0_0
674
+ // CHECK: [USEFUL] %28 = integer_literal $Builtin.IntLiteral, 0
675
+ // CHECK: [USEFUL] %29 = metatype $@thin Int.Type
660
676
// CHECK: [NONE] // function_ref Int.init(_builtinIntegerLiteral:)
661
- // CHECK: [USEFUL] %29 = apply %28(%26 , %27 ) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int
662
- // CHECK: [ACTIVE] %30 = begin_access [read] [static] %2 : $*Array<Float>
663
- // CHECK: [ACTIVE] %31 = load_borrow %30 : $*Array<Float>
664
- // CHECK: [ACTIVE] %32 = alloc_stack $Float
677
+ // CHECK: [USEFUL] %31 = apply %30(%28 , %29 ) : $@convention(method) (Builtin.IntLiteral, @thin Int.Type) -> Int
678
+ // CHECK: [ACTIVE] %32 = begin_access [read] [static] %2 : $*Array<Float>
679
+ // CHECK: [ACTIVE] %33 = load_borrow %32 : $*Array<Float>
680
+ // CHECK: [ACTIVE] %34 = alloc_stack $Float
665
681
// CHECK: [NONE] // function_ref Array.subscript.getter
666
- // CHECK: [NONE] %34 = apply %33 <Float>(%32 , %29 , %31 ) : $@convention(method) <τ_0_0> (Int, @guaranteed Array<τ_0_0>) -> @out τ_0_0
667
- // CHECK: [ACTIVE] %35 = load [trivial] %32 : $*Float
682
+ // CHECK: [NONE] %36 = apply %35 <Float>(%34 , %31 , %33 ) : $@convention(method) <τ_0_0> (Int, @guaranteed Array<τ_0_0>) -> @out τ_0_0
683
+ // CHECK: [ACTIVE] %37 = load [trivial] %34 : $*Float
668
684
669
685
//===----------------------------------------------------------------------===//
670
686
// Class differentiation
0 commit comments