File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
SwiftCompilerSources/Sources/Optimizer/Utilities Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -308,6 +308,10 @@ extension Instruction {
308308 // Don't remove UncheckedEnumDataInst in OSSA in case it is responsible
309309 // for consuming an enum value.
310310 return !parentFunction. hasOwnership
311+ case is ExtendLifetimeInst :
312+ // An extend_lifetime can only be removed if the operand is also removed.
313+ // If its operand is trivial, it will be removed by MandatorySimplification.
314+ return false
311315 default :
312316 break
313317 }
Original file line number Diff line number Diff line change 1+ // RUN: %target-sil-opt -enable-sil-verify-all %s -onone-simplification | %FileCheck %s
2+
3+ // REQUIRES: swift_in_compiler
4+
5+ sil_stage raw
6+
7+ import Builtin
8+ import Swift
9+ import SwiftShims
10+
11+ // extend_lifetime should not be eliminated as dead code.
12+ //
13+ // CHECK-LABEL: sil [ossa] @do_not_remove_extend : $@convention(thin) (Int) -> () {
14+ // CHECK: extend_lifetime %0 : $Int
15+ // CHECK-LABEL: } // end sil function 'do_not_remove_extend'
16+ sil [ossa] @do_not_remove_extend : $@convention(thin) (Int) -> () {
17+ bb0(%0 : $Int):
18+ extend_lifetime %0 : $Int
19+ %4 = tuple ()
20+ return %4 : $()
21+ }
You can’t perform that action at this time.
0 commit comments