summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorFedor Sergeev <fedor.sergeev@azul.com>2018-10-15 10:46:35 +0000
committerFedor Sergeev <fedor.sergeev@azul.com>2018-10-15 10:46:35 +0000
commit0dc6ac91651c2053af35b93af2a4067d85e4f268 (patch)
tree85ffc5e2371dc47cad7bf52db8cbc2f8ac650c8c /llvm/lib
parente303c87e1979f7172d49c7ceacfb1b1694932225 (diff)
downloadbcm5719-llvm-0dc6ac91651c2053af35b93af2a4067d85e4f268.tar.gz
bcm5719-llvm-0dc6ac91651c2053af35b93af2a4067d85e4f268.zip
[NewPM] implement SCC printing for -print-before-all/-print-after-all
Removing deficiency of initial implementation of -print-before-all/-after-all - it was effectively skipping IR printing for all the SCC passes. Now LazyCallGraph:SCC gets its IR printed. Reviewed By: skatkov Differential Revision: https://reviews.llvm.org/D53270 llvm-svn: 344505
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Passes/StandardInstrumentations.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index aa34584fa12..48d36e5a01e 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -37,10 +37,6 @@ namespace PrintIR {
/// Generic IR-printing helper that unpacks a pointer to IRUnit wrapped into
/// llvm::Any and does actual print job.
void unwrapAndPrint(StringRef Banner, Any IR) {
- if (any_isa<const CallGraphSCC *>(IR) ||
- any_isa<const LazyCallGraph::SCC *>(IR))
- return;
-
SmallString<40> Extra{"\n"};
const Module *M = nullptr;
if (any_isa<const Module *>(IR)) {
@@ -55,6 +51,34 @@ void unwrapAndPrint(StringRef Banner, Any IR) {
}
M = F->getParent();
Extra = formatv(" (function: {0})\n", F->getName());
+ } else if (any_isa<const LazyCallGraph::SCC *>(IR)) {
+ const LazyCallGraph::SCC *C = any_cast<const LazyCallGraph::SCC *>(IR);
+ assert(C);
+ if (!llvm::forcePrintModuleIR()) {
+ Extra = formatv(" (scc: {0})\n", C->getName());
+ bool BannerPrinted = false;
+ for (const LazyCallGraph::Node &N : *C) {
+ const Function &F = N.getFunction();
+ if (!F.isDeclaration() && isFunctionInPrintList(F.getName())) {
+ if (!BannerPrinted) {
+ dbgs() << Banner << Extra;
+ BannerPrinted = true;
+ }
+ F.print(dbgs());
+ }
+ }
+ return;
+ }
+ for (const LazyCallGraph::Node &N : *C) {
+ const Function &F = N.getFunction();
+ if (!F.isDeclaration() && isFunctionInPrintList(F.getName())) {
+ M = F.getParent();
+ break;
+ }
+ }
+ if (!M)
+ return;
+ Extra = formatv(" (for scc: {0})\n", C->getName());
} else if (any_isa<const Loop *>(IR)) {
const Loop *L = any_cast<const Loop *>(IR);
const Function *F = L->getHeader()->getParent();
OpenPOWER on IntegriCloud