[PATCH] D54793: Fixing -print-module-scope for legacy SCC passes
Fedor Sergeev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 3 06:51:18 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348144: Fixing -print-module-scope for legacy SCC passes (authored by fedor.sergeev, committed by ).
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D54793/new/
https://reviews.llvm.org/D54793
Files:
llvm/trunk/lib/Analysis/CallGraphSCCPass.cpp
llvm/trunk/test/Other/scc-pass-printer.ll
Index: llvm/trunk/lib/Analysis/CallGraphSCCPass.cpp
===================================================================
--- llvm/trunk/lib/Analysis/CallGraphSCCPass.cpp
+++ llvm/trunk/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;
}
Index: llvm/trunk/test/Other/scc-pass-printer.ll
===================================================================
--- llvm/trunk/test/Other/scc-pass-printer.ll
+++ llvm/trunk/test/Other/scc-pass-printer.ll
@@ -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()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54793.176392.patch
Type: text/x-patch
Size: 2641 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181203/91bb8512/attachment.bin>
More information about the llvm-commits
mailing list