[llvm] [NewPM][CodeGen] Add callback style codegen pass builder (PR #108690)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 23 01:29:21 PDT 2024


================
@@ -145,6 +145,17 @@ PreservedAnalyses ModuleToFunctionPassAdaptor::run(Module &M,
   return PA;
 }
 
+void ModuleToFunctionPassAdaptor::eraseIf(function_ref<bool(StringRef)> Pred) {
+  StringRef PassName = Pass->name();
+  if (PassName.contains("PassManager") || PassName.ends_with("PassAdaptor")) {
+    Pass->eraseIf(Pred);
+    if (Pass->isEmpty())
+      Pass.reset();
+  } else if (Pred(PassName)) {
+    Pass.reset();
+  }
+}
----------------
paperchalice wrote:

It uses `eraseIf` to support `--start/stop-before/after`, this may introduce some empty pass managers or adaptors, the code here ensures we can remove empty adaptors in `eraseIf`.

https://github.com/llvm/llvm-project/pull/108690


More information about the llvm-commits mailing list