[llvm-commits] [poolalloc] r98063 - in /poolalloc/trunk: include/poolalloc/PoolAllocate.h lib/PoolAllocate/Heuristic.cpp lib/PoolAllocate/PointerCompress.cpp lib/PoolAllocate/PoolAllocate.cpp lib/PoolAllocate/RunTimeAssociate.cpp lib/PoolAllocate/TransformFunctionBody.cpp
alenhar2 at llvm.org
alenhar2 at llvm.org
Tue Mar 9 08:50:15 PST 2010
Author: alenhar2
Date: Tue Mar 9 10:50:15 2010
New Revision: 98063
URL: http://llvm.org/viewvc/llvm-project?rev=98063&view=rev
Log:
Keep poolalloc compiling, but it is broken.
The FIXME for the dsa type changes need to be dealt with
The malloc/free situation needs to be dealt with.
Modified:
poolalloc/trunk/include/poolalloc/PoolAllocate.h
poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp
poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp
poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
poolalloc/trunk/lib/PoolAllocate/RunTimeAssociate.cpp
poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/PoolAllocate.h?rev=98063&r1=98062&r2=98063&view=diff
==============================================================================
--- poolalloc/trunk/include/poolalloc/PoolAllocate.h (original)
+++ poolalloc/trunk/include/poolalloc/PoolAllocate.h Tue Mar 9 10:50:15 2010
@@ -31,7 +31,6 @@
#include "dsa/DataStructure.h"
#include "poolalloc/Config/config.h"
-#include <set>
#include <utility>
namespace llvm {
@@ -59,7 +58,7 @@
/// MarkedNodes - The set of nodes which are not locally pool allocatable in
/// the current function.
///
- std::set<const DSNode*> MarkedNodes;
+ DenseSet<const DSNode*> MarkedNodes;
/// F - The function this FuncInfo corresponds to.
///
Modified: poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp?rev=98063&r1=98062&r2=98063&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp Tue Mar 9 10:50:15 2010
@@ -57,9 +57,10 @@
unsigned Heuristic::getRecommendedSize(const DSNode *N) {
unsigned PoolSize = 0;
- if (!N->isArray() && N->getType()->isSized()) {
- PoolSize = N->getParentGraph()->getTargetData().getTypeAllocSize(N->getType());
- }
+ //FIXME: types
+// if (!N->isArray() && N->getType()->isSized()) {
+// PoolSize = N->getParentGraph()->getTargetData().getTypeAllocSize(N->getType());
+// }
if (PoolSize == 1) PoolSize = 0;
return PoolSize;
}
@@ -121,14 +122,15 @@
/// DSNode.
///
unsigned Heuristic::getRecommendedAlignment(const DSNode *N) {
- if (!N->getType() || N->getType()->isVoidTy()) // Is this void or collapsed?
+ //FIXME: Type
+ //if (!N->getType() || N->getType()->isVoidTy()) // Is this void or collapsed?
return 0; // No known alignment, let runtime decide.
- const TargetData &TD = N->getParentGraph()->getTargetData();
+ //const TargetData &TD = N->getParentGraph()->getTargetData();
// If there are no doubles on an 8-byte boundary in this structure, there is
// no reason to 8-byte align objects in the pool.
- return Wants8ByteAlignment(N->getType(), 0, TD) ? 8 : 4;
+ //return Wants8ByteAlignment(N->getType(), 0, TD) ? 8 : 4;
}
@@ -231,7 +233,7 @@
if (F == 0) {
for (unsigned i = 0, e = NodesToPA.size(); i != e; ++i) {
const DSNode *Node = NodesToPA[i];
- if ((Node->isNodeCompletelyFolded() || !Node->isArray()) &&
+ if ((Node->isNodeCompletelyFolded() || !Node->isArrayNode()) &&
NodeExistsInCycle(Node))
ResultPools.push_back(OnePool(Node));
}
Modified: poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp?rev=98063&r1=98062&r2=98063&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp Tue Mar 9 10:50:15 2010
@@ -228,10 +228,13 @@
const TargetData &TD) {
// First step, compute the type of the compressed node. This basically
// replaces all pointers to compressed pools with uints.
- NewTy = ComputeCompressedType(Pool->getType(), 0, Nodes);
+//FIXME: TYPE
+ // NewTy = ComputeCompressedType(Pool->getType(), 0, Nodes);
+ NewTy = 0;
// Get the compressed type size.
- NewSize = NewTy->isSized() ? TD.getTypeAllocSize(NewTy) : 0;
+ //NewSize = NewTy->isSized() ? TD.getTypeAllocSize(NewTy) : 0;
+ NewSize = 0;
}
@@ -320,14 +323,15 @@
/// dump - Emit a debugging dump for this pool info.
///
void CompressedPoolInfo::dump() const {
- const TargetData &TD = getNode()->getParentGraph()->getTargetData();
- errs() << " From size: "
- << (getNode()->getType()->isSized() ?
- TD.getTypeAllocSize(getNode()->getType()) : 0)
- << " To size: "
- << (NewTy->isSized() ? TD.getTypeAllocSize(NewTy) : 0) << "\n";
- errs() << "Node: "; getNode()->dump();
- errs() << "New Type: " << *NewTy << "\n";
+// const TargetData &TD = getNode()->getParentGraph()->getTargetData();
+//FIXME: type
+ //errs() << " From size: "
+// << (getNode()->getType()->isSized() ?
+// TD.getTypeAllocSize(getNode()->getType()) : 0)
+// << " To size: "
+// << (NewTy->isSized() ? TD.getTypeAllocSize(NewTy) : 0) << "\n";
+// errs() << "Node: "; getNode()->dump();
+// errs() << "New Type: " << *NewTy << "\n";
}
@@ -704,9 +708,10 @@
const Type* PT =
cast<PointerType>(GEPI.getOperand(0)->getType())->getElementType();
if(isa<ArrayType>(PT)) {
- if (cast<ArrayType>(PT)->getElementType() == PI->getNode()->getType())
- NTy = PointerType::getUnqual(ArrayType::get(PI->getNewType(),
- cast<ArrayType>(PT)->getNumElements()));
+ //FIXME: TYPE
+// if (cast<ArrayType>(PT)->getElementType() == PI->getNode()->getType())
+// NTy = PointerType::getUnqual(ArrayType::get(PI->getNewType(),
+// cast<ArrayType>(PT)->getNumElements()));
}
}
Modified: poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp?rev=98063&r1=98062&r2=98063&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Tue Mar 9 10:50:15 2010
@@ -349,13 +349,13 @@
static void GetNodesReachableFromGlobals(DSGraph* G,
- std::set<const DSNode*> &NodesFromGlobals) {
+ DenseSet<const DSNode*> &NodesFromGlobals) {
for (DSScalarMap::global_iterator I = G->getScalarMap().global_begin(),
E = G->getScalarMap().global_end(); I != E; ++I)
G->getNodeForValue(*I).getNode()->markReachableNodes(NodesFromGlobals);
}
-static void MarkNodesWhichMustBePassedIn(std::set<const DSNode*> &MarkedNodes,
+static void MarkNodesWhichMustBePassedIn(DenseSet<const DSNode*> &MarkedNodes,
Function &F, DSGraph* G,
bool PassAllArguments) {
// Mark globals and incomplete nodes as live... (this handles arguments)
@@ -377,16 +377,16 @@
// Calculate which DSNodes are reachable from globals. If a node is reachable
// from a global, we will create a global pool for it, so no argument passage
// is required.
- std::set<const DSNode*> NodesFromGlobals;
+ DenseSet<const DSNode*> NodesFromGlobals;
GetNodesReachableFromGlobals(G, NodesFromGlobals);
// Remove any nodes reachable from a global. These nodes will be put into
// global pools, which do not require arguments to be passed in. Also, erase
// any marked node that is not a heap node. Since no allocations or frees
// will be done with it, it needs no argument.
- for (std::set<const DSNode*>::iterator I = MarkedNodes.begin(),
+ for (DenseSet<const DSNode*>::iterator I = MarkedNodes.begin(),
E = MarkedNodes.end(); I != E; ) {
- const DSNode *N = *I++;
+ const DSNode *N = *I; ++I;
if ((!(1 || N->isHeapNode()) && !PassAllArguments) || NodesFromGlobals.count(N))
MarkedNodes.erase(N);
}
@@ -402,7 +402,7 @@
// Create a new entry for F.
FuncInfo &FI =
FunctionInfo.insert(std::make_pair(&F, FuncInfo(F))).first->second;
- std::set<const DSNode*> &MarkedNodes = FI.MarkedNodes;
+ DenseSet<const DSNode*> &MarkedNodes = FI.MarkedNodes;
if (G->node_begin() == G->node_end())
return; // No memory activity, nothing is required
@@ -411,8 +411,13 @@
// current function. This set will contain all of the DSNodes which require
// pools to be passed in from outside of the function.
MarkNodesWhichMustBePassedIn(MarkedNodes, F, G, PassAllArguments);
-
- FI.ArgNodes.insert(FI.ArgNodes.end(), MarkedNodes.begin(), MarkedNodes.end());
+
+
+ //FI.ArgNodes.insert(FI.ArgNodes.end(), MarkedNodes.begin(), MarkedNodes.end());
+ //Work around DenseSet not having iterator traits
+ for (DenseSet<const DSNode*>::iterator ii = MarkedNodes.begin(),
+ ee = MarkedNodes.end(); ii != ee; ++ii)
+ FI.ArgNodes.insert(FI.ArgNodes.end(), *ii);
}
// MakeFunctionClone - If the specified function needs to be modified for pool
@@ -527,13 +532,13 @@
DSGraph* GG = Graphs->getGlobalsGraph();
// Get all of the nodes reachable from globals.
- std::set<const DSNode*> GlobalHeapNodes;
+ DenseSet<const DSNode*> GlobalHeapNodes;
GetNodesReachableFromGlobals(GG, GlobalHeapNodes);
// Filter out all nodes which have no heap allocations merged into them.
- for (std::set<const DSNode*>::iterator I = GlobalHeapNodes.begin(),
+ for (DenseSet<const DSNode*>::iterator I = GlobalHeapNodes.begin(),
E = GlobalHeapNodes.end(); I != E; ) {
- std::set<const DSNode*>::iterator Last = I++;
+ DenseSet<const DSNode*>::iterator Last = I; ++I;
#if 0
//
@@ -547,10 +552,11 @@
}
#endif
+ //FIXME: erase on a densemap invalidates all iterators
const DSNode *tmp = *Last;
// errs() << "test \n";
- if (!(tmp->isHeapNode() || tmp->isArray()))
- GlobalHeapNodes.erase(Last);
+ if (!(tmp->isHeapNode() || tmp->isArrayNode()))
+ GlobalHeapNodes.erase(tmp);
}
// Otherwise get the main function to insert the poolinit calls.
@@ -565,8 +571,14 @@
<< " global nodes!\n";
- std::vector<const DSNode*> NodesToPA(GlobalHeapNodes.begin(),
- GlobalHeapNodes.end());
+ //std::vector<const DSNode*> NodesToPA(GlobalHeapNodes.begin(),
+ // GlobalHeapNodes.end());
+ //DenseSet Doesn't have polite iterators
+ std::vector<const DSNode*> NodesToPA;
+ for (DenseSet<const DSNode*>::iterator ii = GlobalHeapNodes.begin(),
+ ee = GlobalHeapNodes.end(); ii != ee; ++ii)
+ NodesToPA.push_back(*ii);
+
std::vector<Heuristic::OnePool> ResultPools;
CurHeuristic->AssignToPools(NodesToPA, 0, GG, ResultPools);
@@ -590,7 +602,7 @@
}
// Any unallocated DSNodes get null pool descriptor pointers.
- for (std::set<const DSNode*>::iterator I = GlobalHeapNodes.begin(),
+ for (DenseSet<const DSNode*>::iterator I = GlobalHeapNodes.begin(),
E = GlobalHeapNodes.end(); I != E; ++I) {
GlobalNodes[*I] = ConstantPointerNull::get(PointerType::getUnqual(PoolDescType));
++NumNonprofit;
@@ -704,7 +716,7 @@
if (G->node_begin() == G->node_end()) return; // Quick exit if nothing to do.
FuncInfo &FI = *getFuncInfo(F);
- std::set<const DSNode*> &MarkedNodes = FI.MarkedNodes;
+ DenseSet<const DSNode*> &MarkedNodes = FI.MarkedNodes;
// Calculate which DSNodes are reachable from globals. If a node is reachable
// from a global, we will create a global pool for it, so no argument passage
@@ -721,7 +733,7 @@
for (DSGraph::node_iterator I = G->node_begin(), E = G->node_end(); I != E;++I){
// We only need to make a pool if there is a heap object in it...
DSNode *N = I;
- if ((N->isHeapNode()) || (BoundsChecksEnabled && (N->isArray()))) {
+ if ((N->isHeapNode()) || (BoundsChecksEnabled && (N->isArrayNode()))) {
if (GlobalsGraphNodeMapping.count(N)) {
// If it is a global pool, set up the pool descriptor appropriately.
DSNode *GGN = GlobalsGraphNodeMapping[N].getNode();
Modified: poolalloc/trunk/lib/PoolAllocate/RunTimeAssociate.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/RunTimeAssociate.cpp?rev=98063&r1=98062&r2=98063&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/RunTimeAssociate.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/RunTimeAssociate.cpp Tue Mar 9 10:50:15 2010
@@ -56,13 +56,13 @@
////////////////////////////////////////////////////////////////////////////////
static void GetNodesReachableFromGlobals(DSGraph* G,
- std::set<const DSNode*> &NodesFromGlobals) {
+ DenseSet<const DSNode*> &NodesFromGlobals) {
for (DSScalarMap::global_iterator I = G->getScalarMap().global_begin(),
E = G->getScalarMap().global_end(); I != E; ++I)
G->getNodeForValue(*I).getNode()->markReachableNodes(NodesFromGlobals);
}
-static void MarkNodesWhichMustBePassedIn(std::set<const DSNode*> &MarkedNodes,
+static void MarkNodesWhichMustBePassedIn(DenseSet<const DSNode*> &MarkedNodes,
Function &F, DSGraph* G,
EntryPointAnalysis* EPA) {
// All DSNodes reachable from arguments must be passed in...
@@ -84,13 +84,13 @@
// Calculate which DSNodes are reachable from globals. If a node is reachable
// from a global, we will create a global pool for it, so no argument passage
// is required.
- std::set<const DSNode*> NodesFromGlobals;
+ DenseSet<const DSNode*> NodesFromGlobals;
GetNodesReachableFromGlobals(G, NodesFromGlobals);
// Remove any nodes reachable from a global. These nodes will be put into
// global pools, which do not require arguments to be passed in.
- for (std::set<const DSNode*>::iterator I = NodesFromGlobals.begin(),
+ for (DenseSet<const DSNode*>::iterator I = NodesFromGlobals.begin(),
E = NodesFromGlobals.end(); I != E; ++I)
MarkedNodes.erase(*I);
}
@@ -101,7 +101,7 @@
/// map and recording this info in the ArgNodes set.
static void FindFunctionPoolArgs(Function &F, FuncInfo& FI,
EntryPointAnalysis* EPA) {
- std::set<const DSNode*> MarkedNodes;
+ DenseSet<const DSNode*> MarkedNodes;
if (FI.G->node_begin() == FI.G->node_end())
return; // No memory activity, nothing is required
@@ -111,13 +111,15 @@
// pools to be passed in from outside of the function.
MarkNodesWhichMustBePassedIn(MarkedNodes, F, FI.G,EPA);
- FI.ArgNodes.insert(FI.ArgNodes.end(), MarkedNodes.begin(), MarkedNodes.end());
+ //FI.ArgNodes.insert(FI.ArgNodes.end(), MarkedNodes.begin(), MarkedNodes.end());
+ //Work around DenseSet not having iterator traits
+ for (DenseSet<const DSNode*>::iterator ii = MarkedNodes.begin(),
+ ee = MarkedNodes.end(); ii != ee; ++ii)
+ FI.ArgNodes.insert(FI.ArgNodes.end(), *ii);
}
-
-
////////////////////////////////////////////////////////////////////////////////
// RTAssociate
////////////////////////////////////////////////////////////////////////////////
@@ -286,7 +288,7 @@
// DSGraph* GG = Graphs->getGlobalsGraph();
// Get all of the nodes reachable from globals.
- std::set<const DSNode*> GlobalHeapNodes;
+ DenseSet<const DSNode*> GlobalHeapNodes;
GetNodesReachableFromGlobals(GG, GlobalHeapNodes);
errs() << "Pool allocating " << GlobalHeapNodes.size()
Modified: poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp?rev=98063&r1=98062&r2=98063&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Tue Mar 9 10:50:15 2010
@@ -271,7 +271,7 @@
// Get the pool handle for the node that this contributes to...
DSNode *Node = getDSNodeHFor(&MI).getNode();
- if (Node->isArray()) {
+ if (Node->isArrayNode()) {
Value *PH = getPoolHandle(&MI);
if (PH == 0 || isa<ConstantPointerNull>(PH)) return;
TargetData &TD = PAInfo.getAnalysis<TargetData>();
@@ -751,7 +751,7 @@
if (FI.PoolDescriptors.count(LocalNode))
ArgVal = FI.PoolDescriptors.find(LocalNode)->second;
if (isa<Constant>(ArgVal) && cast<Constant>(ArgVal)->isNullValue()) {
- if ((!(PAInfo.BoundsChecksEnabled)) || (ArgNodes[i]->isArray())) {
+ if ((!(PAInfo.BoundsChecksEnabled)) || (ArgNodes[i]->isArrayNode())) {
if (!isa<InvokeInst>(TheCall)) {
// Dinakar: We need pooldescriptors for allocas in the callee if it
// escapes
More information about the llvm-commits
mailing list