File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -709,6 +709,11 @@ static bool rewriteAllocBoxAsAllocStack(AllocBoxInst *ABI) {
709709 // instruction we found that isn't an explicit dealloc_box.
710710 Builder.emitDestroyAddrAndFold (Loc, valueToDestroy);
711711 }
712+ auto *dbi = dyn_cast<DeallocBoxInst>(LastRelease);
713+ if (dbi && dbi->isDeadEnd ()) {
714+ // Don't bother to create dealloc_stack instructions in dead-ends.
715+ continue ;
716+ }
712717 Builder.createDeallocStack (Loc, ASI);
713718 }
714719
Original file line number Diff line number Diff line change @@ -50,3 +50,24 @@ bb0(%0 : $Int):
5050 return %3 : $Int
5151}
5252
53+ // CHECK-LABEL: sil [ossa] @keep_dead_end : {{.*}} {
54+ // CHECK: [[STACK:%[^,]+]] = alloc_stack
55+ // CHECK: cond_br undef, [[DIE:bb[0-9]+]]
56+ // CHECK: [[DIE]]:
57+ // CHECK-NEXT: unreachable
58+ // CHECK-LABEL: } // end sil function 'keep_dead_end'
59+ sil [ossa] @keep_dead_end : $@convention(thin) () -> () {
60+ bb0:
61+ %b = alloc_box ${ var Int }
62+ cond_br undef, die, exit
63+
64+ die:
65+ dealloc_box [dead_end] %b : ${ var Int }
66+ unreachable
67+
68+ exit:
69+ dealloc_box %b : ${ var Int }
70+ %retval = tuple ()
71+ return %retval : $()
72+
73+ }
You can’t perform that action at this time.
0 commit comments