Skip to content

[lld][LTO] Teach LTO to print pipeline passes #101018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions llvm/include/llvm/Passes/PassBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,10 @@ class NoOpLoopAnalysis : public AnalysisInfoMixin<NoOpLoopAnalysis> {
return Result();
}
};

/// Common option used by multiple tools to print pipeline passes
extern cl::opt<bool> PrintPipelinePasses;

}

#endif
10 changes: 10 additions & 0 deletions llvm/lib/LTO/LTOBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,16 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM,
if (!Conf.DisableVerify)
MPM.addPass(VerifierPass());

if (PrintPipelinePasses) {
std::string PipelineStr;
raw_string_ostream OS(PipelineStr);
MPM.printPipeline(OS, [&PIC](StringRef ClassName) {
auto PassName = PIC.getPassNameForClassName(ClassName);
return PassName.empty() ? ClassName : PassName;
});
outs() << "pipeline-passes: " << PipelineStr << '\n';
}

MPM.run(Mod, MAM);
}

Expand Down
13 changes: 13 additions & 0 deletions llvm/test/LTO/X86/print-pipeline-passes.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
; RUN: llvm-as < %s >%t.bc
; RUN: llvm-lto -print-pipeline-passes -exported-symbol=_f -o /dev/null %t.bc 2>&1 | FileCheck %s

; CHECK: pipeline-passes: verify,{{.*}},verify

target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.10.0"


define void @f() {
entry:
ret void
}
4 changes: 0 additions & 4 deletions llvm/tools/llc/NewPMDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@
#include "llvm/Transforms/Scalar/LoopPassManager.h"
#include "llvm/Transforms/Utils/Cloning.h"

namespace llvm {
extern cl::opt<bool> PrintPipelinePasses;
} // namespace llvm

using namespace llvm;

static cl::opt<std::string>
Expand Down
4 changes: 0 additions & 4 deletions llvm/tools/opt/NewPMDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,6 @@ static cl::opt<bool> DisableLoopUnrolling(
"disable-loop-unrolling",
cl::desc("Disable loop unrolling in all relevant passes"), cl::init(false));

namespace llvm {
extern cl::opt<bool> PrintPipelinePasses;
} // namespace llvm

template <typename PassManagerT>
bool tryParsePipelineText(PassBuilder &PB,
const cl::opt<std::string> &PipelineOpt) {
Expand Down
Loading