File tree Expand file tree Collapse file tree 2 files changed +68
-1
lines changed
lib/SILOptimizer/PassManager Expand file tree Collapse file tree 2 files changed +68
-1
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,10 @@ llvm::cl::opt<bool> SILDisableLateOMEByDefault(
66
66
llvm::cl::desc(
67
67
" Disable late OME for non-transparent functions by default" ));
68
68
69
+ llvm::cl::opt<bool >
70
+ EnableDestroyHoisting (" enable-destroy-hoisting" , llvm::cl::init(true ),
71
+ llvm::cl::desc(" Enable the DestroyHoisting pass." ));
72
+
69
73
// ===----------------------------------------------------------------------===//
70
74
// Diagnostic Pass Pipeline
71
75
// ===----------------------------------------------------------------------===//
@@ -145,7 +149,7 @@ static void addMandatoryDiagnosticOptPipeline(SILPassPipelinePlan &P) {
145
149
P.addSILSkippingChecker ();
146
150
#endif
147
151
148
- if (Options.shouldOptimize ()) {
152
+ if (Options.shouldOptimize () && EnableDestroyHoisting ) {
149
153
P.addDestroyHoisting ();
150
154
}
151
155
P.addMandatoryInlining ();
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %target-build-swift -O -Xllvm -enable-destroy-hoisting=false -module-name=test %s -o %t/a.out
3
+ // RUN: %target-run %t/a.out | %FileCheck %s
4
+
5
+ // REQUIRES: executable_test,optimized_stdlib
6
+
7
+ final class Storage {
8
+ var v : Int
9
+ init ( _ v : Int ) {
10
+ self . v = v
11
+ }
12
+ }
13
+
14
+ struct IntBox {
15
+ var s : Storage
16
+
17
+ init ( _ x : Int ) {
18
+ s = Storage ( x)
19
+ }
20
+
21
+ var value : Int { return s. v }
22
+
23
+ mutating func increment( _ delta: Int ) {
24
+ if ( !isKnownUniquelyReferenced( & s) ) {
25
+ // We should never see this message
26
+ print ( " ## copy on write " )
27
+ s = Storage ( s. v)
28
+ }
29
+ s. v += delta
30
+ }
31
+ }
32
+
33
+ enum E {
34
+ case value( IntBox )
35
+ case none
36
+
37
+ @inline ( never)
38
+ mutating func simpleIncrement( ) {
39
+ switch self {
40
+ case . value( var i) :
41
+ i. increment ( 1 )
42
+ self = . value( i)
43
+ case . none:
44
+ break
45
+ }
46
+ }
47
+ }
48
+
49
+ func test_enum( ) {
50
+ // CHECK: test_enum() simpleIncrement start
51
+ print ( #function, " simpleIncrement start " )
52
+ var e1 = E . value ( IntBox ( 27 ) )
53
+ e1. simpleIncrement ( )
54
+ // CHECK-NEXT: test_enum() simpleIncrement end: 28
55
+ switch e1 {
56
+ case . value( let i) :
57
+ print ( #function, " simpleIncrement end: " , i. s. v. description)
58
+ case . none:
59
+ print ( " none " )
60
+ }
61
+ }
62
+
63
+ test_enum ( )
You can’t perform that action at this time.
0 commit comments