summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-31 01:54:59 +0000
committerChris Lattner <sabre@nondot.org>2003-08-31 01:54:59 +0000
commitf7e9594843df89f82aa69a5a8fd452e4ab2a9763 (patch)
treec0d516c6d3037779e430106b55f319f745eda4d3 /llvm/lib/Analysis
parenta74a63c8f9ea335bd138d57083c35a04cd829890 (diff)
downloadbcm5719-llvm-f7e9594843df89f82aa69a5a8fd452e4ab2a9763.tar.gz
bcm5719-llvm-f7e9594843df89f82aa69a5a8fd452e4ab2a9763.zip
Initial checkin of the CallGraphSCCPass class
llvm-svn: 8247
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp b/llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp
new file mode 100644
index 00000000000..fd5e1ca80ef
--- /dev/null
+++ b/llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp
@@ -0,0 +1,30 @@
+//===- CallGraphSCCPass.cpp - Pass that operates BU on call graph ---------===//
+//
+// This file implements the CallGraphSCCPass class, which is used for passes
+// which are implemented as bottom-up traversals on the call graph. Because
+// there may be cycles in the call graph, passes of this type operate on the
+// call-graph in SCC order: that is, they process function bottom-up, except for
+// recursive functions, which they process all at once.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/CallGraphSCCPass.h"
+#include "llvm/Analysis/CallGraph.h"
+#include "Support/TarjanSCCIterator.h"
+
+/// getAnalysisUsage - For this class, we declare that we require and preserve
+/// the call graph. If the derived class implements this method, it should
+/// always explicitly call the implementation here.
+void CallGraphSCCPass::getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.addRequired<CallGraph>();
+ AU.addPreserved<CallGraph>();
+}
+
+bool CallGraphSCCPass::run(Module &M) {
+ CallGraph &CG = getAnalysis<CallGraph>();
+ bool Changed = false;
+ for (TarjanSCC_iterator<CallGraph*> I = tarj_begin(&CG), E = tarj_end(&CG);
+ I != E; ++I)
+ Changed = runOnSCC(**I);
+ return Changed;
+}
OpenPOWER on IntegriCloud