1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00

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

llvm-svn: 348144
This commit is contained in:
Fedor Sergeev 2018-12-03 14:48:15 +00:00
parent 7777cbe23a
commit e9e52b4a6a
2 changed files with 28 additions and 4 deletions

View File

@ -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())) {
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;
}

View File

@ -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()