@@ -169,61 +169,6 @@ static SILBasicBlock *insertBackedgeBlock(SILLoop *L, DominanceInfo *DT,
169
169
return BEBlock;
170
170
}
171
171
172
- // / Canonicalize loop exit blocks so that they only have predecessors inside the
173
- // / loop.
174
- static bool canonicalizeLoopExitBlocks (SILLoop *L, DominanceInfo *DT,
175
- SILLoopInfo *LI) {
176
- assert (L && " We assume that L is not null" );
177
-
178
- bool Changed = false ;
179
- SmallVector<SILBasicBlock *, 8 > ExitingBlocks;
180
- L->getExitingBlocks (ExitingBlocks);
181
-
182
- for (auto *ExitingBlock : ExitingBlocks) {
183
- for (unsigned i : indices (ExitingBlock->getSuccessors ())) {
184
- // We have to look up our exiting blocks each time around the loop since
185
- // if we split a critical edge, the exiting block will have a new
186
- // terminator implying a new successor list. The new non-critical edge
187
- // though will be placed at the same spot in the new terminator where the
188
- // critical edge was in the old terminator. Thus as long as we use
189
- // indices, we will visit all exiting block edges appropriately and not
190
- // deal with touching stale memory.
191
- auto Succs = ExitingBlock->getSuccessors ();
192
- auto *SuccBB = Succs[i].getBB ();
193
-
194
- // Add only exit block successors by skipping blocks in the loop.
195
- if (LI->getLoopFor (SuccBB) == L)
196
- continue ;
197
-
198
- // This is unfortunate but necessary since splitCriticalEdge may change IDs.
199
- #ifndef NDEBUG
200
- llvm::SmallString<5 > OldExitingBlockName;
201
- LLVM_DEBUG ({
202
- llvm::raw_svector_ostream buffer (OldExitingBlockName);
203
- ExitingBlock->printAsOperand (buffer);
204
- });
205
- llvm::SmallString<5 > OldSuccBBName;
206
- LLVM_DEBUG ({
207
- llvm::raw_svector_ostream buffer (OldSuccBBName);
208
- SuccBB->printAsOperand (buffer);
209
- });
210
- #endif
211
-
212
- // Split any critical edges in between exiting block and succ iter.
213
- if (splitCriticalEdge (ExitingBlock->getTerminator (), i, DT, LI)) {
214
- LLVM_DEBUG (llvm::dbgs () << " Split critical edge from "
215
- << OldExitingBlockName << " NewID: " ;
216
- ExitingBlock->printAsOperand (llvm::dbgs ());
217
- llvm::dbgs () << " -> OldID: " << OldSuccBBName << " NewID: " ;
218
- SuccBB->printAsOperand (llvm::dbgs ()); llvm::dbgs () << " \n " );
219
- Changed = true ;
220
- }
221
- }
222
- }
223
-
224
- return Changed;
225
- }
226
-
227
172
// / Canonicalize the loop for rotation and downstream passes.
228
173
// /
229
174
// / Create a single preheader and single latch block.
@@ -232,14 +177,12 @@ static bool canonicalizeLoopExitBlocks(SILLoop *L, DominanceInfo *DT,
232
177
// / them before merging the latch. See LLVM's separateNestedLoop.
233
178
bool swift::canonicalizeLoop (SILLoop *L, DominanceInfo *DT, SILLoopInfo *LI) {
234
179
bool ChangedCFG = false ;
180
+
235
181
if (!L->getLoopPreheader ()) {
236
182
insertPreheader (L, DT, LI);
237
183
assert (L->getLoopPreheader () && " L should have a pre-header now" );
238
184
ChangedCFG = true ;
239
185
}
240
-
241
- ChangedCFG |= canonicalizeLoopExitBlocks (L, DT, LI);
242
-
243
186
if (!L->getLoopLatch ())
244
187
ChangedCFG |= (insertBackedgeBlock (L, DT, LI) != nullptr );
245
188
0 commit comments