@@ -431,8 +431,7 @@ class RLEContext {
431
431
// / Function currently processing.
432
432
SILFunction *Fn;
433
433
434
- // / The passmanager we are using.
435
- SILPassManager *PM;
434
+ SILFunctionTransform *parentTransform;
436
435
437
436
// / The alias analysis that we will use during all computations.
438
437
AliasAnalysis *AA;
@@ -500,7 +499,7 @@ class RLEContext {
500
499
#endif
501
500
502
501
public:
503
- RLEContext (SILFunction *F, SILPassManager *PM ,
502
+ RLEContext (SILFunction *F, SILFunctionTransform *parentTransform ,
504
503
bool disableArrayLoads, bool onlyImmutableLoads);
505
504
506
505
RLEContext (const RLEContext &) = delete ;
@@ -1149,7 +1148,8 @@ getProcessFunctionKind(unsigned LoadCount, unsigned StoreCount) {
1149
1148
// the basic blocks in the functions are iterated in post order.
1150
1149
// Then this function can be processed in one iteration, i.e. no
1151
1150
// need to generate the genset and killset.
1152
- auto *PO = PM->getAnalysis <PostOrderAnalysis>()->get (Fn);
1151
+ auto *PO = parentTransform->getPassManager ()->
1152
+ getAnalysis<PostOrderAnalysis>()->get (Fn);
1153
1153
BasicBlockSet HandledBBs (Fn);
1154
1154
for (SILBasicBlock *B : PO->getReversePostOrder ()) {
1155
1155
++BBCount;
@@ -1215,12 +1215,13 @@ void BlockState::dump(RLEContext &Ctx) {
1215
1215
// RLEContext Implementation
1216
1216
// ===----------------------------------------------------------------------===//
1217
1217
1218
- RLEContext::RLEContext (SILFunction *F, SILPassManager *PM ,
1218
+ RLEContext::RLEContext (SILFunction *F, SILFunctionTransform *parentTransform ,
1219
1219
bool disableArrayLoads, bool onlyImmutableLoads)
1220
- : Fn(F), PM(PM), AA(PM->getAnalysis<AliasAnalysis>(F)),
1221
- TE(PM->getAnalysis<TypeExpansionAnalysis>()),
1222
- PO(PM->getAnalysis<PostOrderAnalysis>()->get(F)),
1223
- EAFI(PM->getAnalysis<EpilogueARCAnalysis>()->get(F)),
1220
+ : Fn(F), parentTransform(parentTransform),
1221
+ AA(parentTransform->getPassManager ()->getAnalysis<AliasAnalysis>(F)),
1222
+ TE(parentTransform->getPassManager ()->getAnalysis<TypeExpansionAnalysis>()),
1223
+ PO(parentTransform->getPassManager ()->getAnalysis<PostOrderAnalysis>()->get(F)),
1224
+ EAFI(parentTransform->getPassManager ()->getAnalysis<EpilogueARCAnalysis>()->get(F)),
1224
1225
BBToLocState(F), BBWithLoads(F),
1225
1226
ArrayType(disableArrayLoads
1226
1227
? F->getModule ().getASTContext().getArrayDecl()
@@ -1628,6 +1629,9 @@ bool RLEContext::run() {
1628
1629
// Set up the load forwarding.
1629
1630
processBasicBlocksForRLE (Optimistic);
1630
1631
1632
+ if (!parentTransform->continueWithNextSubpassRun (nullptr ))
1633
+ return false ;
1634
+
1631
1635
// Finally, perform the redundant load replacements.
1632
1636
llvm::SmallVector<SILInstruction *, 16 > InstsToDelete;
1633
1637
bool SILChanged = false ;
@@ -1648,6 +1652,10 @@ bool RLEContext::run() {
1648
1652
auto Iter = Loads.find (V);
1649
1653
if (Iter == Loads.end ())
1650
1654
continue ;
1655
+
1656
+ if (!parentTransform->continueWithNextSubpassRun (V))
1657
+ return SILChanged;
1658
+
1651
1659
LLVM_DEBUG (llvm::dbgs () << " Replacing " << SILValue (Iter->first )
1652
1660
<< " With " << Iter->second );
1653
1661
auto *origLoad = cast<LoadInst>(Iter->first );
@@ -1666,6 +1674,10 @@ bool RLEContext::run() {
1666
1674
// Erase the instructions recursively, this way, we get rid of pass
1667
1675
// dependence on DCE.
1668
1676
for (auto &X : InstsToDelete) {
1677
+
1678
+ if (!parentTransform->continueWithNextSubpassRun (X))
1679
+ return SILChanged;
1680
+
1669
1681
// It is possible that the instruction still has uses, because it could be
1670
1682
// used as the replacement Value, i.e. F.second, for some other RLE pairs.
1671
1683
//
@@ -1700,16 +1712,19 @@ class RedundantLoadElimination : public SILFunctionTransform {
1700
1712
LLVM_DEBUG (llvm::dbgs () << " *** RLE on function: " << F->getName ()
1701
1713
<< " ***\n " );
1702
1714
1703
- RLEContext RLE (F, PM , disableArrayLoads,
1715
+ RLEContext RLE (F, this , disableArrayLoads,
1704
1716
/* onlyImmutableLoads*/ false );
1705
1717
if (RLE.run ()) {
1706
1718
invalidateAnalysis (SILAnalysis::InvalidationKind::Instructions);
1707
1719
}
1720
+ if (!continueWithNextSubpassRun (nullptr ))
1721
+ return ;
1722
+
1708
1723
if (RLE.shouldOptimizeImmutableLoads ()) {
1709
1724
// / Re-running RLE with cutting base addresses off at
1710
1725
// / `ref_element_addr [immutable]` or `ref_tail_addr [immutable]` can
1711
1726
// / expose additional opportunities.
1712
- RLEContext RLE2 (F, PM , disableArrayLoads,
1727
+ RLEContext RLE2 (F, this , disableArrayLoads,
1713
1728
/* onlyImmutableLoads*/ true );
1714
1729
if (RLE2.run ()) {
1715
1730
invalidateAnalysis (SILAnalysis::InvalidationKind::Instructions);
0 commit comments