[PATCH] D66560: [IRPrinting] Improve module pass printer to work better with -filter-print-funcs
Taewook Oh via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 4 01:08:49 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370849: [IRPrinting] Improve module pass printer to work better with -filter-print-funcs (authored by twoh, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D66560?vs=216875&id=218606#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66560/new/
https://reviews.llvm.org/D66560
Files:
llvm/trunk/lib/IR/IRPrintingPasses.cpp
llvm/trunk/test/Other/module-pass-printer.ll
Index: llvm/trunk/lib/IR/IRPrintingPasses.cpp
===================================================================
--- llvm/trunk/lib/IR/IRPrintingPasses.cpp
+++ llvm/trunk/lib/IR/IRPrintingPasses.cpp
@@ -26,14 +26,22 @@
ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}
PreservedAnalyses PrintModulePass::run(Module &M, ModuleAnalysisManager &) {
- if (!Banner.empty())
- OS << Banner << "\n";
- if (llvm::isFunctionInPrintList("*"))
+ if (llvm::isFunctionInPrintList("*")) {
+ if (!Banner.empty())
+ OS << Banner << "\n";
M.print(OS, nullptr, ShouldPreserveUseListOrder);
+ }
else {
- for(const auto &F : M.functions())
- if (llvm::isFunctionInPrintList(F.getName()))
+ bool BannerPrinted = false;
+ for(const auto &F : M.functions()) {
+ if (llvm::isFunctionInPrintList(F.getName())) {
+ if (!BannerPrinted && !Banner.empty()) {
+ OS << Banner << "\n";
+ BannerPrinted = true;
+ }
F.print(OS);
+ }
+ }
}
return PreservedAnalyses::all();
}
Index: llvm/trunk/test/Other/module-pass-printer.ll
===================================================================
--- llvm/trunk/test/Other/module-pass-printer.ll
+++ llvm/trunk/test/Other/module-pass-printer.ll
@@ -0,0 +1,18 @@
+; Check pass name is only printed once.
+; RUN: opt < %s 2>&1 -forceattrs -disable-output -print-after-all | FileCheck %s
+; RUN: opt < %s 2>&1 -forceattrs -disable-output -print-after-all -filter-print-funcs=foo,bar | FileCheck %s
+
+; Check pass name is not printed if a module doesn't include any function specified in -filter-print-funcs.
+; RUN: opt < %s 2>&1 -forceattrs -disable-output -print-after-all -filter-print-funcs=baz | FileCheck %s -allow-empty -check-prefix=EMPTY
+
+; CHECK: *** IR Dump After Force set function attributes ***
+; CHECK-NOT: *** IR Dump After Force set function attributes ***
+; EMPTY-NOT: *** IR Dump After Force set function attributes ***
+
+define void @foo() {
+ ret void
+}
+
+define void @bar() {
+ ret void
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66560.218606.patch
Type: text/x-patch
Size: 2049 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190904/7a0e376d/attachment.bin>
More information about the llvm-commits
mailing list