|
12 | 12 |
|
13 | 13 | #define DEBUG_TYPE "sil-semantic-arc-opts" |
14 | 14 |
|
15 | | -#include "swift/Basic/LLVM.h" |
16 | | - |
17 | 15 | #include "OwnershipLiveRange.h" |
18 | 16 | #include "OwnershipPhiOperand.h" |
19 | 17 | #include "SemanticARCOptVisitor.h" |
| 18 | +#include "Transforms.h" |
| 19 | + |
| 20 | +#include "swift/Basic/LLVM.h" |
20 | 21 |
|
21 | 22 | #include "swift/Basic/BlotSetVector.h" |
22 | 23 | #include "swift/Basic/FrozenMultiMap.h" |
@@ -74,9 +75,6 @@ bool SemanticARCOptVisitor::optimize() { |
74 | 75 | assert(!madeAdditionalChanges && "Should be at the fixed point"); |
75 | 76 | } |
76 | 77 |
|
77 | | - // Then use the newly seeded peephole map to |
78 | | - madeChange |= performPostPeepholeOwnedArgElimination(); |
79 | | - |
80 | 78 | return madeChange; |
81 | 79 | } |
82 | 80 |
|
@@ -180,13 +178,21 @@ struct SemanticARCOpts : SILFunctionTransform { |
180 | 178 | } |
181 | 179 | } |
182 | 180 |
|
183 | | - // Then process the worklist. We only destroy instructions, so invalidate |
184 | | - // that. Once we modify the ownership of block arguments, we will need to |
185 | | - // perhaps invalidate branches as well. |
186 | | - if (visitor.optimize()) { |
| 181 | + // Then process the worklist, performing peepholes. |
| 182 | + bool madeChange = visitor.optimize(); |
| 183 | + |
| 184 | + // Now that we have seeded the map of phis to incoming values that could be |
| 185 | + // converted to guaranteed, ignoring the phi, try convert those phis to be |
| 186 | + // guaranteed. |
| 187 | + if (tryConvertOwnedPhisToGuaranteedPhis(visitor.ctx)) { |
187 | 188 | invalidateAnalysis( |
188 | 189 | SILAnalysis::InvalidationKind::BranchesAndInstructions); |
| 190 | + return; |
189 | 191 | } |
| 192 | + |
| 193 | + // Otherwise, we only deleted instructions and did not touch phis. |
| 194 | + if (madeChange) |
| 195 | + invalidateAnalysis(SILAnalysis::InvalidationKind::Instructions); |
190 | 196 | } |
191 | 197 | }; |
192 | 198 |
|
|
0 commit comments