Skip to content

Commit 3b30ffc

Browse files
committed
---
yaml --- r: 347112 b: refs/heads/master c: c8520b1 h: refs/heads/master
1 parent 74fcbe6 commit 3b30ffc

File tree

3 files changed

+84
-3
lines changed

3 files changed

+84
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 8063cf77b45c43662ed6946260096ba2a2b7990e
2+
refs/heads/master: c8520b1cf7e6c7d6971a83bc14ae0504d5661c07
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/lib/SIL/BasicBlockUtils.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ void swift::changeBranchTarget(TermInst *T, unsigned edgeIdx,
5050
case TermKind::BranchInst: {
5151
auto *BI = cast<BranchInst>(T);
5252
SmallVector<SILValue, 8> args;
53-
for (auto arg : BI->getArgs())
54-
args.push_back(arg);
53+
if (preserveArgs) {
54+
for (auto arg : BI->getArgs())
55+
args.push_back(arg);
56+
}
5557
B.createBranch(T->getLoc(), newDest, args);
5658
BI->dropAllReferences();
5759
BI->eraseFromParent();

trunk/test/SILOptimizer/stack_promotion.sil

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,3 +741,82 @@ bb0(%0 : $Int, %another: $Array<Int>):
741741
%24 = tuple ()
742742
return %24 : $()
743743
}
744+
745+
746+
// CHECK-LABEL: sil @promote_with_unreachable_block_nest_bug
747+
// CHECK: bb3:
748+
// CHECK: dealloc_ref [stack] %{{.*}}
749+
// CHECK: bb4:
750+
// CHECK: br bb5
751+
// CHECK: bb5:
752+
// CHECK: dealloc_ref [stack] %{{.*}}
753+
// CHECK: bb6:
754+
// CHECK: dealloc_ref [stack] %{{.*}}
755+
// CHECK: bb11:
756+
// CHECK: alloc_ref [stack] $XX
757+
// CHECK: return
758+
sil @promote_with_unreachable_block_nest_bug : $@convention(thin) () -> Int32 {
759+
bb0:
760+
%0 = alloc_stack $Builtin.Int32 // user: %30
761+
%1 = alloc_stack $Builtin.Int32 // users: %29, %27
762+
cond_br undef, bb1, bb7 // id: %2
763+
764+
bb1: // Preds: bb0
765+
br bb14 // id: %3
766+
767+
bb2: // Preds: bb10
768+
cond_br undef, bb5, bb3 // id: %4
769+
770+
bb3: // Preds: bb2
771+
strong_release %20 : $XX // id: %5
772+
br bb6 // id: %6
773+
774+
bb4: // Preds: bb10
775+
%7 = integer_literal $Builtin.Int32, 0 // user: %8
776+
%8 = struct $Int32 (%7 : $Builtin.Int32) // user: %9
777+
br bb13(%8 : $Int32) // id: %9
778+
779+
bb5: // Preds: bb2
780+
strong_release %20 : $XX // id: %10
781+
br bb6 // id: %11
782+
783+
bb6: // Preds: bb5 bb3
784+
br bb12 // id: %12
785+
786+
bb7: // Preds: bb0
787+
cond_br undef, bb8, bb9 // id: %13
788+
789+
bb8: // Preds: bb7
790+
cond_br undef, bb10, bb11 // id: %14
791+
792+
bb9: // Preds: bb7
793+
%15 = integer_literal $Builtin.Int32, 0 // user: %16
794+
%16 = struct $Int32 (%15 : $Builtin.Int32) // user: %17
795+
br bb13(%16 : $Int32) // id: %17
796+
797+
bb10: // Preds: bb8
798+
%18 = alloc_ref $XX // user: %20
799+
// function_ref xx_init
800+
%19 = function_ref @xx_init : $@convention(thin) (@guaranteed XX) -> XX // user: %20
801+
%20 = apply %19(%18) : $@convention(thin) (@guaranteed XX) -> XX // users: %21, %5, %10
802+
%21 = ref_element_addr %20 : $XX, #XX.x // user: %22
803+
%22 = load %21 : $*Int32
804+
cond_br undef, bb2, bb4 // id: %23
805+
806+
bb11: // Preds: bb8
807+
unreachable // id: %24
808+
809+
bb12: // Preds: bb6
810+
br bb14 // id: %25
811+
812+
bb13(%26 : $Int32): // Preds: bb9 bb4
813+
dealloc_stack %1 : $*Builtin.Int32 // id: %27
814+
unreachable // id: %28
815+
816+
bb14: // Preds: bb12 bb1
817+
dealloc_stack %1 : $*Builtin.Int32 // id: %29
818+
dealloc_stack %0 : $*Builtin.Int32 // id: %30
819+
%31 = integer_literal $Builtin.Int32, 0 // user: %32
820+
%32 = struct $Int32 (%31 : $Builtin.Int32) // user: %33
821+
return %32 : $Int32 // id: %33
822+
} // end sil function 'promote_with_unreachable_block_nest_bug'

0 commit comments

Comments
 (0)