summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2016-03-10 11:24:11 +0000
committerChandler Carruth <chandlerc@gmail.com>2016-03-10 11:24:11 +0000
commit4c660f70870023d62e5fd353c7038359fd23391e (patch)
tree544bae0a5bdc791c067b8446191caf77350bffc5
parentb95def749141e0d5c5985be74c3fb2a4ae308fb0 (diff)
downloadbcm5719-llvm-4c660f70870023d62e5fd353c7038359fd23391e.tar.gz
bcm5719-llvm-4c660f70870023d62e5fd353c7038359fd23391e.zip
[CG] Add a new pass manager printer pass for the old call graph and
actually finish wiring up the old call graph. There were bugs in the old call graph that hadn't been caught because it wasn't being tested. It wasn't being tested because it wasn't in the pipeline system and we didn't have a printing pass to run in tests. This fixes all of that. As for why I'm still keeping the old call graph alive its so that I can port GlobalsAA to the new pass manager with out forking it to work with the lazy call graph. That's clearly the right eventual design, but it seems pragmatic to defer that until its necessary. The old call graph works just fine for GlobalsAA. llvm-svn: 263104
-rw-r--r--llvm/include/llvm/Analysis/CallGraph.h11
-rw-r--r--llvm/lib/Analysis/CallGraph.cpp6
-rw-r--r--llvm/lib/Passes/PassBuilder.cpp1
-rw-r--r--llvm/lib/Passes/PassRegistry.def2
-rw-r--r--llvm/test/Analysis/CallGraph/no-intrinsics.ll1
-rw-r--r--llvm/test/Other/new-pass-manager.ll8
6 files changed, 28 insertions, 1 deletions
diff --git a/llvm/include/llvm/Analysis/CallGraph.h b/llvm/include/llvm/Analysis/CallGraph.h
index 5f329913121..7feccefdc59 100644
--- a/llvm/include/llvm/Analysis/CallGraph.h
+++ b/llvm/include/llvm/Analysis/CallGraph.h
@@ -303,7 +303,16 @@ public:
/// \brief Compute the \c CallGraph for the module \c M.
///
/// The real work here is done in the \c CallGraph constructor.
- CallGraph run(Module *M) { return CallGraph(*M); }
+ CallGraph run(Module &M) { return CallGraph(M); }
+};
+
+/// \brief Printer pass for the \c CallGraphAnalysis results.
+class CallGraphPrinterPass : public PassBase<CallGraphPrinterPass> {
+ raw_ostream &OS;
+
+public:
+ explicit CallGraphPrinterPass(raw_ostream &OS) : OS(OS) {}
+ PreservedAnalyses run(Module &M, AnalysisManager<Module> *AM);
};
/// \brief The \c ModulePass which wraps up a \c CallGraph and the logic to
diff --git a/llvm/lib/Analysis/CallGraph.cpp b/llvm/lib/Analysis/CallGraph.cpp
index 235d0f61263..594e886e539 100644
--- a/llvm/lib/Analysis/CallGraph.cpp
+++ b/llvm/lib/Analysis/CallGraph.cpp
@@ -259,6 +259,12 @@ void CallGraphNode::replaceCallEdge(CallSite CS,
}
}
+PreservedAnalyses CallGraphPrinterPass::run(Module &M,
+ AnalysisManager<Module> *AM) {
+ AM->getResult<CallGraphAnalysis>(M).print(OS);
+ return PreservedAnalyses::all();
+}
+
//===----------------------------------------------------------------------===//
// Out-of-line definitions of CallGraphAnalysis class members.
//
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 38e1dd00661..7f55353ab50 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -23,6 +23,7 @@
#include "llvm/Analysis/BasicAliasAnalysis.h"
#include "llvm/Analysis/CFLAliasAnalysis.h"
#include "llvm/Analysis/CGSCCPassManager.h"
+#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/DominanceFrontier.h"
#include "llvm/Analysis/LazyCallGraph.h"
#include "llvm/Analysis/LoopInfo.h"
diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def
index 0bc3739f3f1..112ce909910 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -19,6 +19,7 @@
#ifndef MODULE_ANALYSIS
#define MODULE_ANALYSIS(NAME, CREATE_PASS)
#endif
+MODULE_ANALYSIS("callgraph", CallGraphAnalysis())
MODULE_ANALYSIS("lcg", LazyCallGraphAnalysis())
MODULE_ANALYSIS("no-op-module", NoOpModuleAnalysis())
MODULE_ANALYSIS("targetlibinfo", TargetLibraryAnalysis())
@@ -32,6 +33,7 @@ MODULE_PASS("inferattrs", InferFunctionAttrsPass())
MODULE_PASS("invalidate<all>", InvalidateAllAnalysesPass())
MODULE_PASS("no-op-module", NoOpModulePass())
MODULE_PASS("print", PrintModulePass(dbgs()))
+MODULE_PASS("print-callgraph", CallGraphPrinterPass(dbgs()))
MODULE_PASS("print-lcg", LazyCallGraphPrinterPass(dbgs()))
MODULE_PASS("strip-dead-prototypes", StripDeadPrototypesPass())
MODULE_PASS("verify", VerifierPass())
diff --git a/llvm/test/Analysis/CallGraph/no-intrinsics.ll b/llvm/test/Analysis/CallGraph/no-intrinsics.ll
index d858907d724..69bfce77918 100644
--- a/llvm/test/Analysis/CallGraph/no-intrinsics.ll
+++ b/llvm/test/Analysis/CallGraph/no-intrinsics.ll
@@ -1,4 +1,5 @@
; RUN: opt < %s -print-callgraph -disable-output 2>&1 | FileCheck %s
+; RUN: opt < %s -passes=print-callgraph -disable-output 2>&1 | FileCheck %s
; Check that intrinsics aren't added to the call graph
diff --git a/llvm/test/Other/new-pass-manager.ll b/llvm/test/Other/new-pass-manager.ll
index 67a6672165b..1ffd422c6a2 100644
--- a/llvm/test/Other/new-pass-manager.ll
+++ b/llvm/test/Other/new-pass-manager.ll
@@ -323,6 +323,14 @@
; CHECK-MEMDEP: Running analysis: MemoryDependenceAnalysis
; CHECK-MEMDEP: Finished llvm::Module pass manager run
+; RUN: opt -disable-output -disable-verify -debug-pass-manager %s 2>&1 \
+; RUN: -passes='require<callgraph>' \
+; RUN: | FileCheck %s --check-prefix=CHECK-CALLGRAPH
+; CHECK-CALLGRAPH: Starting llvm::Module pass manager run
+; CHECK-CALLGRAPH: Running pass: RequireAnalysisPass
+; CHECK-CALLGRAPH: Running analysis: CallGraphAnalysis
+; CHECK-CALLGRAPH: Finished llvm::Module pass manager run
+
; RUN: opt -disable-output -disable-verify -debug-pass-manager \
; RUN: -passes='default<O0>' %s 2>&1 \
; RUN: | FileCheck %s --check-prefix=CHECK-O2
OpenPOWER on IntegriCloud