Skip to content

Commit 2c5ee0f

Browse files
committed
[CanonicalizeOSSALifetime] Fixed caching bug.
Previously, the destroys set (now set vector) wasn't ever being cleared. The result was that users could get overly pessimistic behavior if they had previously used the utility with a destroy that came after the destroys relevant for its current run. Here, it is cleared when the utility is initialized with a new def. Addresses a TODO in the copy_propagation test.
1 parent 9cd4cdb commit 2c5ee0f

File tree

2 files changed

+2
-15
lines changed

2 files changed

+2
-15
lines changed

include/swift/SILOptimizer/Utils/CanonicalizeOSSALifetime.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ class CanonicalizeOSSALifetime {
304304
// analysis, freeing its memory.
305305
accessBlocks = nullptr;
306306
consumes.clear();
307+
destroys.clear();
307308

308309
liveness.initializeDef(def);
309310
}

test/SILOptimizer/copy_propagation.sil

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -668,27 +668,13 @@ bb1:
668668

669669
// Original Overlapping (unnecessarily extends pruned liveness):
670670
//
671-
// TODO: this copy could be avoided but is probably an unusual case,
672-
// and sinking the destroy outside the access scope might help to
673-
// optimize the access itself.
674-
//
675-
// %def
676-
// begin_access // access scope unrelated to def
677-
// use %def // pruned liveness ends here
678-
// br bb1
679-
// bb1:
680-
// destroy %def
681-
// end_access
682-
//
683671
// CHECK-LABEL: sil [ossa] @testOriginalOverlapInDeadBlock : $@convention(thin) () -> () {
684672
// CHECK: [[DEF:%.*]] = apply %{{.*}}() : $@convention(thin) () -> @owned AnyObject
685673
// CHECK: begin_access
686-
// CHECK: [[COPY:%.*]] = copy_value [[DEF]] : $AnyObject
687-
// CHECK: store [[COPY]] to [init] %{{.*}} : $*AnyObject
674+
// CHECK: store [[DEF]] to [init] %{{.*}} : $*AnyObject
688675
// CHECK: br bb1
689676
// CHECK: bb1:
690677
// CHECK: end_access
691-
// CHECK: destroy_value [[DEF]] : $AnyObject
692678
// CHECK-LABEL: } // end sil function 'testOriginalOverlapInDeadBlock'
693679
sil [ossa] @testOriginalOverlapInDeadBlock : $@convention(thin) () -> () {
694680
bb0:

0 commit comments

Comments
 (0)