Skip to content

Commit c3b1c58

Browse files
committed
Fix test cases for copy propagation improvements
More dead code happens to be eliminated now because of consistent use of the InstructionDeleter.
1 parent e70a61b commit c3b1c58

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

test/SILOptimizer/copy_propagation.sil

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ sil [ossa] @getOwnedC : $@convention(thin) () -> (@owned C)
3232
sil [ossa] @takeOwnedC : $@convention(thin) (@owned C) -> ()
3333
sil [ossa] @takeOwnedCTwice : $@convention(thin) (@owned C, @owned C) -> ()
3434
sil [ossa] @takeGuaranteedC : $@convention(thin) (@guaranteed C) -> ()
35+
sil [ossa] @takeGuaranteedAnyObject : $@convention(thin) (@guaranteed AnyObject) -> ()
3536

3637
// -O ignores this because there's no copy_value
3738
// -Onone hoists the destroy and adds a poison flag.
@@ -342,6 +343,8 @@ bb0:
342343
br bb1
343344

344345
bb1:
346+
%f2 = function_ref @takeGuaranteedAnyObject : $@convention(thin) (@guaranteed AnyObject) -> ()
347+
%call = apply %f2(%obj) : $@convention(thin) (@guaranteed AnyObject) -> ()
345348
destroy_value %copy : $AnyObject
346349
destroy_value %obj : $AnyObject
347350
destroy_value %box : ${ var AnyObject }
@@ -392,6 +395,8 @@ bb1:
392395
br bb2
393396

394397
bb2:
398+
%f2 = function_ref @takeGuaranteedAnyObject : $@convention(thin) (@guaranteed AnyObject) -> ()
399+
%call = apply %f2(%obj) : $@convention(thin) (@guaranteed AnyObject) -> ()
395400
destroy_value %copy : $AnyObject
396401
destroy_value %obj : $AnyObject
397402
destroy_value %box : ${ var AnyObject }
@@ -435,6 +440,8 @@ bb0:
435440
br bb1
436441

437442
bb1:
443+
%f2 = function_ref @takeGuaranteedAnyObject : $@convention(thin) (@guaranteed AnyObject) -> ()
444+
%call = apply %f2(%obj) : $@convention(thin) (@guaranteed AnyObject) -> ()
438445
destroy_value %copy : $AnyObject
439446
destroy_value %obj : $AnyObject
440447
destroy_value %box : ${ var AnyObject }
@@ -484,6 +491,8 @@ bb1:
484491
br bb2
485492

486493
bb2:
494+
%f2 = function_ref @takeGuaranteedAnyObject : $@convention(thin) (@guaranteed AnyObject) -> ()
495+
%call = apply %f2(%obj) : $@convention(thin) (@guaranteed AnyObject) -> ()
487496
destroy_value %copy : $AnyObject
488497
destroy_value %obj : $AnyObject
489498
destroy_value %box : ${ var AnyObject }
@@ -527,6 +536,8 @@ bb0:
527536
br bb1
528537

529538
bb1:
539+
%f2 = function_ref @takeGuaranteedAnyObject : $@convention(thin) (@guaranteed AnyObject) -> ()
540+
%call = apply %f2(%obj) : $@convention(thin) (@guaranteed AnyObject) -> ()
530541
destroy_value %copy : $AnyObject
531542
destroy_value %obj : $AnyObject
532543
destroy_value %box : ${ var AnyObject }
@@ -577,6 +588,8 @@ bb1:
577588
br bb2
578589

579590
bb2:
591+
%f2 = function_ref @takeGuaranteedAnyObject : $@convention(thin) (@guaranteed AnyObject) -> ()
592+
%call = apply %f2(%obj) : $@convention(thin) (@guaranteed AnyObject) -> ()
580593
destroy_value %copy : $AnyObject
581594
destroy_value %obj : $AnyObject
582595
destroy_value %box : ${ var AnyObject }
@@ -622,6 +635,8 @@ bb0:
622635
br bb1
623636

624637
bb1:
638+
%f2 = function_ref @takeGuaranteedAnyObject : $@convention(thin) (@guaranteed AnyObject) -> ()
639+
%call = apply %f2(%obj) : $@convention(thin) (@guaranteed AnyObject) -> ()
625640
destroy_value %obj : $AnyObject
626641
destroy_value %box : ${ var AnyObject }
627642
%v = tuple ()

test/SILOptimizer/copy_propagation_opaque.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ bb0(%arg : @owned $T):
394394
// CHECK-TRACE-LABEL: *** CopyPropagation: testBorrowCopy
395395
// CHECK-TRACE: Outer copy [[OUTERCOPY:%.*]] = copy_value %0 : $T
396396
// CHECK-TRACE: Use of outer copy destroy_value
397-
// CHECK-TRACE: Removing %{{.*}} = copy_value
397+
// CHECK-TRACE: Deleting %{{.*}} = copy_value
398398
// CHECK-TRACE: Removing destroy_value [[OUTERCOPY]] : $T
399399
// CHECK-TRACE: Removing [[OUTERCOPY]] = copy_value %0 : $T
400400
//

test/SILOptimizer/sil_combine_apply_ossa.sil

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// RUN: %target-sil-opt -enable-sil-verify-all %s -sil-combine -sil-combine-disable-alloc-stack-opts | %FileCheck %s
1+
// RUN: %target-sil-opt -enable-ossa-modules -enable-sil-verify-all %s -sil-combine -sil-combine-disable-alloc-stack-opts | %FileCheck %s
2+
3+
// -enable-ossa-modules happens to enable copy propagation during sil-combine, which these tests rely on.
24

35
import Swift
46
import Builtin
@@ -516,10 +518,10 @@ sil [ossa] @guaranteed_closure : $@convention(thin) (@guaranteed C) -> ()
516518

517519
// CHECK-LABEL: sil [ossa] @test_guaranteed_closure
518520
// CHECK: bb0([[ARG:%.*]] : @guaranteed $C):
519-
// CHECK: [[ARG_COPY:%.*]] = copy_value [[ARG]]
520521
// CHECK: [[F:%.*]] = function_ref @guaranteed_closure
522+
// CHECK: [[ARG_COPY:%.*]] = copy_value [[ARG]]
521523
// CHECK: [[C:%.*]] = partial_apply [callee_guaranteed] [[F]]([[ARG_COPY]])
522-
// CHECK: apply [[F]]([[ARG]])
524+
// CHECK: apply [[F]](%0)
523525
// Don't release the closure context -- it is @callee_guaranteed.
524526
// CHECK-NOT: destroy_value [[C]] : $@callee_guaranteed () -> ()
525527
// CHECK-NOT: destroy_value [[C]] : $@callee_guaranteed () -> ()

0 commit comments

Comments
 (0)