File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -316,6 +316,11 @@ void DCE::markLive() {
316316 break ;
317317 }
318318 case SILInstructionKind::EndLifetimeInst: {
319+ if (I.getOperand (0 )->getType ().isAddress ()) {
320+ // DCE cannot reason about values in memory.
321+ markInstructionLive (&I);
322+ break ;
323+ }
319324 // The instruction is live only if it's operand value is also live
320325 addReverseDependency (I.getOperand (0 ), &I);
321326 break ;
Original file line number Diff line number Diff line change @@ -22,7 +22,12 @@ struct CAndBit {
2222}
2323
2424struct MO: ~Copyable {
25- deinit
25+ var x: Int
26+ deinit
27+ }
28+
29+ struct Outer : ~Copyable {
30+ var x: MO
2631}
2732
2833sil @dummy : $@convention(thin) () -> ()
@@ -487,3 +492,18 @@ sil [ossa] @dont_delete_move_value_lexical : $@convention(thin) () -> () {
487492 %retval = tuple ()
488493 return %retval : $()
489494}
495+
496+ // CHECK-LABEL: sil [ossa] @dont_remove_addr_end_lifetime :
497+ // CHECK: end_lifetime
498+ // CHECK-LABEL: } // end sil function 'dont_remove_addr_end_lifetime'
499+ sil [ossa] @dont_remove_addr_end_lifetime : $@convention(thin) (@owned Outer) -> () {
500+ bb0(%0 : @owned $Outer):
501+ %1 = alloc_stack $Outer
502+ store %0 to [init] %1 : $*Outer
503+ %3 = struct_element_addr %1 : $*Outer, #Outer.x
504+ end_lifetime %3 : $*MO
505+ dealloc_stack %1 : $*Outer
506+ %6 = tuple ()
507+ return %6 : $()
508+ }
509+
You can’t perform that action at this time.
0 commit comments