Skip to content

Commit 23b99ef

Browse files
authored
Merge pull request #11282 from atrick/fix
2 parents 5ebddc3 + 6124ae6 commit 23b99ef

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/SILOptimizer/Utils/Local.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,10 +1984,12 @@ simplifyCheckedCastAddrBranchInst(CheckedCastAddrBranchInst *Inst) {
19841984
// The unconditional_addr_cast can be skipped, if the result of a cast
19851985
// is not used afterwards.
19861986
if (ResultNotUsed) {
1987+
if (shouldTakeOnSuccess(Inst->getConsumptionKind())) {
1988+
auto &srcTL = Builder.getModule().getTypeLowering(Src->getType());
1989+
srcTL.emitDestroyAddress(Builder, Loc, Src);
1990+
}
19871991
EraseInstAction(Inst);
19881992
Builder.setInsertionPoint(BB);
1989-
if (shouldTakeOnSuccess(Inst->getConsumptionKind()))
1990-
Builder.emitDestroyAddr(Loc, Src);
19911993
auto *NewI = Builder.createBranch(Loc, SuccessBB);
19921994
WillSucceedAction();
19931995
return NewI;

test/SILOptimizer/simplify_cfg.sil

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2914,7 +2914,8 @@ class IsQ : Q {}
29142914
// CHECK-LABEL: sil @test_dead_checked_cast_br : $@convention(thin) (@in IsQ) -> () {
29152915
// CHECK: bb0(%0 : $*IsQ):
29162916
// CHECK: [[Q:%.*]] = alloc_stack $Q
2917-
// CHECK: destroy_addr %0 : $*IsQ
2917+
// CHECK: [[LD:%.*]] = load %0 : $*IsQ
2918+
// CHECK: strong_release [[LD]] : $IsQ
29182919
// CHECK: dealloc_stack [[Q]] : $*Q
29192920
// CHECK: [[R:%.*]] = tuple ()
29202921
// CHECK: return [[R]] : $()

0 commit comments

Comments
 (0)