Skip to content

Commit 24bc395

Browse files
committed
[CopyPropagation] Canonicalize all values.
Previously, the lifetimes of only values which were copied were canonicalized during the non-mandatory CopyPropagation pass. The mandatory pass (i.e. MandatoryCopyPropagation) has been disabled, meaning that non-copied values lifetimes were never canonicalized. So enable canonicalization of all lifetimes during regular CopyPropagation. rdar://54335055
1 parent db80c36 commit 24bc395

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/SILOptimizer/Transforms/CopyPropagation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ namespace {
375375
class CopyPropagation : public SILFunctionTransform {
376376
/// True if debug_value instructions should be pruned.
377377
bool pruneDebug;
378-
/// True of all values should be canonicalized.
378+
/// True if all values should be canonicalized.
379379
bool canonicalizeAll;
380380
/// If true, then borrow scopes will be canonicalized, allowing copies of
381381
/// guaranteed values to be optimized. Does *not* shrink the borrow scope.
@@ -588,7 +588,7 @@ SILTransform *swift::createMandatoryCopyPropagation() {
588588
}
589589

590590
SILTransform *swift::createCopyPropagation() {
591-
return new CopyPropagation(/*pruneDebug*/ true, /*canonicalizeAll*/ false,
591+
return new CopyPropagation(/*pruneDebug*/ true, /*canonicalizeAll*/ true,
592592
/*canonicalizeBorrows*/ EnableRewriteBorrows,
593593
/*poisonRefs*/ false);
594594
}

test/SILOptimizer/copy_propagation.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ sil [ossa] @takeOwnedCTwice : $@convention(thin) (@owned C, @owned C) -> ()
3636
sil [ossa] @takeGuaranteedC : $@convention(thin) (@guaranteed C) -> ()
3737
sil [ossa] @takeGuaranteedAnyObject : $@convention(thin) (@guaranteed AnyObject) -> ()
3838

39-
// -O ignores this because there's no copy_value
39+
// -O hoists the destroy
4040
// -Onone hoists the destroy and adds a poison flag.
4141
//
4242
// CHECK-LABEL: sil [ossa] @testDestroyAfterCall : {{.*}} {
4343
// CHECK: bb0:
4444
// CHECK: [[ARG:%.*]] = apply
4545
// CHECK-ONONE: destroy_value [poison] [[ARG]] : $B
46-
// CHECK: apply
4746
// CHECK-OPT: destroy_value [[ARG]] : $B
47+
// CHECK: apply
4848
// CHECK-LABEL: } // end sil function 'testDestroyAfterCall'
4949
sil [ossa] @testDestroyAfterCall : $@convention(thin) () -> () {
5050
bb0:

0 commit comments

Comments
 (0)