<div dir="ltr">Oops, was looking at the wrong ~CallGraph (one in Clang, not in LLVM).<br><br>This one's a bit more involved & possibly trickier to make movable: <a href="http://llvm.org/docs/doxygen/html/CallGraph_8cpp_source.html#l00035">http://llvm.org/docs/doxygen/html/CallGraph_8cpp_source.html#l00035</a> <br><br>Hmm, maybe not - just unique_ptrifying the relevant members and moving them over should probably suffice.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 5, 2015 at 10:47 AM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Mon, Dec 2, 2013 at 4:35 AM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: chandlerc<br>
Date: Mon Dec 2 06:35:56 2013<br>
New Revision: 196095<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=196095&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=196095&view=rev</a><br>
Log:<br>
[PM] [cleanup] Rearrange the public and private sections of this class<br>
to be a bit more sensible. The public interface now is first followed by<br>
the implementation details.<br>
<br>
This also resolves a FIXME to make something private -- it was already<br>
possible as the one special caller was already a friend.<br>
<br>
No functionality changed.<br>
<br>
Modified:<br>
llvm/trunk/include/llvm/Analysis/CallGraph.h<br>
<br>
Modified: llvm/trunk/include/llvm/Analysis/CallGraph.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/CallGraph.h?rev=196095&r1=196094&r2=196095&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/CallGraph.h?rev=196095&r1=196094&r2=196095&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Analysis/CallGraph.h (original)<br>
+++ llvm/trunk/include/llvm/Analysis/CallGraph.h Mon Dec 2 06:35:56 2013<br>
@@ -165,28 +165,11 @@ public:<br>
/// Typically represents a function in the call graph. There are also special<br>
/// "null" nodes used to represent theoretical entries in the call graph.<br>
class CallGraphNode {<br>
- friend class CallGraph;<br>
-<br>
- AssertingVH<Function> F;<br>
-<br>
public:<br>
/// \brief A pair of the calling instruction (a call or invoke)<br>
/// and the call graph node being called.<br>
typedef std::pair<WeakVH, CallGraphNode *> CallRecord;<br>
<br>
-private:<br>
- std::vector<CallRecord> CalledFunctions;<br>
-<br>
- /// \brief The number of times that this CallGraphNode occurs in the<br>
- /// CalledFunctions array of this or other CallGraphNodes.<br>
- unsigned NumReferences;<br>
-<br>
- CallGraphNode(const CallGraphNode &) LLVM_DELETED_FUNCTION;<br>
- void operator=(const CallGraphNode &) LLVM_DELETED_FUNCTION;<br>
-<br>
- void DropRef() { --NumReferences; }<br>
- void AddRef() { ++NumReferences; }<br>
-<br>
public:<br>
typedef std::vector<CallRecord> CalledFunctionsVector;<br>
<br>
@@ -281,12 +264,48 @@ public:<br>
/// Note that this method takes linear time, so it should be used sparingly.<br>
void replaceCallEdge(CallSite CS, CallSite NewCS, CallGraphNode *NewNode);<br>
<br>
+private:<br>
+ friend class CallGraph;<br>
+<br>
+ AssertingVH<Function> F;<br>
+<br>
+ std::vector<CallRecord> CalledFunctions;<br>
+<br>
+ /// \brief The number of times that this CallGraphNode occurs in the<br>
+ /// CalledFunctions array of this or other CallGraphNodes.<br>
+ unsigned NumReferences;<br>
+<br>
+ CallGraphNode(const CallGraphNode &) LLVM_DELETED_FUNCTION;<br>
+ void operator=(const CallGraphNode &) LLVM_DELETED_FUNCTION;<br>
+<br>
+ void DropRef() { --NumReferences; }<br>
+ void AddRef() { ++NumReferences; }<br>
+<br>
/// \brief A special function that should only be used by the CallGraph class.<br>
- //<br>
- // FIXME: Make this private?<br>
void allReferencesDropped() { NumReferences = 0; }<br>
};<br>
<br>
+/// \brief An analysis pass to compute the \c CallGraph for a \c Module.<br>
+///<br>
+/// This class implements the concept of an analysis pass used by the \c<br>
+/// ModuleAnalysisManager to run an analysis over a module and cache the<br>
+/// resulting data.<br>
+class CallGraphAnalysis {<br>
+public:<br>
+ /// \brief A formulaic typedef to inform clients of the result type.<br>
+ typedef CallGraph Result;<br>
+<br>
+ static void *ID() { return (void *)&PassID; }<br>
+<br>
+ /// \brief Compute the \c CallGraph for the module \c M.<br>
+ ///<br>
+ /// The real work here is done in the \c CallGraph constructor.<br>
+ CallGraph run(Module *M) { return CallGraph(*M); }<br></blockquote><div><br></div></div></div><div>This introduces a call to the implicit copy ctor of CallGraph which is probably incorrect (since ~CallGraph involves a call to "<span style="color:rgb(0,0,0);font-family:monospace,fixed;font-size:9pt;line-height:15px;background-color:rgb(251,252,253)">llvm::DeleteContainerSeconds(FunctionMap);"). <br><br>The type can probably be made implicitly movable by just updating FunctionMap's values to be unique_ptrs, but this code also seems untested (changing the definition of 'run' to be "= delete" doesn't break the build). Should it be removed? updated? tested in some way?<br><br>(found this while cleaning up -Wdeprecated warnings in LLVM)<span class="HOEnZb"><font color="#888888"><br><br>- David</font></span></span></div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+private:<br>
+ static char PassID;<br>
+};<br>
+<br>
/// \brief The \c ModulePass which wraps up a \c CallGraph and the logic to<br>
/// build it.<br>
///<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></span></div><br></div></div>
</blockquote></div><br></div>