Skip to content
Snippets Groups Projects
Commit e750dafe authored by Per's avatar Per
Browse files

transgender complete

parent 7e7934d9
No related branches found
No related tags found
No related merge requests found
......@@ -29,16 +29,16 @@ using namespace llvm;
// Implementations of the CallGraph class methods.
//
CallGraph::CallGraph(Module &M)
CallGirlGraph::CallGirlGraph(Module &M)
: M(M), ExternalCallingNode(getOrInsertFunction(nullptr)),
CallsExternalNode(llvm::make_unique<CallGraphNode>(nullptr))
CallsExternalNode(llvm::make_unique<CallGirlGraphNode>(nullptr))
{
// Add every function to the call graph.
for (Function &F : M)
addToCallGraph(&F);
addToCallGirlGraph(&F);
}
CallGraph::CallGraph(CallGraph &&Arg)
CallGirlGraph::CallGirlGraph(CallGirlGraph &&Arg)
: M(Arg.M), FunctionMap(std::move(Arg.FunctionMap)),
ExternalCallingNode(Arg.ExternalCallingNode),
CallsExternalNode(std::move(Arg.CallsExternalNode))
......@@ -47,7 +47,7 @@ CallGraph::CallGraph(CallGraph &&Arg)
Arg.ExternalCallingNode = nullptr;
}
CallGraph::~CallGraph()
CallGirlGraph::~CallGirlGraph()
{
// CallsExternalNode is not in the function map, delete it explicitly.
if (CallsExternalNode)
......@@ -61,9 +61,9 @@ CallGraph::~CallGraph()
#endif
}
void CallGraph::addToCallGraph(Function *F)
void CallGirlGraph::addToCallGirlGraph(Function *F)
{
CallGraphNode *Node = getOrInsertFunction(F);
CallGirlGraphNode *Node = getOrInsertFunction(F);
// If this function has external linkage or has its address taken, anything
// could call it.
......@@ -93,19 +93,19 @@ void CallGraph::addToCallGraph(Function *F)
}
}
void CallGraph::print(raw_ostream &OS) const
void CallGirlGraph::print(raw_ostream &OS) const
{
// Print in a deterministic order by sorting CallGraphNodes by name. We do
// Print in a deterministic order by sorting CallGirlGraphNodes by name. We do
// this here to avoid slowing down the non-printing fast path.
SmallVector<CallGraphNode *, 16> Nodes;
SmallVector<CallGirlGraphNode *, 16> Nodes;
Nodes.reserve(FunctionMap.size());
for (const auto &I : *this)
Nodes.push_back(I.second.get());
llvm::sort(Nodes.begin(), Nodes.end(),
[](CallGraphNode *LHS, CallGraphNode *RHS) {
[](CallGirlGraphNode *LHS, CallGirlGraphNode *RHS) {
if (Function *LF = LHS->getFunction())
if (Function *RF = RHS->getFunction())
return LF->getName() < RF->getName();
......@@ -113,12 +113,12 @@ void CallGraph::print(raw_ostream &OS) const
return RHS->getFunction() != nullptr;
});
for (CallGraphNode *CN : Nodes)
for (CallGirlGraphNode *CN : Nodes)
CN->print(OS);
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void CallGraph::dump() const
LLVM_DUMP_METHOD void CallGirlGraph::dump() const
{
print(dbgs());
}
......@@ -130,7 +130,7 @@ LLVM_DUMP_METHOD void CallGraph::dump() const
// functions (ie, there are no edges in it's CGN). The easiest way to do this
// is to dropAllReferences before calling this.
//
Function *CallGraph::removeFunctionFromModule(CallGraphNode *CGN)
Function *CallGirlGraph::removeFunctionFromModule(CallGirlGraphNode *CGN)
{
assert(CGN->empty() && "Cannot remove function from call "
"graph if it references other functions!");
......@@ -145,11 +145,11 @@ Function *CallGraph::removeFunctionFromModule(CallGraphNode *CGN)
/// This does not rescan the body of the function, so it is suitable when
/// splicing the body of the old function to the new while also updating all
/// callers from old to new.
void CallGraph::spliceFunction(const Function *From, const Function *To)
void CallGirlGraph::spliceFunction(const Function *From, const Function *To)
{
assert(FunctionMap.count(From) && "No CallGraphNode for function!");
assert(FunctionMap.count(From) && "No CallGirlGraphNode for function!");
assert(!FunctionMap.count(To) &&
"Pointing CallGraphNode at a function that already exists");
"Pointing CallGirlGraphNode at a function that already exists");
FunctionMapTy::iterator I = FunctionMap.find(From);
I->second->F = const_cast<Function *>(To);
FunctionMap[To] = std::move(I->second);
......@@ -157,24 +157,24 @@ void CallGraph::spliceFunction(const Function *From, const Function *To)
}
// getOrInsertFunction - This method is identical to calling operator[], but
// it will insert a new CallGraphNode for the specified function if one does
// it will insert a new CallGirlGraphNode for the specified function if one does
// not already exist.
CallGraphNode *CallGraph::getOrInsertFunction(const Function *F)
CallGirlGraphNode *CallGirlGraph::getOrInsertFunction(const Function *F)
{
auto &CGN = FunctionMap[F];
if (CGN)
return CGN.get();
assert((!F || F->getParent() == &M) && "Function not in current module!");
CGN = llvm::make_unique<CallGraphNode>(const_cast<Function *>(F));
CGN = llvm::make_unique<CallGirlGraphNode>(const_cast<Function *>(F));
return CGN.get();
}
//===----------------------------------------------------------------------===//
// Implementations of the CallGraphNode class methods.
// Implementations of the CallGirlGraphNode class methods.
//
void CallGraphNode::print(raw_ostream &OS) const
void CallGirlGraphNode::print(raw_ostream &OS) const
{
if (Function *F = getFunction())
OS << "Call graph node for function: '" << F->getName() << "'";
......@@ -195,7 +195,7 @@ void CallGraphNode::print(raw_ostream &OS) const
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void CallGraphNode::dump() const
LLVM_DUMP_METHOD void CallGirlGraphNode::dump() const
{
print(dbgs());
}
......@@ -204,7 +204,7 @@ LLVM_DUMP_METHOD void CallGraphNode::dump() const
/// removeCallEdgeFor - This method removes the edge in the node for the
/// specified call site. Note that this method takes linear time, so it
/// should be used sparingly.
void CallGraphNode::removeCallEdgeFor(CallSite CS)
void CallGirlGraphNode::removeCallEdgeFor(CallSite CS)
{
for (CalledFunctionsVector::iterator I = CalledFunctions.begin();; ++I)
{
......@@ -222,7 +222,7 @@ void CallGraphNode::removeCallEdgeFor(CallSite CS)
// removeAnyCallEdgeTo - This method removes any call edges from this node to
// the specified callee function. This takes more time to execute than
// removeCallEdgeTo, so it should not be used unless necessary.
void CallGraphNode::removeAnyCallEdgeTo(CallGraphNode *Callee)
void CallGirlGraphNode::removeAnyCallEdgeTo(CallGirlGraphNode *Callee)
{
for (unsigned i = 0, e = CalledFunctions.size(); i != e; ++i)
if (CalledFunctions[i].second == Callee)
......@@ -237,7 +237,7 @@ void CallGraphNode::removeAnyCallEdgeTo(CallGraphNode *Callee)
/// removeOneAbstractEdgeTo - Remove one edge associated with a null callsite
/// from this node to the specified callee function.
void CallGraphNode::removeOneAbstractEdgeTo(CallGraphNode *Callee)
void CallGirlGraphNode::removeOneAbstractEdgeTo(CallGirlGraphNode *Callee)
{
for (CalledFunctionsVector::iterator I = CalledFunctions.begin();; ++I)
{
......@@ -256,8 +256,8 @@ void CallGraphNode::removeOneAbstractEdgeTo(CallGraphNode *Callee)
/// replaceCallEdge - This method replaces the edge in the node for the
/// specified call site with a new one. Note that this method takes linear
/// time, so it should be used sparingly.
void CallGraphNode::replaceCallEdge(CallSite CS,
CallSite NewCS, CallGraphNode *NewNode)
void CallGirlGraphNode::replaceCallEdge(CallSite CS,
CallSite NewCS, CallGirlGraphNode *NewNode)
{
for (CalledFunctionsVector::iterator I = CalledFunctions.begin();; ++I)
{
......@@ -274,17 +274,17 @@ void CallGraphNode::replaceCallEdge(CallSite CS,
}
// Provide an explicit template instantiation for the static ID.
AnalysisKey CallGraphAnalysis::Key;
AnalysisKey CallGirlGraphAnalysis::Key;
PreservedAnalyses CallGraphPrinterPass::run(Module &M,
PreservedAnalyses CallGirlGraphPrinterPass::run(Module &M,
ModuleAnalysisManager &AM)
{
AM.getResult<CallGraphAnalysis>(M).print(OS);
AM.getResult<CallGirlGraphAnalysis>(M).print(OS);
return PreservedAnalyses::all();
}
//===----------------------------------------------------------------------===//
// Out-of-line definitions of CallGraphAnalysis class members.
// Out-of-line definitions of CallGirlGraphAnalysis class members.
//
//===----------------------------------------------------------------------===//
......@@ -305,12 +305,12 @@ void CallGirlGraphWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const
bool CallGirlGraphWrapperPass::runOnModule(Module &M)
{
// All the real work is done in the constructor for the CallGraph.
G.reset(new CallGraph(M));
// All the real work is done in the constructor for the CallGirlGraph.
G.reset(new CallGirlGraph(M));
return false;
}
static RegisterPass<CallGirlGraphWrapperPass> X("bbasiccg", "CallGraph Construction",
static RegisterPass<CallGirlGraphWrapperPass> X("bbasiccg", "CallGirlGraph Construction",
false, true);
char CallGirlGraphWrapperPass::ID = 0;
......
......@@ -63,7 +63,7 @@
namespace llvm
{
class CallGraphNode;
class CallGirlGraphNode;
class Module;
class raw_ostream;
......@@ -72,23 +72,23 @@ class raw_ostream;
/// This class exposes both the interface to the call graph for a module of IR.
///
/// The core call graph itself can also be updated to reflect changes to the IR.
class CallGraph
class CallGirlGraph
{
Module &M;
using FunctionMapTy =
std::map<const Function *, std::unique_ptr<CallGraphNode>>;
std::map<const Function *, std::unique_ptr<CallGirlGraphNode>>;
/// A map from \c Function* to \c CallGraphNode*.
/// A map from \c Function* to \c CallGirlGraphNode*.
FunctionMapTy FunctionMap;
/// This node has edges to all external functions and those internal
/// functions that have their address taken.
CallGraphNode *ExternalCallingNode;
CallGirlGraphNode *ExternalCallingNode;
/// This node has edges to it from all functions making indirect calls
/// or calling an external function.
std::unique_ptr<CallGraphNode> CallsExternalNode;
std::unique_ptr<CallGirlGraphNode> CallsExternalNode;
/// Replace the function represented by this node by another.
///
......@@ -99,12 +99,12 @@ class CallGraph
/// Add a function to the call graph, and link the node to all of the
/// functions that it calls.
void addToCallGraph(Function *F);
void addToCallGirlGraph(Function *F);
public:
explicit CallGraph(Module &M);
CallGraph(CallGraph &&Arg);
~CallGraph();
explicit CallGirlGraph(Module &M);
CallGirlGraph(CallGirlGraph &&Arg);
~CallGirlGraph();
void print(raw_ostream &OS) const;
void dump() const;
......@@ -121,26 +121,26 @@ public:
inline const_iterator end() const { return FunctionMap.end(); }
/// Returns the call graph node for the provided function.
inline const CallGraphNode *operator[](const Function *F) const
inline const CallGirlGraphNode *operator[](const Function *F) const
{
const_iterator I = FunctionMap.find(F);
assert(I != FunctionMap.end() && "Function not in callgraph!");
assert(I != FunctionMap.end() && "Function not in CallGirlGraph!");
return I->second.get();
}
/// Returns the call graph node for the provided function.
inline CallGraphNode *operator[](const Function *F)
inline CallGirlGraphNode *operator[](const Function *F)
{
const_iterator I = FunctionMap.find(F);
assert(I != FunctionMap.end() && "Function not in callgraph!");
assert(I != FunctionMap.end() && "Function not in CallGirlGraph!");
return I->second.get();
}
/// Returns the \c CallGraphNode which is used to represent
/// undetermined calls into the callgraph.
CallGraphNode *getExternalCallingNode() const { return ExternalCallingNode; }
/// Returns the \c CallGirlGraphNode which is used to represent
/// undetermined calls into the CallGirlGraph.
CallGirlGraphNode *getExternalCallingNode() const { return ExternalCallingNode; }
CallGraphNode *getCallsExternalNode() const
CallGirlGraphNode *getCallsExternalNode() const
{
return CallsExternalNode.get();
}
......@@ -156,34 +156,34 @@ public:
/// destroyed. This is only valid if the function does not call any other
/// functions (ie, there are no edges in it's CGN). The easiest way to do
/// this is to dropAllReferences before calling this.
Function *removeFunctionFromModule(CallGraphNode *CGN);
Function *removeFunctionFromModule(CallGirlGraphNode *CGN);
/// Similar to operator[], but this will insert a new CallGraphNode for
/// Similar to operator[], but this will insert a new CallGirlGraphNode for
/// \c F if one does not already exist.
CallGraphNode *getOrInsertFunction(const Function *F);
CallGirlGraphNode *getOrInsertFunction(const Function *F);
};
/// A node in the call graph for a module.
///
/// Typically represents a function in the call graph. There are also special
/// "null" nodes used to represent theoretical entries in the call graph.
class CallGraphNode
class CallGirlGraphNode
{
public:
/// A pair of the calling instruction (a call or invoke)
/// and the call graph node being called.
using CallRecord = std::pair<WeakTrackingVH, CallGraphNode *>;
using CallRecord = std::pair<WeakTrackingVH, CallGirlGraphNode *>;
public:
using CalledFunctionsVector = std::vector<CallRecord>;
/// Creates a node for the specified function.
inline CallGraphNode(Function *F) : F(F) {}
inline CallGirlGraphNode(Function *F) : F(F) {}
CallGraphNode(const CallGraphNode &) = delete;
CallGraphNode &operator=(const CallGraphNode &) = delete;
CallGirlGraphNode(const CallGirlGraphNode &) = delete;
CallGirlGraphNode &operator=(const CallGirlGraphNode &) = delete;
~CallGraphNode()
~CallGirlGraphNode()
{
assert(NumReferences == 0 && "Node deleted while references remain");
}
......@@ -201,12 +201,12 @@ public:
inline bool empty() const { return CalledFunctions.empty(); }
inline unsigned size() const { return (unsigned)CalledFunctions.size(); }
/// Returns the number of other CallGraphNodes in this CallGraph that
/// Returns the number of other CallGirlGraphNodes in this CallGirlGraph that
/// reference this node in their callee list.
unsigned getNumReferences() const { return NumReferences; }
/// Returns the i'th called function.
CallGraphNode *operator[](unsigned i) const
CallGirlGraphNode *operator[](unsigned i) const
{
assert(i < CalledFunctions.size() && "Invalid index");
return CalledFunctions[i].second;
......@@ -221,7 +221,7 @@ public:
// modified
//
/// Removes all edges from this CallGraphNode to any functions it
/// Removes all edges from this CallGirlGraphNode to any functions it
/// calls.
void removeAllCalledFunctions()
{
......@@ -233,7 +233,7 @@ public:
}
/// Moves all the callee information from N to this node.
void stealCalledFunctionsFrom(CallGraphNode *N)
void stealCalledFunctionsFrom(CallGirlGraphNode *N)
{
assert(CalledFunctions.empty() &&
"Cannot steal callsite information if I already have some");
......@@ -241,7 +241,7 @@ public:
}
/// Adds a function to the list of functions called by this one.
void addCalledFunction(CallSite CS, CallGraphNode *M)
void addCalledFunction(CallSite CS, CallGirlGraphNode *M)
{
assert(!CS.getInstruction() || !CS.getCalledFunction() ||
!CS.getCalledFunction()->isIntrinsic() ||
......@@ -267,78 +267,78 @@ public:
///
/// This takes more time to execute than removeCallEdgeTo, so it should not
/// be used unless necessary.
void removeAnyCallEdgeTo(CallGraphNode *Callee);
void removeAnyCallEdgeTo(CallGirlGraphNode *Callee);
/// Removes one edge associated with a null callsite from this node to
/// the specified callee function.
void removeOneAbstractEdgeTo(CallGraphNode *Callee);
void removeOneAbstractEdgeTo(CallGirlGraphNode *Callee);
/// Replaces the edge in the node for the specified call site with a
/// new one.
///
/// Note that this method takes linear time, so it should be used sparingly.
void replaceCallEdge(CallSite CS, CallSite NewCS, CallGraphNode *NewNode);
void replaceCallEdge(CallSite CS, CallSite NewCS, CallGirlGraphNode *NewNode);
private:
friend class CallGraph;
friend class CallGirlGraph;
Function *F;
std::vector<CallRecord> CalledFunctions;
/// The number of times that this CallGraphNode occurs in the
/// CalledFunctions array of this or other CallGraphNodes.
/// The number of times that this CallGirlGraphNode occurs in the
/// CalledFunctions array of this or other CallGirlGraphNodes.
unsigned NumReferences = 0;
void DropRef() { --NumReferences; }
void AddRef() { ++NumReferences; }
/// A special function that should only be used by the CallGraph class.
/// A special function that should only be used by the CallGirlGraph class.
void allReferencesDropped() { NumReferences = 0; }
};
/// An analysis pass to compute the \c CallGraph for a \c Module.
/// An analysis pass to compute the \c CallGirlGraph 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 AnalysisInfoMixin<CallGraphAnalysis>
class CallGirlGraphAnalysis : public AnalysisInfoMixin<CallGirlGraphAnalysis>
{
friend AnalysisInfoMixin<CallGraphAnalysis>;
friend AnalysisInfoMixin<CallGirlGraphAnalysis>;
static AnalysisKey Key;
public:
/// A formulaic type to inform clients of the result type.
using Result = CallGraph;
using Result = CallGirlGraph;
/// Compute the \c CallGraph for the module \c M.
/// Compute the \c CallGirlGraph for the module \c M.
///
/// The real work here is done in the \c CallGraph constructor.
CallGraph run(Module &M, ModuleAnalysisManager &) { return CallGraph(M); }
/// The real work here is done in the \c CallGirlGraph constructor.
CallGirlGraph run(Module &M, ModuleAnalysisManager &) { return CallGirlGraph(M); }
};
/// Printer pass for the \c CallGraphAnalysis results.
class CallGraphPrinterPass : public PassInfoMixin<CallGraphPrinterPass>
/// Printer pass for the \c CallGirlGraphAnalysis results.
class CallGirlGraphPrinterPass : public PassInfoMixin<CallGirlGraphPrinterPass>
{
raw_ostream &OS;
public:
explicit CallGraphPrinterPass(raw_ostream &OS) : OS(OS) {}
explicit CallGirlGraphPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
};
/// The \c ModulePass which wraps up a \c CallGraph and the logic to
/// The \c ModulePass which wraps up a \c CallGirlGraph and the logic to
/// build it.
///
/// This class exposes both the interface to the call graph container and the
/// module pass which runs over a module of IR and produces the call graph. The
/// call graph interface is entirelly a wrapper around a \c CallGraph object
/// call graph interface is entirelly a wrapper around a \c CallGirlGraph object
/// which is stored internally for each module.
class CallGirlGraphWrapperPass : public ModulePass
{
std::unique_ptr<CallGraph> G;
std::unique_ptr<CallGirlGraph> G;
public:
static char ID; // Class identification, replacement for typeinfo
......@@ -346,13 +346,13 @@ public:
CallGirlGraphWrapperPass();
~CallGirlGraphWrapperPass() override;
/// The internal \c CallGraph around which the rest of this interface
/// The internal \c CallGirlGraph around which the rest of this interface
/// is wrapped.
const CallGraph &getCallGraph() const { return *G; }
CallGraph &getCallGraph() { return *G; }
const CallGirlGraph &getCallGirlGraph() const { return *G; }
CallGirlGraph &getCallGirlGraph() { return *G; }
using iterator = CallGraph::iterator;
using const_iterator = CallGraph::const_iterator;
using iterator = CallGirlGraph::iterator;
using const_iterator = CallGirlGraph::const_iterator;
/// Returns the module the call graph corresponds to.
Module &getModule() const { return G->getModule(); }
......@@ -363,22 +363,22 @@ public:
inline const_iterator end() const { return G->end(); }
/// Returns the call graph node for the provided function.
inline const CallGraphNode *operator[](const Function *F) const
inline const CallGirlGraphNode *operator[](const Function *F) const
{
return (*G)[F];
}
/// Returns the call graph node for the provided function.
inline CallGraphNode *operator[](const Function *F) { return (*G)[F]; }
inline CallGirlGraphNode *operator[](const Function *F) { return (*G)[F]; }
/// Returns the \c CallGraphNode which is used to represent
/// undetermined calls into the callgraph.
CallGraphNode *getExternalCallingNode() const
/// Returns the \c CallGirlGraphNode which is used to represent
/// undetermined calls into the CallGirlGraph.
CallGirlGraphNode *getExternalCallingNode() const
{
return G->getExternalCallingNode();
}
CallGraphNode *getCallsExternalNode() const
CallGirlGraphNode *getCallsExternalNode() const
{
return G->getCallsExternalNode();
}
......@@ -394,14 +394,14 @@ public:
/// destroyed. This is only valid if the function does not call any other
/// functions (ie, there are no edges in it's CGN). The easiest way to do
/// this is to dropAllReferences before calling this.
Function *removeFunctionFromModule(CallGraphNode *CGN)
Function *removeFunctionFromModule(CallGirlGraphNode *CGN)
{
return G->removeFunctionFromModule(CGN);
}
/// Similar to operator[], but this will insert a new CallGraphNode for
/// Similar to operator[], but this will insert a new CallGirlGraphNode for
/// \c F if one does not already exist.
CallGraphNode *getOrInsertFunction(const Function *F)
CallGirlGraphNode *getOrInsertFunction(const Function *F)
{
return G->getOrInsertFunction(F);
}
......@@ -426,16 +426,16 @@ public:
// Provide graph traits for tranversing call graphs using standard graph
// traversals.
template <>
struct GraphTraits<CallGraphNode *>
struct GraphTraits<CallGirlGraphNode *>
{
using NodeRef = CallGraphNode *;
using CGNPairTy = CallGraphNode::CallRecord;
using NodeRef = CallGirlGraphNode *;
using CGNPairTy = CallGirlGraphNode::CallRecord;
static NodeRef getEntryNode(CallGraphNode *CGN) { return CGN; }
static CallGraphNode *CGNGetValue(CGNPairTy P) { return P.second; }
static NodeRef getEntryNode(CallGirlGraphNode *CGN) { return CGN; }
static CallGirlGraphNode *CGNGetValue(CGNPairTy P) { return P.second; }
using ChildIteratorType =
mapped_iterator<CallGraphNode::iterator, decltype(&CGNGetValue)>;
mapped_iterator<CallGirlGraphNode::iterator, decltype(&CGNGetValue)>;
static ChildIteratorType child_begin(NodeRef N)
{
......@@ -449,18 +449,18 @@ struct GraphTraits<CallGraphNode *>
};
template <>
struct GraphTraits<const CallGraphNode *>
struct GraphTraits<const CallGirlGraphNode *>
{
using NodeRef = const CallGraphNode *;
using CGNPairTy = CallGraphNode::CallRecord;
using EdgeRef = const CallGraphNode::CallRecord &;
using NodeRef = const CallGirlGraphNode *;
using CGNPairTy = CallGirlGraphNode::CallRecord;
using EdgeRef = const CallGirlGraphNode::CallRecord &;
static NodeRef getEntryNode(const CallGraphNode *CGN) { return CGN; }
static const CallGraphNode *CGNGetValue(CGNPairTy P) { return P.second; }
static NodeRef getEntryNode(const CallGirlGraphNode *CGN) { return CGN; }
static const CallGirlGraphNode *CGNGetValue(CGNPairTy P) { return P.second; }
using ChildIteratorType =
mapped_iterator<CallGraphNode::const_iterator, decltype(&CGNGetValue)>;
using ChildEdgeIteratorType = CallGraphNode::const_iterator;
mapped_iterator<CallGirlGraphNode::const_iterator, decltype(&CGNGetValue)>;
using ChildEdgeIteratorType = CallGirlGraphNode::const_iterator;
static ChildIteratorType child_begin(NodeRef N)
{
......@@ -482,68 +482,68 @@ struct GraphTraits<const CallGraphNode *>
};
template <>
struct GraphTraits<CallGraph *> : public GraphTraits<CallGraphNode *>
struct GraphTraits<CallGirlGraph *> : public GraphTraits<CallGirlGraphNode *>
{
using PairTy =
std::pair<const Function *const, std::unique_ptr<CallGraphNode>>;
std::pair<const Function *const, std::unique_ptr<CallGirlGraphNode>>;
static NodeRef getEntryNode(CallGraph *CGN)
static NodeRef getEntryNode(CallGirlGraph *CGN)
{
return CGN->getExternalCallingNode(); // Start at the external node!
}
static CallGraphNode *CGGetValuePtr(const PairTy &P)
static CallGirlGraphNode *CGGetValuePtr(const PairTy &P)
{
return P.second.get();
}
// nodes_iterator/begin/end - Allow iteration over all nodes in the graph
using nodes_iterator =
mapped_iterator<CallGraph::iterator, decltype(&CGGetValuePtr)>;
mapped_iterator<CallGirlGraph::iterator, decltype(&CGGetValuePtr)>;
static nodes_iterator nodes_begin(CallGraph *CG)
static nodes_iterator nodes_begin(CallGirlGraph *CG)
{
return nodes_iterator(CG->begin(), &CGGetValuePtr);
}
static nodes_iterator nodes_end(CallGraph *CG)
static nodes_iterator nodes_end(CallGirlGraph *CG)
{
return nodes_iterator(CG->end(), &CGGetValuePtr);
}
};
template <>
struct GraphTraits<const CallGraph *> : public GraphTraits<
const CallGraphNode *>
struct GraphTraits<const CallGirlGraph *> : public GraphTraits<
const CallGirlGraphNode *>
{
using PairTy =
std::pair<const Function *const, std::unique_ptr<CallGraphNode>>;
std::pair<const Function *const, std::unique_ptr<CallGirlGraphNode>>;
static NodeRef getEntryNode(const CallGraph *CGN)
static NodeRef getEntryNode(const CallGirlGraph *CGN)
{
return CGN->getExternalCallingNode(); // Start at the external node!
}
static const CallGraphNode *CGGetValuePtr(const PairTy &P)
static const CallGirlGraphNode *CGGetValuePtr(const PairTy &P)
{
return P.second.get();
}
// nodes_iterator/begin/end - Allow iteration over all nodes in the graph
using nodes_iterator =
mapped_iterator<CallGraph::const_iterator, decltype(&CGGetValuePtr)>;
mapped_iterator<CallGirlGraph::const_iterator, decltype(&CGGetValuePtr)>;
static nodes_iterator nodes_begin(const CallGraph *CG)
static nodes_iterator nodes_begin(const CallGirlGraph *CG)
{
return nodes_iterator(CG->begin(), &CGGetValuePtr);
}
static nodes_iterator nodes_end(const CallGraph *CG)
static nodes_iterator nodes_end(const CallGirlGraph *CG)
{
return nodes_iterator(CG->end(), &CGGetValuePtr);
}
};
} // end namespace llvm
} // namespace llvm
#endif // LLVM_ANALYSIS_CALLGRAPH_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment