[llvm] r245170 - Revert r244127: [PM] Remove a failed attempt to port the CallGraph

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 15 23:35:19 PDT 2015


Author: chandlerc
Date: Sun Aug 16 01:35:19 2015
New Revision: 245170

URL: http://llvm.org/viewvc/llvm-project?rev=245170&view=rev
Log:
Revert r244127: [PM] Remove a failed attempt to port the CallGraph
analysis ...

It turns out that we *do* need the old CallGraph ported to the new pass
manager. There are times where this model of a call graph is really
superior to the one provided by the LazyCallGraph. For example,
GlobalsModRef very specifically needs the model provided by CallGraph.

While here, I've tried to make the move semantics actually work. =]

Modified:
    llvm/trunk/include/llvm/Analysis/CallGraph.h
    llvm/trunk/lib/Analysis/IPA/CallGraph.cpp

Modified: llvm/trunk/include/llvm/Analysis/CallGraph.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/CallGraph.h?rev=245170&r1=245169&r2=245170&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/CallGraph.h (original)
+++ llvm/trunk/include/llvm/Analysis/CallGraph.h Sun Aug 16 01:35:19 2015
@@ -105,7 +105,8 @@ class CallGraph {
   void addToCallGraph(Function *F);
 
 public:
-  CallGraph(Module &M);
+  explicit CallGraph(Module &M);
+  CallGraph(CallGraph &&Arg);
   ~CallGraph();
 
   void print(raw_ostream &OS) const;
@@ -288,6 +289,27 @@ private:
   void allReferencesDropped() { NumReferences = 0; }
 };
 
+/// \brief An analysis pass to compute the \c CallGraph for a \c Module.
+///
+/// This class implements the concept of an analysis pass used by the \c
+/// ModuleAnalysisManager to run an analysis over a module and cache the
+/// resulting data.
+class CallGraphAnalysis {
+public:
+  /// \brief A formulaic typedef to inform clients of the result type.
+  typedef CallGraph Result;
+
+  static void *ID() { return (void *)&PassID; }
+
+  /// \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); }
+
+private:
+  static char PassID;
+};
+
 /// \brief The \c ModulePass which wraps up a \c CallGraph and the logic to
 /// build it.
 ///

Modified: llvm/trunk/lib/Analysis/IPA/CallGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/CallGraph.cpp?rev=245170&r1=245169&r2=245170&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/IPA/CallGraph.cpp (original)
+++ llvm/trunk/lib/Analysis/IPA/CallGraph.cpp Sun Aug 16 01:35:19 2015
@@ -32,6 +32,15 @@ CallGraph::CallGraph(Module &M)
     Root = ExternalCallingNode;
 }
 
+CallGraph::CallGraph(CallGraph &&Arg)
+    : M(Arg.M), FunctionMap(std::move(Arg.FunctionMap)), Root(Arg.Root),
+      ExternalCallingNode(Arg.ExternalCallingNode),
+      CallsExternalNode(std::move(Arg.CallsExternalNode)) {
+  Arg.FunctionMap.clear();
+  Arg.Root = nullptr;
+  Arg.ExternalCallingNode = nullptr;
+}
+
 CallGraph::~CallGraph() {
   // CallsExternalNode is not in the function map, delete it explicitly.
   if (CallsExternalNode)
@@ -253,6 +262,12 @@ void CallGraphNode::replaceCallEdge(Call
 }
 
 //===----------------------------------------------------------------------===//
+// Out-of-line definitions of CallGraphAnalysis class members.
+//
+
+char CallGraphAnalysis::PassID;
+
+//===----------------------------------------------------------------------===//
 // Implementations of the CallGraphWrapperPass class methods.
 //
 




More information about the llvm-commits mailing list