[PATCH] D49291: [LegacyPassManager] Fix dumpPassArguments() for clang
Son Tuan Vu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 13 06:29:40 PDT 2018
tyb0807 created this revision.
tyb0807 added a reviewer: dexonsmith.
Herald added a subscriber: llvm-commits.
Hi,
Here's the current situation:
$ opt -debug-pass=Structure -S -print-after-all -O0 < test.ll
Pass Arguments: -tti -verify -print-function -ee-instrument -print-function
Target Transform Information
FunctionPass Manager
Module Verifier
Print Function IR
Instrument function entry/exit with calls to e.g. mcount() (pre inlining)
Print Function IR
whereas:
$ clang -mllvm -debug-pass=Structure -mllvm -print-after-all -emit-llvm -S -O0 -o - test.c
Pass Arguments: -tti -targetlibinfo -verify -ee-instrument
Target Transform Information
Target Library Information
FunctionPass Manager
Module Verifier
Print Function IR
Instrument function entry/exit with calls to e.g. mcount() (pre inlining)
Print Function IR
As you can see, the `Pass Arguments` display for clang is not accurate: it does not have `print-function` command, while the `PrintFunctionPass` is indeed in the pipeline and gets executed (as pointed out by the pipeline structure).
This patch is supposed to fix this: `PMDataManager::dumpPassArguments()` will consider different IR printing passes (`PrintModulePass`, `PrintFunctionPass` and `PrintBasicBlockPass`). As for `PrintCallGraphSCCPass`, `PrintLoopPass` and `PrintRegionPass`, users can't explicitly insert them into the pipeline (there's no command line argument to do it), so I guess it is correct to not see them in `debug-pass=Arguments` even though `debug-pass=Structure` does show that they are in the pipeline.
Sorry to bother you again Duncan , I don't know anybody else to help me review this other than you.
Thank you very much
Repository:
rL LLVM
https://reviews.llvm.org/D49291
Files:
lib/IR/IRPrintingPasses.cpp
test/Other/printer.c
Index: test/Other/printer.c
===================================================================
--- /dev/null
+++ test/Other/printer.c
@@ -0,0 +1,9 @@
+// RUN: clang -mllvm -debug-pass=Arguments -mllvm -print-after-all -emit-llvm -S -o - %s 2>&1 | \
+// RUN: FileCheck %s
+
+int foo() {
+ return 0;
+}
+
+// CHECK: Pass Arguments: -tti -targetlibinfo -verify -print-function -ee-instrument -print-function
+// CHECK: Pass Arguments: -tti -targetlibinfo -assumption-cache-tracker -profile-summary-info -forceattrs -print-module -basiccg -always-inline
Index: lib/IR/IRPrintingPasses.cpp
===================================================================
--- lib/IR/IRPrintingPasses.cpp
+++ lib/IR/IRPrintingPasses.cpp
@@ -60,10 +60,14 @@
public:
static char ID;
- PrintModulePassWrapper() : ModulePass(ID) {}
+ PrintModulePassWrapper() : ModulePass(ID) {
+ initializePrintModulePassWrapperPass(*PassRegistry::getPassRegistry());
+ }
PrintModulePassWrapper(raw_ostream &OS, const std::string &Banner,
bool ShouldPreserveUseListOrder)
- : ModulePass(ID), P(OS, Banner, ShouldPreserveUseListOrder) {}
+ : ModulePass(ID), P(OS, Banner, ShouldPreserveUseListOrder) {
+ initializePrintModulePassWrapperPass(*PassRegistry::getPassRegistry());
+ }
bool runOnModule(Module &M) override {
ModuleAnalysisManager DummyMAM;
@@ -83,9 +87,13 @@
public:
static char ID;
- PrintFunctionPassWrapper() : FunctionPass(ID) {}
+ PrintFunctionPassWrapper() : FunctionPass(ID) {
+ initializePrintFunctionPassWrapperPass(*PassRegistry::getPassRegistry());
+ }
PrintFunctionPassWrapper(raw_ostream &OS, const std::string &Banner)
- : FunctionPass(ID), P(OS, Banner) {}
+ : FunctionPass(ID), P(OS, Banner) {
+ initializePrintFunctionPassWrapperPass(*PassRegistry::getPassRegistry());
+ }
// This pass just prints a banner followed by the function as it's processed.
bool runOnFunction(Function &F) override {
@@ -107,9 +115,13 @@
public:
static char ID;
- PrintBasicBlockPass() : BasicBlockPass(ID), Out(dbgs()) {}
+ PrintBasicBlockPass() : BasicBlockPass(ID), Out(dbgs()) {
+ initializePrintBasicBlockPassPass(*PassRegistry::getPassRegistry());
+ }
PrintBasicBlockPass(raw_ostream &Out, const std::string &Banner)
- : BasicBlockPass(ID), Out(Out), Banner(Banner) {}
+ : BasicBlockPass(ID), Out(Out), Banner(Banner) {
+ initializePrintBasicBlockPassPass(*PassRegistry::getPassRegistry());
+ }
bool runOnBasicBlock(BasicBlock &BB) override {
Out << Banner << BB;
@@ -123,7 +135,7 @@
StringRef getPassName() const override { return "Print BasicBlock IR"; }
};
-}
+} // end anonymous namespace
char PrintModulePassWrapper::ID = 0;
INITIALIZE_PASS(PrintModulePassWrapper, "print-module",
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49291.155365.patch
Type: text/x-patch
Size: 2819 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180713/fe198d98/attachment.bin>
More information about the llvm-commits
mailing list