[llvm-commits] [poolalloc] r131867 - in /poolalloc/trunk: include/assistDS/Devirt.h include/dsa/CallTargets.h lib/AssistDS/Devirt.cpp lib/DSA/CallTargets.cpp
Arushi Aggarwal
aggarwa4 at illinois.edu
Sun May 22 14:18:24 PDT 2011
Author: aggarwa4
Date: Sun May 22 16:18:23 2011
New Revision: 131867
URL: http://llvm.org/viewvc/llvm-project?rev=131867&view=rev
Log:
Make calltargets templated on the DSA type.
Modified:
poolalloc/trunk/include/assistDS/Devirt.h
poolalloc/trunk/include/dsa/CallTargets.h
poolalloc/trunk/lib/AssistDS/Devirt.cpp
poolalloc/trunk/lib/DSA/CallTargets.cpp
Modified: poolalloc/trunk/include/assistDS/Devirt.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/Devirt.h?rev=131867&r1=131866&r2=131867&view=diff
==============================================================================
--- poolalloc/trunk/include/assistDS/Devirt.h (original)
+++ poolalloc/trunk/include/assistDS/Devirt.h Sun May 22 16:18:23 2011
@@ -38,7 +38,7 @@
class Devirtualize : public ModulePass, public InstVisitor<Devirtualize> {
private:
// Access to analysis pass which finds targets of indirect function calls
- CallTargetFinder* CTF;
+ dsa::CallTargetFinder<EQTDDataStructures> *CTF;
// Access to the target data analysis pass
TargetData * TD;
@@ -62,7 +62,7 @@
virtual bool runOnModule(Module & M);
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
- AU.addRequired<CallTargetFinder>();
+ AU.addRequired<dsa::CallTargetFinder<EQTDDataStructures> >();
AU.addRequired<TargetData>();
}
Modified: poolalloc/trunk/include/dsa/CallTargets.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/CallTargets.h?rev=131867&r1=131866&r2=131867&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/CallTargets.h (original)
+++ poolalloc/trunk/include/dsa/CallTargets.h Sun May 22 16:18:23 2011
@@ -17,13 +17,16 @@
#include "llvm/Pass.h"
#include "llvm/Support/CallSite.h"
+#include "dsa/DataStructure.h"
#include <set>
#include <list>
#include <map>
-namespace llvm {
+using namespace llvm;
+namespace dsa{
+ template<class dsa>
class CallTargetFinder : public ModulePass {
std::map<CallSite, std::vector<const Function*> > IndMap;
std::set<CallSite> CompleteSites;
Modified: poolalloc/trunk/lib/AssistDS/Devirt.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/Devirt.cpp?rev=131867&r1=131866&r2=131867&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/Devirt.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/Devirt.cpp Sun May 22 16:18:23 2011
@@ -395,7 +395,7 @@
//
// Get the targets of indirect function calls.
//
- CTF = &getAnalysis<CallTargetFinder>();
+ CTF = &getAnalysis<dsa::CallTargetFinder<EQTDDataStructures> >();
//
// Get information on the target system.
Modified: poolalloc/trunk/lib/DSA/CallTargets.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/CallTargets.cpp?rev=131867&r1=131866&r2=131867&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/CallTargets.cpp (original)
+++ poolalloc/trunk/lib/DSA/CallTargets.cpp Sun May 22 16:18:23 2011
@@ -29,20 +29,23 @@
#include <ostream>
using namespace llvm;
+RegisterPass<dsa::CallTargetFinder<EQTDDataStructures> > X("calltarget","Find Call Targets (uses DSA)");
namespace {
STATISTIC (DirCall, "Number of direct calls");
STATISTIC (IndCall, "Number of indirect calls");
STATISTIC (CompleteInd, "Number of complete indirect calls");
STATISTIC (CompleteEmpty, "Number of complete empty calls");
- RegisterPass<CallTargetFinder> X("calltarget","Find Call Targets (uses DSA)");
}
-char CallTargetFinder::ID = 0;
+namespace dsa {
+ template<typename dsa>
+char CallTargetFinder<dsa>::ID = 0;
-void CallTargetFinder::findIndTargets(Module &M)
+ template<class dsa>
+void CallTargetFinder<dsa>::findIndTargets(Module &M)
{
- EQTDDataStructures* T = &getAnalysis<EQTDDataStructures>();
+ dsa* T = &getAnalysis<dsa>();
const DSCallGraph & callgraph = T->getCallGraph();
DSGraph* G = T->getGlobalsGraph();
DSGraph::ScalarMapTy& SM = G->getScalarMap();
@@ -122,7 +125,8 @@
}
}
-void CallTargetFinder::print(llvm::raw_ostream &O, const Module *M) const
+ template<class dsa>
+void CallTargetFinder<dsa>::print(llvm::raw_ostream &O, const Module *M) const
{
O << "[* = incomplete] CS: func list\n";
for (std::map<CallSite, std::vector<const Function*> >::const_iterator ii =
@@ -149,12 +153,15 @@
}
}
-bool CallTargetFinder::runOnModule(Module &M) {
+ template<class dsa>
+bool CallTargetFinder<dsa>::runOnModule(Module &M) {
findIndTargets(M);
return false;
}
-void CallTargetFinder::getAnalysisUsage(AnalysisUsage &AU) const {
+ template<class dsa>
+void CallTargetFinder<dsa>::getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
- AU.addRequired<EQTDDataStructures>();
+ AU.addRequired<dsa>();
+}
}
More information about the llvm-commits
mailing list