#include <ostream>
using namespace llvm;
+/// isOnlyADirectCall - Return true if this callsite is *just* a direct call to
+/// the specified function. Specifically return false if the callsite also
+/// takes the address of the function.
static bool isOnlyADirectCall(Function *F, CallSite CS) {
if (!CS.getInstruction()) return false;
for (CallSite::arg_iterator I = CS.arg_begin(), E = CS.arg_end(); I != E; ++I)
public:
BasicCallGraph() : Root(0), ExternalCallingNode(0), CallsExternalNode(0) {}
- ~BasicCallGraph() { destroy(); }
// runOnModule - Compute the call graph for the specified module.
virtual bool runOnModule(Module &M) {
- destroy();
CallGraph::initialize(M);
ExternalCallingNode = getOrInsertFunction(0);
AU.setPreservesAll();
}
- void print(llvm_ostream &o, const Module *M) const {
- if (o.stream()) print(*o.stream(), M);
+ void print(std::ostream *o, const Module *M) const {
+ if (o) print(*o, M);
}
virtual void print(std::ostream &o, const Module *M) const {
/// dump - Print out this call graph.
///
inline void dump() const {
- print(llvm_cerr, Mod);
+ print(cerr, Mod);
}
CallGraphNode* getExternalCallingNode() const { return ExternalCallingNode; }
//
// destroy - Release memory for the call graph
virtual void destroy() {
- if (!CallsExternalNode) {
- delete CallsExternalNode;
- CallsExternalNode = 0;
- }
+ /// CallsExternalNode is not in the function map, delete it explicitly.
+ delete CallsExternalNode;
+ CallsExternalNode = 0;
+ CallGraph::destroy();
}
};
} //End anonymous namespace
void CallGraph::initialize(Module &M) {
- destroy();
Mod = &M;
}
}
void CallGraph::dump() const {
- print(llvm_cerr, 0);
+ print(cerr, 0);
}
//===----------------------------------------------------------------------===//
OS << "\n";
}
-void CallGraphNode::dump() const { print(llvm_cerr); }
+void CallGraphNode::dump() const { print(cerr); }
void CallGraphNode::removeCallEdgeTo(CallGraphNode *Callee) {
for (unsigned i = CalledFunctions.size(); ; --i) {