[llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp PoolAllocate.h TransformFunctionBody.cpp
Andrew Lenharth
alenhar2 at cs.uiuc.edu
Mon Jun 19 07:55:40 PDT 2006
Changes in directory llvm-poolalloc/lib/PoolAllocate:
PoolAllocate.cpp updated: 1.123 -> 1.124
PoolAllocate.h updated: 1.49 -> 1.50
TransformFunctionBody.cpp updated: 1.52 -> 1.53
---
Log message:
add an option to use the td graph to resolve unresolved call sites. Also always check the BU DSNode for info if the callgraph fails us.
---
Diffs of the changes: (+49 -5)
PoolAllocate.cpp | 11 +++++++++++
PoolAllocate.h | 2 ++
TransformFunctionBody.cpp | 41 ++++++++++++++++++++++++++++++++++++-----
3 files changed, 49 insertions(+), 5 deletions(-)
Index: llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp
diff -u llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.123 llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.124
--- llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.123 Wed Jan 25 16:07:36 2006
+++ llvm-poolalloc/lib/PoolAllocate/PoolAllocate.cpp Mon Jun 19 09:55:28 2006
@@ -26,6 +26,7 @@
#include "llvm/Target/TargetData.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Cloning.h"
+#include "llvm/Analysis/DataStructure/CallTargets.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/STLExtras.h"
@@ -76,6 +77,10 @@
cl::opt<bool>
DisablePoolFreeOpt("poolalloc-force-all-poolfrees",
cl::desc("Do not try to elide poolfree's where possible"));
+
+ cl::opt<bool>
+ UseTDResolve("poolalloc-usetd-resolve",
+ cl::desc("Use Top-Down Graph as a resolve source"));
}
void PoolAllocate::getAnalysisUsage(AnalysisUsage &AU) const {
@@ -93,6 +98,8 @@
AU.setPreservesAll();
#endif
AU.addRequired<TargetData>();
+ if (UseTDResolve)
+ AU.addRequired<CallTargetFinder>();
}
bool PoolAllocate::runOnModule(Module &M) {
@@ -102,6 +109,10 @@
#endif
CurModule = &M;
ECGraphs = &getAnalysis<EquivClassGraphs>(); // folded inlined CBU graphs
+ if (UseTDResolve)
+ CTF = &getAnalysis<CallTargetFinder>();
+ else
+ CTF = 0;
CurHeuristic = Heuristic::create();
CurHeuristic->Initialize(M, ECGraphs->getGlobalsGraph(), *this);
Index: llvm-poolalloc/lib/PoolAllocate/PoolAllocate.h
diff -u llvm-poolalloc/lib/PoolAllocate/PoolAllocate.h:1.49 llvm-poolalloc/lib/PoolAllocate/PoolAllocate.h:1.50
--- llvm-poolalloc/lib/PoolAllocate/PoolAllocate.h:1.49 Wed Jun 14 16:17:32 2006
+++ llvm-poolalloc/lib/PoolAllocate/PoolAllocate.h Mon Jun 19 09:55:28 2006
@@ -43,6 +43,7 @@
class Type;
class AllocaInst;
class EquivClassGraphs;
+class CallTargetFinder;
namespace PA {
@@ -122,6 +123,7 @@
Module *CurModule;
EquivClassGraphs *ECGraphs;
+ CallTargetFinder* CTF;
std::map<Function*, PA::FuncInfo> FunctionInfo;
std::map<Function*, Function*> CloneToOrigMap;
Index: llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp
diff -u llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.52 llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.53
--- llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.52 Thu Apr 13 09:07:35 2006
+++ llvm-poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp Mon Jun 19 09:55:28 2006
@@ -15,6 +15,7 @@
#include "PoolAllocate.h"
#include "llvm/Analysis/DataStructure/DataStructure.h"
#include "llvm/Analysis/DataStructure/DSGraph.h"
+#include "llvm/Analysis/DataStructure/CallTargets.h"
#include "llvm/Module.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Constants.h"
@@ -34,6 +35,7 @@
PoolAllocate &PAInfo;
DSGraph &G; // The Bottom-up DS Graph
FuncInfo &FI;
+ CallTargetFinder* CTF;
// PoolUses - For each pool (identified by the pool descriptor) keep track
// of which blocks require the memory in the pool to not be freed. This
@@ -47,8 +49,9 @@
FuncTransform(PoolAllocate &P, DSGraph &g, FuncInfo &fi,
std::multimap<AllocaInst*, Instruction*> &poolUses,
- std::multimap<AllocaInst*, CallInst*> &poolFrees)
- : PAInfo(P), G(g), FI(fi),
+ std::multimap<AllocaInst*, CallInst*> &poolFrees,
+ CallTargetFinder* ctf)
+ : PAInfo(P), G(g), FI(fi), CTF(ctf),
PoolUses(poolUses), PoolFrees(poolFrees) {
}
@@ -115,7 +118,7 @@
std::multimap<AllocaInst*,Instruction*> &poolUses,
std::multimap<AllocaInst*, CallInst*> &poolFrees,
Function &F) {
- FuncTransform(*this, g, fi, poolUses, poolFrees).visit(F);
+ FuncTransform(*this, g, fi, poolUses, poolFrees, CTF).visit(F);
}
@@ -519,11 +522,39 @@
CF = I->second;
break;
}
-
+
+ // If we didn't find the callee in the constructed call graph, try
+ // checking in the DSNode itself.
+ // This isn't ideal as it means that this call site didn't have inlining
+ // happen.
+ if (!CF) {
+ DSGraph* dg = &ECGraphs.getDSGraph(*OrigInst->getParent()->getParent());
+ DSNode* d = dg->getNodeForValue(OrigInst->getOperand(0)).getNode();
+ const std::vector<GlobalValue*> &g = d->getGlobalsList();
+ for(std::vector<GlobalValue*>::const_iterator ii = g.begin(), ee = g.end();
+ !CF && ii != ee; ++ii) {
+ EquivalenceClasses< GlobalValue *> & EC = ECGraphs.getGlobalECs();
+ for (EquivalenceClasses<GlobalValue *>::member_iterator MI = EC.findLeader(*ii);
+ MI != EC.member_end(); ++MI) // Loop over members in this set.
+ if ((CF = dyn_cast<Function>(*MI))) {
+ std::cerr << "\n***\nPA: *** WARNING (FuncTransform::visitCallSite): "
+ << "Using DSNode for callees for call-site in function "
+ << CS.getCaller()->getName() << "\n***\n";
+ break;
+ }
+ }
+ }
+
+ if (!CF && CTF) {
+ std::cerr << "\nPA: Last Resort TD Indirect Resolve in " << CS.getCaller()->getName() << "\n";
+ CF = *CTF->begin(isa<CallInst>(OrigInst)?CallSite(cast<CallInst>(OrigInst))
+ :CallSite(cast<InvokeInst>(OrigInst)));
+ if (CF) std::cerr << "TD resolved to " << CF->getName() << "\n";
+ }
if (!CF) {
// FIXME: Unknown callees for a call-site. Warn and ignore.
- std::cerr << "\n***\n*** WARNING (FuncTransform::visitCallSite): "
+ std::cerr << "\n***\nPA: *** WARNING (FuncTransform::visitCallSite): "
<< "Unknown callees for call-site in function "
<< CS.getCaller()->getName() << "\n***\n";
return;
More information about the llvm-commits
mailing list