File tree Expand file tree Collapse file tree 3 files changed +50
-32
lines changed
lib/SILOptimizer/PassManager Expand file tree Collapse file tree 3 files changed +50
-32
lines changed Original file line number Diff line number Diff line change @@ -760,6 +760,9 @@ static void addLowLevelPassPipeline(SILPassPipelinePlan &P) {
760760 P.addObjectOutliner ();
761761 P.addDeadStoreElimination ();
762762
763+ // dead-store-elimination can expose opportunities for dead object elimination.
764+ P.addDeadObjectElimination ();
765+
763766 // We've done a lot of optimizations on this function, attempt to FSO.
764767 P.addFunctionSignatureOpts ();
765768 P.addComputeEscapeEffects ();
Original file line number Diff line number Diff line change 1+ // RUN: %target-swift-frontend -O -emit-sil -parse-as-library %s | %FileCheck %s
2+
3+ // REQUIRES: swift_stdlib_no_asserts,optimized_stdlib
4+ // REQUIRES: swift_in_compiler
5+
6+ protocol E {
7+ func f( ) -> Bool
8+ }
9+
10+ protocol P {
11+ associatedtype A = Int
12+ }
13+
14+ public struct X : P , E {
15+ func f( ) -> Bool { return true }
16+ }
17+
18+ func g< T : P > ( _ x : T ) -> Bool {
19+ if let y = x as? E { return y. f ( ) }
20+ return false
21+ }
22+
23+ // Check that this function can be completely constant folded and no alloc_stack remains.
24+
25+ // CHECK-LABEL: sil @$s10dead_alloc0A10AllocStackySbAA1XVF :
26+ // CHECK: bb0({{.*}}):
27+ // CHECK-NEXT: debug_value
28+ // CHECK-NEXT: integer_literal
29+ // CHECK-NEXT: struct
30+ // CHECK-NEXT: return
31+ // CHECK-NEXT: } // end sil function '$s10dead_alloc0A10AllocStackySbAA1XVF'
32+ public func deadAllocStack( _ x: X ) -> Bool {
33+ return g ( x)
34+ }
35+
36+ public class C < T> {
37+ let x : String = " 123 "
38+ }
39+
40+ // CHECK-LABEL: sil @$s10dead_alloc0A13ClassInstanceyyF :
41+ // CHECK: bb0:
42+ // CHECK-NEXT: tuple
43+ // CHECK-NEXT: return
44+ // CHECK-NEXT: } // end sil function '$s10dead_alloc0A13ClassInstanceyyF'
45+ public func deadClassInstance( ) {
46+ let _ = C < Int > ( )
47+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments