[llvm-commits] [poolalloc] r96979 - in /poolalloc/trunk: include/dsa/DSNode.h lib/DSA/Basic.cpp lib/DSA/DataStructure.cpp lib/DSA/Makefile lib/DSA/Printer.cpp lib/PoolAllocate/Makefile
alenhar2 at llvm.org
alenhar2 at llvm.org
Tue Feb 23 12:50:55 PST 2010
Author: alenhar2
Date: Tue Feb 23 14:50:55 2010
New Revision: 96979
URL: http://llvm.org/viewvc/llvm-project?rev=96979&view=rev
Log:
get rid of getGlobalContext and simplify ilist by using generic impl
Modified:
poolalloc/trunk/include/dsa/DSNode.h
poolalloc/trunk/lib/DSA/Basic.cpp
poolalloc/trunk/lib/DSA/DataStructure.cpp
poolalloc/trunk/lib/DSA/Makefile
poolalloc/trunk/lib/DSA/Printer.cpp
poolalloc/trunk/lib/PoolAllocate/Makefile
Modified: poolalloc/trunk/include/dsa/DSNode.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSNode.h?rev=96979&r1=96978&r2=96979&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/DSNode.h (original)
+++ poolalloc/trunk/include/dsa/DSNode.h Tue Feb 23 14:50:55 2010
@@ -15,6 +15,7 @@
#define LLVM_ANALYSIS_DSNODE_H
#include "dsa/DSSupport.h"
+#include "llvm/ADT/ilist_node.h"
#include "llvm/Support/Streams.h"
#include "poolalloc/ADT/HashExtras.h"
@@ -31,7 +32,11 @@
/// track of any pointers that have been stored into the object as well as the
/// different types represented in this object.
///
-class DSNode {
+class DSNode : public ilist_node<DSNode> {
+ friend struct ilist_sentinel_traits<DSNode>;
+ //Sentinel
+ DSNode() : NumReferrers(0), Size(0), Ty(0) {}
+
/// NumReferrers - The number of DSNodeHandles pointing to this node... if
/// this is a forwarding node, then this is the number of node handles which
/// are still forwarding over us.
@@ -48,8 +53,8 @@
/// Next, Prev - These instance variables are used to keep the node on a
/// doubly-linked ilist in the DSGraph.
///
- DSNode *Next, *Prev;
- friend struct ilist_traits<DSNode>;
+ //DSNode *Next, *Prev;
+ //friend struct ilist_traits<DSNode>;
/// Size - The current size of the node. This should be equal to the size of
/// the current type record.
@@ -400,54 +405,6 @@
};
//===----------------------------------------------------------------------===//
-// Define the ilist_traits specialization for the DSGraph ilist.
-//
-template<>
-struct ilist_traits<DSNode> {
- static DSNode *getPrev(const DSNode *N) { return N->Prev; }
- static DSNode *getNext(const DSNode *N) { return N->Next; }
-
- static void deleteNode(llvm::DSNode *V) { delete V; }
- static void setPrev(DSNode *N, DSNode *Prev) { N->Prev = Prev; }
- static void setNext(DSNode *N, DSNode *Next) { N->Next = Next; }
-
- static DSNode *createSentinel() { return new DSNode(0,0); }
- static void destroySentinel(DSNode *N) { delete N; }
-
- void addNodeToList(DSNode *NTy) {}
- void removeNodeFromList(DSNode *NTy) {}
- void transferNodesFromList(iplist<DSNode, ilist_traits> &L2,
- ilist_iterator<DSNode> first,
- ilist_iterator<DSNode> last) {}
- DSNode *provideInitialHead() const {
- DSNode * sentinel = createSentinel();
- setPrev (sentinel, sentinel);
- return sentinel;
- }
-
- /// ensureHead - make sure that Head is either already
- /// initialized or assigned a fresh sentinel
- /// @return the sentinel
- static DSNode *ensureHead(DSNode *&Head) {
- if (!Head) {
- Head = createSentinel();
- noteHead (Head, Head);
- setNext(Head, Head);
- return Head;
- }
- return getPrev(Head);
- }
-
- /// noteHead - stash the sentinel into its default location
- static void noteHead(DSNode *NewHead, DSNode *Sentinel) {
- setPrev(NewHead, Sentinel);
- }
-};
-
-template<>
-struct ilist_traits<const DSNode> : public ilist_traits<DSNode> {};
-
-//===----------------------------------------------------------------------===//
// Define inline DSNodeHandle functions that depend on the definition of DSNode
//
inline DSNode *DSNodeHandle::getNode() const {
Modified: poolalloc/trunk/lib/DSA/Basic.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Basic.cpp?rev=96979&r1=96978&r2=96979&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Basic.cpp (original)
+++ poolalloc/trunk/lib/DSA/Basic.cpp Tue Feb 23 14:50:55 2010
@@ -38,7 +38,7 @@
//
// Create a void pointer type. This is simply a pointer to an 8 bit value.
//
- const IntegerType * IT = IntegerType::getInt8Ty(getGlobalContext());
+ const IntegerType * IT = IntegerType::getInt8Ty(M.getContext());
const PointerType * VoidPtrTy = PointerType::getUnqual(IT);
DSNode * GVNodeInternal = new DSNode(VoidPtrTy, GlobalsGraph);
Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=96979&r1=96978&r2=96979&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructure.cpp (original)
+++ poolalloc/trunk/lib/DSA/DataStructure.cpp Tue Feb 23 14:50:55 2010
@@ -122,7 +122,7 @@
//===----------------------------------------------------------------------===//
DSNode::DSNode(const Type *T, DSGraph *G)
- : NumReferrers(0), Size(0), ParentGraph(G), Ty(Type::getVoidTy(getGlobalContext())), NodeType(0) {
+: NumReferrers(0), Size(0), ParentGraph(G), Ty(0) {
// Add the type entry if it is specified...
if (T) mergeTypeInfo(T, 0);
if (G) G->addNode(this);
@@ -164,10 +164,9 @@
}
void DSNode::assertOK() const {
- const Type * VoidType = Type::getVoidTy(getGlobalContext());
- assert((Ty != VoidType ||
- (Ty == VoidType && (Size == 0 ||
- (NodeType & DSNode::ArrayNode)))) &&
+ assert(((Ty && Ty->getTypeID() != Type::VoidTyID) ||
+ ((!Ty || Ty->getTypeID() == Type::VoidTyID) && (Size == 0 ||
+ (NodeType & DSNode::ArrayNode)))) &&
"Node not OK!");
assert(ParentGraph && "Node has no parent?");
@@ -190,7 +189,7 @@
ForwardNH.setTo(To, Offset);
NodeType = DeadNode;
Size = 0;
- Ty = Type::getVoidTy(getGlobalContext());
+ Ty = 0;
// Remove this node from the parent graph's Nodes list.
ParentGraph->unlinkNode(this);
@@ -238,7 +237,7 @@
// node.
if (getSize() <= 1) {
NodeType |= DSNode::ArrayNode;
- Ty = Type::getVoidTy(getGlobalContext());
+ Ty = 0;
Size = 1;
assert(Links.size() <= 1 && "Size is 1, but has more links?");
Links.resize(1);
@@ -248,7 +247,7 @@
// forward, the forwarder has the opportunity to correct the offset.
DSNode *DestNode = new DSNode(0, ParentGraph);
DestNode->NodeType = NodeType|DSNode::ArrayNode;
- DestNode->Ty = Type::getVoidTy(getGlobalContext());
+ DestNode->Ty = 0;
DestNode->Size = 1;
DestNode->Globals.swap(Globals);
@@ -290,8 +289,8 @@
/// all of the field sensitivity that may be present in the node.
///
bool DSNode::isNodeCompletelyFolded() const {
- const Type * VoidType = Type::getVoidTy(getGlobalContext());
- return getSize() == 1 && Ty == VoidType && isArray();
+ return getSize() == 1 && (!Ty || Ty->getTypeID() == Type::VoidTyID)
+ && isArray();
}
/// addFullGlobalsList - Compute the full set of global values that are
@@ -490,7 +489,7 @@
//
// Create an array type that fits the padding size.
//
- const Type * Int8Type = IntegerType::getInt8Ty(getGlobalContext());
+ const Type * Int8Type = IntegerType::getInt8Ty(SubType->getContext());
const Type * paddingType = ArrayType::get (Int8Type, nextOffset-thisOffset);
//
@@ -499,7 +498,7 @@
std::vector<const Type *> elementTypes;
elementTypes.push_back (SubType);
elementTypes.push_back (paddingType);
- return (StructType::get (getGlobalContext(), elementTypes, true));
+ return (StructType::get (SubType->getContext(), elementTypes, true));
} else {
return SubType;
}
@@ -516,6 +515,8 @@
bool DSNode::mergeTypeInfo(const Type *NewTy, unsigned Offset,
bool FoldIfIncompatible) {
//DOUT << "merging " << *NewTy << " at " << Offset << " with " << *Ty << "\n";
+ if (!Ty) Ty = Type::getVoidTy(NewTy->getContext());
+
const TargetData &TD = getTargetData();
// Check to make sure the Size member is up-to-date. Size can be one of the
// following:
@@ -524,7 +525,7 @@
// Size = 1, Ty = Void, Array = 1: The node is collapsed
// Otherwise, sizeof(Ty) = Size
//
- const Type * VoidType = Type::getVoidTy(getGlobalContext());
+ const Type * VoidType = Type::getVoidTy(NewTy->getContext());
assert(((Size == 0 && Ty == VoidType && !isArray()) ||
(Size == 0 && !Ty->isSized() && !isArray()) ||
(Size == 1 && Ty == VoidType && isArray()) ||
@@ -945,8 +946,7 @@
}
#endif
// Merge the type entries of the two nodes together...
- const Type * VoidType = Type::getVoidTy(getGlobalContext());
- if (NH.getNode()->Ty != VoidType)
+ if (NH.getNode()->Ty && NH.getNode()->Ty->getTypeID() != Type::VoidTyID)
CurNodeH.getNode()->mergeTypeInfo(NH.getNode()->Ty, NOffset);
assert(!CurNodeH.getNode()->isDeadNode());
@@ -1206,9 +1206,9 @@
}
// Merge the type entries of the two nodes together...
- const Type * VoidType = Type::getVoidTy(getGlobalContext());
- if (SN->getType() != VoidType && !DN->isNodeCompletelyFolded()) {
- DN->mergeTypeInfo(SN->getType(), NH.getOffset()-SrcNH.getOffset());
+ if ((SN->getType() || SN->getType()->getTypeID() != Type::VoidTyID)
+ && !DN->isNodeCompletelyFolded()) {
+ DN->mergeTypeInfo(SN->getType(), NH.getOffset() - SrcNH.getOffset());
DN = NH.getNode();
}
}
@@ -2033,12 +2033,12 @@
}
static inline void killIfUselessEdge(DSNodeHandle &Edge) {
- const Type * VoidType = Type::getVoidTy(getGlobalContext());
- if (DSNode *N = Edge.getNode()) // Is there an edge?
+ if (DSNode * N = Edge.getNode()) // Is there an edge?
if (N->getNumReferrers() == 1) // Does it point to a lonely node?
// No interesting info?
if ((N->getNodeFlags() & ~DSNode::IncompleteNode) == 0 &&
- N->getType() == VoidType && !N->isNodeCompletelyFolded())
+ (!N->getType() || N->getType()->getTypeID() == Type::VoidTyID)
+ && !N->isNodeCompletelyFolded())
Edge.setTo(0, 0); // Kill the edge!
}
Modified: poolalloc/trunk/lib/DSA/Makefile
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Makefile?rev=96979&r1=96978&r2=96979&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Makefile (original)
+++ poolalloc/trunk/lib/DSA/Makefile Tue Feb 23 14:50:55 2010
@@ -8,9 +8,10 @@
##===----------------------------------------------------------------------===##
LEVEL = ../..
-BUILD_RELINKED=1
-SHARED_LIBRARY=1
LIBRARYNAME = LLVMDataStructure
+BUILD_ARCHIVE := 1
+SHARED_LIBRARY := 1
+#LOADABLE_MODULE := 1
include $(LEVEL)/Makefile.common
Modified: poolalloc/trunk/lib/DSA/Printer.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Printer.cpp?rev=96979&r1=96978&r2=96979&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Printer.cpp (original)
+++ poolalloc/trunk/lib/DSA/Printer.cpp Tue Feb 23 14:50:55 2010
@@ -63,7 +63,10 @@
if (N->isNodeCompletelyFolded())
OS << "COLLAPSED";
else {
- WriteTypeSymbolic(OS, N->getType(), M);
+ if (N->getType())
+ WriteTypeSymbolic(OS, N->getType(), M);
+ else
+ OS << "VOID";
if (N->isArray())
OS << " array";
}
Modified: poolalloc/trunk/lib/PoolAllocate/Makefile
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/Makefile?rev=96979&r1=96978&r2=96979&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/Makefile (original)
+++ poolalloc/trunk/lib/PoolAllocate/Makefile Tue Feb 23 14:50:55 2010
@@ -6,15 +6,13 @@
#
# Give the name of a library. This will build a dynamic version.
#
-BUILD_RELINKED=1
-SHARED_LIBRARY=1
LIBRARYNAME=poolalloc
+BUILD_ARCHIVE := 1
+SHARED_LIBRARY := 1
+#LOADABLE_MODULE := 1
#
# Include Makefile.common so we know what to do.
#
include $(LEVEL)/Makefile.common
-LDFLAGS += -lLLVMDataStructure
-CFLAGS += -fPIC
-
More information about the llvm-commits
mailing list