39
39
40
40
using namespace swift ;
41
41
42
+ namespace {
43
+
42
44
// / Instructions which can be hoisted:
43
45
// / loads, function calls without side effects and (some) exclusivity checks
44
46
using InstSet = llvm::SmallPtrSet<SILInstruction *, 8 >;
45
47
48
+ using InstVector = llvm::SmallVector<SILInstruction *, 8 >;
49
+
46
50
// / A subset of instruction which may have side effects.
47
51
// / Doesn't contain ones that have special handling (e.g. fix_lifetime)
48
52
using WriteSet = SmallPtrSet<SILInstruction *, 8 >;
@@ -188,7 +192,6 @@ static bool hoistInstructions(SILLoop *Loop, DominanceInfo *DT,
188
192
return Changed;
189
193
}
190
194
191
- namespace {
192
195
// / \brief Summary of may writes occurring in the loop tree rooted at \p
193
196
// / Loop. This includes all writes of the sub loops and the loop itself.
194
197
struct LoopNestSummary {
@@ -290,7 +293,7 @@ static bool sinkInstruction(DominanceInfo *DT,
290
293
291
294
static bool sinkInstructions (std::unique_ptr<LoopNestSummary> &LoopSummary,
292
295
DominanceInfo *DT, SILLoopInfo *LI,
293
- InstSet &SinkDownSet) {
296
+ InstVector &SinkDownSet) {
294
297
auto *Loop = LoopSummary->Loop ;
295
298
LLVM_DEBUG (llvm::errs () << " Sink instructions attempt\n " );
296
299
SmallVector<SILBasicBlock *, 8 > domBlocks;
@@ -323,7 +326,7 @@ static void getEndAccesses(BeginAccessInst *BI,
323
326
324
327
static bool
325
328
hoistSpecialInstruction (std::unique_ptr<LoopNestSummary> &LoopSummary,
326
- DominanceInfo *DT, SILLoopInfo *LI, InstSet &Special) {
329
+ DominanceInfo *DT, SILLoopInfo *LI, InstVector &Special) {
327
330
auto *Loop = LoopSummary->Loop ;
328
331
LLVM_DEBUG (llvm::errs () << " Hoist and Sink pairs attempt\n " );
329
332
auto Preheader = Loop->getLoopPreheader ();
@@ -376,11 +379,11 @@ class LoopTreeOptimization {
376
379
InstSet HoistUp;
377
380
378
381
// / Instructions that we may be able to sink down
379
- InstSet SinkDown;
382
+ InstVector SinkDown;
380
383
381
384
// / Hoistable Instructions that need special treatment
382
385
// / e.g. begin_access
383
- InstSet SpecialHoist;
386
+ InstVector SpecialHoist;
384
387
385
388
public:
386
389
LoopTreeOptimization (SILLoop *TopLevelLoop, SILLoopInfo *LI,
@@ -657,7 +660,7 @@ void LoopTreeOptimization::analyzeCurrentLoop(
657
660
}
658
661
case SILInstructionKind::RefElementAddrInst: {
659
662
auto *REA = static_cast <RefElementAddrInst *>(&Inst);
660
- SpecialHoist.insert (REA);
663
+ SpecialHoist.push_back (REA);
661
664
break ;
662
665
}
663
666
case swift::SILInstructionKind::CondFailInst: {
@@ -715,7 +718,7 @@ void LoopTreeOptimization::analyzeCurrentLoop(
715
718
continue ;
716
719
}
717
720
if (!mayWriteTo (AA, MayWrites, FL) || !mayWritesMayRelease) {
718
- SinkDown.insert (FL);
721
+ SinkDown.push_back (FL);
719
722
}
720
723
}
721
724
for (auto *BI : BeginAccesses) {
@@ -726,7 +729,7 @@ void LoopTreeOptimization::analyzeCurrentLoop(
726
729
}
727
730
if (analyzeBeginAccess (BI, BeginAccesses, fullApplies, MayWrites, ASA,
728
731
DomTree)) {
729
- SpecialHoist.insert (BI);
732
+ SpecialHoist.push_back (BI);
730
733
}
731
734
}
732
735
}
0 commit comments