Skip to content

Commit

Permalink
[opt] Clean up code related to parsing legacy passes for new PM drive…
Browse files Browse the repository at this point in the history
…r. NFC

Just some minor cleanups given that `opt -passname` syntax is dead
for the new pass manager driver.
  • Loading branch information
bjope committed Dec 12, 2022
1 parent 9883ee6 commit 9c980f7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 25 deletions.
14 changes: 1 addition & 13 deletions llvm/tools/opt/NewPMDriver.cpp
Expand Up @@ -324,7 +324,7 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
TargetLibraryInfoImpl *TLII, ToolOutputFile *Out,
ToolOutputFile *ThinLTOLinkOut,
ToolOutputFile *OptRemarkFile,
StringRef PassPipeline, ArrayRef<StringRef> Passes,
StringRef PassPipeline,
ArrayRef<PassPlugin> PassPlugins,
OutputKind OK, VerifierKind VK,
bool ShouldPreserveAssemblyUseListOrder,
Expand Down Expand Up @@ -448,23 +448,11 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,

// Add passes according to the -passes options.
if (!PassPipeline.empty()) {
assert(Passes.empty() &&
"PassPipeline and Passes should not both contain passes");
if (auto Err = PB.parsePassPipeline(MPM, PassPipeline)) {
errs() << Arg0 << ": " << toString(std::move(Err)) << "\n";
return false;
}
}
// Add passes specified using the legacy PM syntax (i.e. not using
// -passes). This should be removed later when such support has been
// deprecated, i.e. when all lit tests running opt (and not using
// -enable-new-pm=0) have been updated to use -passes.
for (auto PassName : Passes) {
if (auto Err = PB.parsePassPipeline(MPM, PassName)) {
errs() << Arg0 << ": " << toString(std::move(Err)) << "\n";
return false;
}
}

if (VK > VK_NoVerifier)
MPM.addPass(VerifierPass());
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/opt/NewPMDriver.h
Expand Up @@ -71,7 +71,7 @@ void printPasses(raw_ostream &OS);
bool runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
TargetLibraryInfoImpl *TLII, ToolOutputFile *Out,
ToolOutputFile *ThinLinkOut, ToolOutputFile *OptRemarkFile,
StringRef PassPipeline, ArrayRef<StringRef> PassInfos,
StringRef PassPipeline,
ArrayRef<PassPlugin> PassPlugins, opt_tool::OutputKind OK,
opt_tool::VerifierKind VK,
bool ShouldPreserveAssemblyUseListOrder,
Expand Down
13 changes: 2 additions & 11 deletions llvm/tools/opt/opt.cpp
Expand Up @@ -664,26 +664,19 @@ int main(int argc, char **argv) {
"-debug-pass-manager, or use the legacy PM (-enable-new-pm=0)\n";
return 1;
}
if (PassPipeline.getNumOccurrences() > 0 && PassList.size() > 0) {
errs()
<< "Cannot specify passes via both -foo-pass and --passes=foo-pass\n";
return 1;
}
auto NumOLevel = OptLevelO0 + OptLevelO1 + OptLevelO2 + OptLevelO3 +
OptLevelOs + OptLevelOz;
if (NumOLevel > 1) {
errs() << "Cannot specify multiple -O#\n";
return 1;
}
if (NumOLevel > 0 &&
(PassPipeline.getNumOccurrences() > 0 || PassList.size() > 0)) {
if (NumOLevel > 0 && (PassPipeline.getNumOccurrences() > 0)) {
errs() << "Cannot specify -O# and --passes=/--foo-pass, use "
"-passes='default<O#>,other-pass'\n";
return 1;
}
std::string Pipeline = PassPipeline;

SmallVector<StringRef, 4> Passes;
if (OptLevelO0)
Pipeline = "default<O0>";
if (OptLevelO1)
Expand All @@ -696,8 +689,6 @@ int main(int argc, char **argv) {
Pipeline = "default<Os>";
if (OptLevelOz)
Pipeline = "default<Oz>";
for (const auto &P : PassList)
Passes.push_back(P->getPassArgument());
OutputKind OK = OK_NoOutput;
if (!NoOutput)
OK = OutputAssembly
Expand All @@ -715,7 +706,7 @@ int main(int argc, char **argv) {
// layer.
return runPassPipeline(argv[0], *M, TM.get(), &TLII, Out.get(),
ThinLinkOut.get(), RemarksFile.get(), Pipeline,
Passes, PluginList, OK, VK, PreserveAssemblyUseListOrder,
PluginList, OK, VK, PreserveAssemblyUseListOrder,
PreserveBitcodeUseListOrder, EmitSummaryIndex,
EmitModuleHash, EnableDebugify,
VerifyDebugInfoPreserve)
Expand Down

0 comments on commit 9c980f7

Please sign in to comment.