Skip to content

Commit 0b55f22

Browse files
committed
Update unit tests for fixed borrowed-from ownership and liveness.
1 parent 43b61ab commit 0b55f22

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

test/SILOptimizer/copy_propagation.sil

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-sil-opt -sil-print-types -update-borrowed-from -copy-propagation -canonical-ossa-rewrite-borrows -enable-sil-verify-all %s | %FileCheck %s --check-prefixes=CHECK,CHECK-OPT
2-
// RUN: %target-sil-opt -sil-print-types -update-borrowed-from -mandatory-copy-propagation -canonical-ossa-rewrite-borrows -enable-sil-verify-all %s | %FileCheck %s --check-prefixes=CHECK,CHECK-ONONE
1+
// RUN: %target-sil-opt -sil-print-types -update-borrowed-from -copy-propagation -canonical-ossa-rewrite-borrows -enable-sil-verify-all %s | %FileCheck %s --check-prefixes=CHECK
2+
// RUN: %target-sil-opt -sil-print-types -update-borrowed-from -mandatory-copy-propagation -canonical-ossa-rewrite-borrows -enable-sil-verify-all %s | %FileCheck %s --check-prefixes=CHECK
33

44
// REQUIRES: asserts
55

@@ -836,14 +836,16 @@ bb4:
836836
return %v : $()
837837
}
838838

839-
// Test a dead begin_borrow (with no scope ending uses). Make sure
840-
// copy-propagation doesn't end the lifetime before the dead borrow.
839+
// Test a dead begin_borrow (with no scope ending uses).
840+
//
841+
// TODO: with lifetime completion, both copies should be deleted.
841842
//
842843
// CHECK-LABEL: sil hidden [ossa] @testDeadBorrow : {{.*}} {
843844
// CHECK: bb0:
844-
// CHECK-NOT: copy_value
845-
// CHECK: begin_borrow
845+
// CHECK: copy_value
846846
// CHECK: destroy_value
847+
// CHECK: copy_value
848+
// CHECK: begin_borrow
847849
// CHECK: unreachable
848850
// CHECK-LABEL: } // end sil function 'testDeadBorrow'
849851
sil hidden [ossa] @testDeadBorrow : $@convention(thin) () -> () {

test/SILOptimizer/liveness_unit.sil

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ bb3(%phi : @guaranteed $D):
258258
// CHECK-NEXT: Incomplete liveness: Reborrowed inner scope
259259
// CHECK-NEXT: bb0: LiveOut
260260
// CHECK-NEXT: bb1: LiveWithin
261-
// CHECK-NEXT: regular user: %7 = borrowed %4 : $C from (%0 : $C)
262-
// CHECK-NEXT: regular user: br bb1(%1 : $C, %2 : $PairC)
263-
// CHECK-NEXT: last user: %7 = borrowed %4 : $C from (%0 : $C)
261+
// CHECK-NEXT: regular user: end_borrow %{{.*}} : $C
262+
// CHECK-NEXT: regular user: br bb1(%{{.*}} : $C, %{{.*}} : $PairC)
263+
// CHECK-NEXT: last user: end_borrow %{{.*}} : $C
264264
// CHECK-NEXT: end running
265265
sil [ossa] @testSSAInnerReborrowedPhi : $@convention(thin) (@guaranteed C) -> () {
266266
bb0(%0 : @guaranteed $C):

test/SILOptimizer/sil_combine_ossa.sil

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4932,16 +4932,14 @@ bb0(%0 : @guaranteed $_ContiguousArrayBuffer<Element>):
49324932
}
49334933

49344934
// CHECK-LABEL: sil [ossa] @cowbuffer_reading_no_lookthrough_reborrow : $@convention(method) <Element> (@guaranteed _ContiguousArrayBuffer<Element>) -> MyInt {
4935-
// CHECK-NOT: ref_element_addr [immutable]
4936-
// CHECK-NOT: ref_tail_addr [immutable]
4935+
//
4936+
// After updating with borrowed-from instructions, the ref_element_addr's can all be promoted without looking through
4937+
// reborrows because they are reachable from the borrowed-from.
4938+
//
49374939
// CHECK-NOT: builtin "COWBufferForReading"
4938-
// CHECK: ref_element_addr %
4939-
// CHECK-NOT: ref_element_addr [immutable]
4940-
// CHECK-NOT: ref_tail_addr [immutable]
4940+
// CHECK: ref_element_addr [immutable]
49414941
// CHECK-NOT: builtin "COWBufferForReading"
4942-
// CHECK: ref_tail_addr %
4943-
// CHECK-NOT: ref_element_addr [immutable]
4944-
// CHECK-NOT: ref_tail_addr [immutable]
4942+
// CHECK: ref_tail_addr [immutable] %
49454943
// CHECK-NOT: builtin "COWBufferForReading"
49464944
// CHECK: } // end sil function 'cowbuffer_reading_no_lookthrough_reborrow'
49474945
sil [ossa] @cowbuffer_reading_no_lookthrough_reborrow : $@convention(method) <Element> (@guaranteed _ContiguousArrayBuffer<Element>) -> MyInt {

0 commit comments

Comments
 (0)