#define LLVM_ANALYSIS_DATA_STRUCTURE_H
#include "llvm/Pass.h"
-#include "Support/HashExtras.h"
#include "Support/hash_set"
class Type;
+class CallInst;
class DSGraph;
class DSNode;
class DSCallSite;
//
class LocalDataStructures : public Pass {
// DSInfo, one graph for each function
- hash_map<const Function*, DSGraph*> DSInfo;
+ hash_map<Function*, DSGraph*> DSInfo;
DSGraph *GlobalsGraph;
public:
~LocalDataStructures() { releaseMemory(); }
virtual bool run(Module &M);
bool hasGraph(const Function &F) const {
- return DSInfo.find(&F) != DSInfo.end();
+ return DSInfo.find(const_cast<Function*>(&F)) != DSInfo.end();
}
// getDSGraph - Return the data structure graph for the specified function.
DSGraph &getDSGraph(const Function &F) const {
- hash_map<const Function*, DSGraph*>::const_iterator I = DSInfo.find(&F);
+ hash_map<Function*, DSGraph*>::const_iterator I =
+ DSInfo.find(const_cast<Function*>(&F));
assert(I != DSInfo.end() && "Function not in module!");
return *I->second;
}
//
class BUDataStructures : public Pass {
// DSInfo, one graph for each function
- hash_map<const Function*, DSGraph*> DSInfo;
+ hash_map<Function*, DSGraph*> DSInfo;
DSGraph *GlobalsGraph;
+ hash_multimap<CallInst*, Function*> ActualCallees;
public:
~BUDataStructures() { releaseMemory(); }
virtual bool run(Module &M);
bool hasGraph(const Function &F) const {
- return DSInfo.find(&F) != DSInfo.end();
+ return DSInfo.find(const_cast<Function*>(&F)) != DSInfo.end();
}
// getDSGraph - Return the data structure graph for the specified function.
DSGraph &getDSGraph(const Function &F) const {
- hash_map<const Function*, DSGraph*>::const_iterator I = DSInfo.find(&F);
+ hash_map<Function*, DSGraph*>::const_iterator I =
+ DSInfo.find(const_cast<Function*>(&F));
assert(I != DSInfo.end() && "Function not in module!");
return *I->second;
}
AU.setPreservesAll();
AU.addRequired<LocalDataStructures>();
}
+
+ typedef hash_multimap<CallInst*, Function*> ActualCalleesTy;
+ const ActualCalleesTy &getActualCallees() const {
+ return ActualCallees;
+ }
+
private:
- DSGraph &calculateGraph(Function &F);
+ void calculateGraph(DSGraph &G);
- // inlineNonSCCGraphs - This method is almost like the other two calculate
- // graph methods. This one is used to inline function graphs (from functions
- // outside of the SCC) into functions in the SCC. It is not supposed to touch
- // functions IN the SCC at all.
- //
- DSGraph &inlineNonSCCGraphs(Function &F,
- hash_set<Function*> &SCCFunctions);
-
- DSGraph &calculateSCCGraph(Function &F,
- hash_set<Function*> &InlinedSCCFunctions);
void calculateReachableGraphs(Function *F);
//
class TDDataStructures : public Pass {
// DSInfo, one graph for each function
- hash_map<const Function*, DSGraph*> DSInfo;
- hash_set<const Function*> GraphDone;
+ hash_map<Function*, DSGraph*> DSInfo;
+ hash_set<Function*> ArgsRemainIncomplete;
DSGraph *GlobalsGraph;
public:
~TDDataStructures() { releaseMyMemory(); }
virtual bool run(Module &M);
bool hasGraph(const Function &F) const {
- return DSInfo.find(&F) != DSInfo.end();
+ return DSInfo.find(const_cast<Function*>(&F)) != DSInfo.end();
}
// getDSGraph - Return the data structure graph for the specified function.
DSGraph &getDSGraph(const Function &F) const {
- hash_map<const Function*, DSGraph*>::const_iterator I = DSInfo.find(&F);
+ hash_map<Function*, DSGraph*>::const_iterator I =
+ DSInfo.find(const_cast<Function*>(&F));
assert(I != DSInfo.end() && "Function not in module!");
return *I->second;
}
}
private:
- void calculateGraph(Function &F);
+ void inlineGraphIntoCallees(DSGraph &G);
DSGraph &getOrCreateDSGraph(Function &F);
-
- void ResolveCallSite(DSGraph &Graph, const DSCallSite &CallSite);
+ void ComputePostOrder(Function &F, hash_set<DSGraph*> &Visited,
+ std::vector<DSGraph*> &PostOrder,
+ const BUDataStructures::ActualCalleesTy &ActualCallees);
};
#endif