[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 13:13:49 PDT 2020
aeubanks updated this revision to Diff 281713.
aeubanks added a comment.
Remove braces
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84872/new/
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,41 @@
}
};
+// For use in NPM transition.
+// TODO: use a codegen version of PassRegistry.def/PassBuilder::is*Pass() once
+// it exists.
+static bool IsCodegenPass(StringRef Pass) {
+ std::vector<StringRef> PassNamePrefix = {
+ "x86-", "xcore-", "wasm-", "systemz-", "ppc-", "nvvm-",
+ "nvptx-", "mips-", "lanai-", "hexagon-", "bpf-", "avr-",
+ "thumb2-", "arm-", "si-", "gcn-", "amdgpu-", "aarch64-"};
+ std::vector<StringRef> PassNameContain = {"ehprepare"};
+ std::vector<StringRef> PassNameExact = {
+ "safe-stack", "cost-model",
+ "codegenprepare", "interleaved-load-combine",
+ "unreachableblockelim", "sclaraized-masked-mem-intrin"};
+ for (const auto &P : PassNamePrefix)
+ if (Pass.startswith(P))
+ return true;
+ for (const auto &P : PassNameContain)
+ if (Pass.contains(P))
+ return true;
+ for (const auto &P : PassNamePrefix)
+ if (Pass == P)
+ return true;
+ return false;
+}
+
+// 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 +720,12 @@
if (OutputThinLTOBC)
M->addModuleFlag(Module::Error, "EnableSplitLTOUnit", SplitLTOUnit);
- if (EnableNewPassManager || PassPipeline.getNumOccurrences() > 0) {
+ // If `-passes=` is specified, use NPM.
+ // If `-enable-new-pm` is specified and there are no codegen passes, use NPM.
+ // e.g. `-enable-new-pm -sroa` will use NPM.
+ // but `-enable-new-pm -codegenprepare` will still revert to legacy PM.
+ 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.281713.patch
Type: text/x-patch
Size: 2222 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200729/ee60cf11/attachment-0001.bin>
More information about the llvm-commits
mailing list