@@ -63,6 +63,39 @@ void PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
63
63
}
64
64
}
65
65
66
+ void PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
67
+ LPMUpdater &>::eraseIf(function_ref<bool (StringRef)> Pred) {
68
+ std::vector<char > IsLoopNestPassVec (
69
+ static_cast <size_t >(IsLoopNestPass.size ()));
70
+ for (unsigned Idx = 0 , Sz = IsLoopNestPass.size (); Idx != Sz; ++Idx)
71
+ IsLoopNestPassVec[Idx] = IsLoopNestPass[Idx];
72
+
73
+ auto ILP = LoopPasses.begin ();
74
+ auto ILNP = LoopNestPasses.begin ();
75
+ for (auto I = IsLoopNestPassVec.begin (); I != IsLoopNestPassVec.end ();) {
76
+ if (*I) {
77
+ if (Pred ((*ILNP)->name ())) {
78
+ I = IsLoopNestPassVec.erase (I);
79
+ ILNP = LoopNestPasses.erase (ILNP);
80
+ continue ;
81
+ }
82
+ ++ILNP;
83
+ } else {
84
+ if (Pred ((*ILP)->name ())) {
85
+ I = IsLoopNestPassVec.erase (I);
86
+ ILP = LoopPasses.erase (ILP);
87
+ continue ;
88
+ }
89
+ ++ILP;
90
+ }
91
+ ++I;
92
+ }
93
+
94
+ IsLoopNestPass.clear ();
95
+ for (const auto I : IsLoopNestPassVec)
96
+ IsLoopNestPass.push_back (I);
97
+ }
98
+
66
99
// Run both loop passes and loop-nest passes on top-level loop \p L.
67
100
PreservedAnalyses
68
101
LoopPassManager::runWithLoopNestPasses (Loop &L, LoopAnalysisManager &AM,
@@ -363,6 +396,17 @@ PreservedAnalyses FunctionToLoopPassAdaptor::run(Function &F,
363
396
return PA;
364
397
}
365
398
399
+ void FunctionToLoopPassAdaptor::eraseIf (function_ref<bool (StringRef)> Pred) {
400
+ StringRef PassName = Pass->name ();
401
+ if (PassName.contains (" PassManager" ) || PassName.ends_with (" PassAdaptor" )) {
402
+ Pass->eraseIf (Pred);
403
+ if (Pass->isEmpty ())
404
+ Pass.reset ();
405
+ } else if (Pred (PassName)) {
406
+ Pass.reset ();
407
+ }
408
+ }
409
+
366
410
PrintLoopPass::PrintLoopPass () : OS(dbgs()) {}
367
411
PrintLoopPass::PrintLoopPass (raw_ostream &OS, const std::string &Banner)
368
412
: OS(OS), Banner(Banner) {}
0 commit comments