[PATCH] D84872: [NewPM][opt] Revert to legacy PM when any codegen passes are specified

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 29 09:59:24 PDT 2020


aeubanks created this revision.
aeubanks added reviewers: hans, asbirlea, ychen.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
aeubanks requested review of this revision.
Herald added a subscriber: aheejin.

This reduces the number of check-llvm failures by 500.

Ideally we'd have a codegen version of PassRegistry.def, or have all the
codegen passes ported and put into PassRegistry.def. But since that
doesn't exist yet, hardcode the list of codegen IR passes.

There are still codegen passes missing from this list, I'll add them
later as I stumble upon them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84872

Files:
  llvm/tools/opt/opt.cpp


Index: llvm/tools/opt/opt.cpp
===================================================================
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -486,6 +486,35 @@
   }
 };
 
+// For use in NPM transition.
+// TODO: use a codegen version of PassRegistry.def/PassBuilder::is*Pass() once
+// it exists.
+static bool IsCodegenPass(StringRef Pass) {
+  return Pass.startswith("x86-") || Pass.startswith("xcore-") ||
+         Pass.startswith("wasm-") || Pass.startswith("systemz-") ||
+         Pass.startswith("ppc-") || Pass.startswith("nvvm-") ||
+         Pass.startswith("nvptx-") || Pass.startswith("mips-") ||
+         Pass.startswith("lanai-") || Pass.startswith("hexagon-") ||
+         Pass.startswith("bpf-") || Pass.startswith("avr-") ||
+         Pass.startswith("thumb2-") || Pass.startswith("arm-") ||
+         Pass.startswith("si-") || Pass.startswith("gcn-") ||
+         Pass.startswith("amdgpu-") || Pass.startswith("aarch64-") ||
+         Pass.contains("ehprepare") || Pass == "safe-stack" ||
+         Pass == "cost-model" || Pass == "codegenprepare" ||
+         Pass == "interleaved-load-combine" || Pass == "unreachableblockelim" ||
+         Pass == "scalarize-masked-mem-intrin";
+}
+
+// For use in NPM transition.
+static bool CodegenPassSpecifiedInPassList() {
+  for (const auto &P : PassList) {
+    StringRef Arg = P->getPassArgument();
+    if (IsCodegenPass(Arg))
+      return true;
+  }
+  return false;
+}
+
 //===----------------------------------------------------------------------===//
 // main for opt
 //
@@ -685,7 +714,8 @@
   if (OutputThinLTOBC)
     M->addModuleFlag(Module::Error, "EnableSplitLTOUnit", SplitLTOUnit);
 
-  if (EnableNewPassManager || PassPipeline.getNumOccurrences() > 0) {
+  if ((EnableNewPassManager && !CodegenPassSpecifiedInPassList()) ||
+      PassPipeline.getNumOccurrences() > 0) {
     if (PassPipeline.getNumOccurrences() > 0 && PassList.size() > 0) {
       errs()
           << "Cannot specify passes via both -foo-pass and --passes=foo-pass";


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84872.281646.patch
Type: text/x-patch
Size: 2030 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200729/da0dfa13/attachment.bin>


More information about the llvm-commits mailing list