[PATCH] D54793: Fixing -print-module-scope for legacy SCC passes
Fedor Sergeev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 21 06:00:55 PST 2018
fedor.sergeev created this revision.
fedor.sergeev added reviewers: chandlerc, philip.pfaffe, apilipenko, mkazantsev, skatkov.
It appears that print-module-scope was not implemented for legacy SCC passes.
Fixed to print a whole module instead of just current SCC.
Repository:
rL LLVM
https://reviews.llvm.org/D54793
Files:
lib/Analysis/CallGraphSCCPass.cpp
test/Other/scc-pass-printer.ll
Index: test/Other/scc-pass-printer.ll
===================================================================
--- test/Other/scc-pass-printer.ll
+++ test/Other/scc-pass-printer.ll
@@ -18,20 +18,27 @@
; INL: IR Dump After
; INL-MOD: IR Dump After {{Function Integration/Inlining|InlinerPass .*scc: .bar, foo}}
+; INL-MOD-NEXT: ModuleID =
+; INL-MOD-NEXT: source_filename =
; INL-MOD: define void @tester()
; INL-MOD-NEXT: call void @foo()
; INL-MOD: define void @foo()
; INL-MOD-NEXT: call void @bar()
; INL-MOD: define void @bar()
; INL-MOD-NEXT: call void @foo()
; INL-MOD: IR Dump After {{Function Integration/Inlining|InlinerPass .*scc: .tester}}
+; INL-MOD-NEXT: ModuleID =
+; INL-MOD-NEXT: source_filename =
; INL-MOD: define void @tester()
; INL-MOD-NEXT: call void @foo()
; INL-MOD: define void @foo()
; INL-MOD-NEXT: call void @bar()
; INL-MOD: define void @bar()
; INL-MOD-NEXT: call void @foo()
; INL-MOD: IR Dump After
+; INL-MOD-NEXT: ModuleID =
+; INL-MOD-NEXT: source_filename =
+; INL-MOD-NOT: Printing <null> Function
define void @tester() noinline {
call void @foo()
Index: lib/Analysis/CallGraphSCCPass.cpp
===================================================================
--- lib/Analysis/CallGraphSCCPass.cpp
+++ lib/Analysis/CallGraphSCCPass.cpp
@@ -633,23 +633,40 @@
bool runOnSCC(CallGraphSCC &SCC) override {
bool BannerPrinted = false;
- auto PrintBannerOnce = [&] () {
+ auto PrintBannerOnce = [&]() {
if (BannerPrinted)
return;
OS << Banner;
BannerPrinted = true;
- };
+ };
+
+ bool NeedModule = llvm::forcePrintModuleIR();
+ if (isFunctionInPrintList("*") && NeedModule) {
+ PrintBannerOnce();
+ OS << "\n";
+ SCC.getCallGraph().getModule().print(OS, nullptr);
+ return false;
+ }
+ bool FoundFunction = false;
for (CallGraphNode *CGN : SCC) {
if (Function *F = CGN->getFunction()) {
if (!F->isDeclaration() && isFunctionInPrintList(F->getName())) {
- PrintBannerOnce();
- F->print(OS);
+ FoundFunction = true;
+ if (!NeedModule) {
+ PrintBannerOnce();
+ F->print(OS);
+ }
}
} else if (isFunctionInPrintList("*")) {
PrintBannerOnce();
OS << "\nPrinting <null> Function\n";
}
}
+ if (NeedModule && FoundFunction) {
+ PrintBannerOnce();
+ OS << "\n";
+ SCC.getCallGraph().getModule().print(OS, nullptr);
+ }
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54793.174910.patch
Type: text/x-patch
Size: 2613 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181121/d2824fb3/attachment.bin>
More information about the llvm-commits
mailing list