[llvm] r348144 - Fixing -print-module-scope for legacy SCC passes
Fedor Sergeev via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 3 06:48:15 PST 2018
Author: fedor.sergeev
Date: Mon Dec 3 06:48:15 2018
New Revision: 348144
URL: http://llvm.org/viewvc/llvm-project?rev=348144&view=rev
Log:
Fixing -print-module-scope for legacy SCC passes
It appears that print-module-scope was not implemented for legacy SCC passes.
Fixed to print a whole module instead of just current SCC.
Reviewed By: mkazantsev
Differential Revision: https://reviews.llvm.org/D54793
Modified:
llvm/trunk/lib/Analysis/CallGraphSCCPass.cpp
llvm/trunk/test/Other/scc-pass-printer.ll
Modified: llvm/trunk/lib/Analysis/CallGraphSCCPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CallGraphSCCPass.cpp?rev=348144&r1=348143&r2=348144&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/CallGraphSCCPass.cpp (original)
+++ llvm/trunk/lib/Analysis/CallGraphSCCPass.cpp Mon Dec 3 06:48:15 2018
@@ -633,23 +633,40 @@ namespace {
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;
}
Modified: llvm/trunk/test/Other/scc-pass-printer.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/scc-pass-printer.ll?rev=348144&r1=348143&r2=348144&view=diff
==============================================================================
--- llvm/trunk/test/Other/scc-pass-printer.ll (original)
+++ llvm/trunk/test/Other/scc-pass-printer.ll Mon Dec 3 06:48:15 2018
@@ -18,6 +18,8 @@
; 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()
@@ -25,6 +27,8 @@
; 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()
@@ -32,6 +36,9 @@
; 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()
More information about the llvm-commits
mailing list