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