[llvm-commits] [poolalloc] r159498 - in /poolalloc/trunk: include/dsa/DSNode.h lib/DSA/DataStructure.cpp lib/DSA/Local.cpp
Will Dietz
wdietz2 at illinois.edu
Sat Jun 30 16:04:50 PDT 2012
Author: wdietz2
Date: Sat Jun 30 18:04:50 2012
New Revision: 159498
URL: http://llvm.org/viewvc/llvm-project?rev=159498&view=rev
Log:
Refactor OOB Offset folding and use in BU as well.
Takes the check that was touched up in r159480, and re-use it elsewhere
so we also fold (instead of assert failing) when cloning results in trying
to point to an offset beyond a node's size.
Fixes BU on 483.xalancbmk.
Modified:
poolalloc/trunk/include/dsa/DSNode.h
poolalloc/trunk/lib/DSA/DataStructure.cpp
poolalloc/trunk/lib/DSA/Local.cpp
Modified: poolalloc/trunk/include/dsa/DSNode.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSNode.h?rev=159498&r1=159497&r2=159498&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/DSNode.h (original)
+++ poolalloc/trunk/include/dsa/DSNode.h Sat Jun 30 18:04:50 2012
@@ -441,6 +441,10 @@
///
void markReachableNodes(llvm::DenseSet<const DSNode*> &ReachableNodes) const;
+
+ /// checkOffsetFoldIfNeeded - Fold DSNode if the specified offset is
+ /// larger than its size, and the node isn't an array or forwarding.
+ void checkOffsetFoldIfNeeded(int Offset);
private:
friend class DSNodeHandle;
Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=159498&r1=159497&r2=159498&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructure.cpp (original)
+++ poolalloc/trunk/lib/DSA/DataStructure.cpp Sat Jun 30 18:04:50 2012
@@ -39,6 +39,7 @@
#define COLLAPSE_ARRAYS_AGGRESSIVELY 0
namespace {
STATISTIC (NumFolds, "Number of nodes completely folded");
+ STATISTIC (NumFoldsOOBOffset, "Number of OOB offsets that caused node folding");
STATISTIC (NumNodeAllocated , "Number of nodes allocated");
}
@@ -722,6 +723,25 @@
}
}
+void DSNode::checkOffsetFoldIfNeeded(int Offset) {
+ if (!isNodeCompletelyFolded() &&
+ (Size != 0 || Offset != 0) &&
+ !isForwarding()) {
+ if ((Offset >= (int)Size) || Offset < 0) {
+ // Accessing offsets out of node size range
+ // This is seen in the "magic" struct in named (from bind), where the
+ // fourth field is an array of length 0, presumably used to create struct
+ // instances of different sizes
+ // More generally this happens whenever code indexes past the end
+ // of a struct type. We don't model this, so fold!
+
+ // Collapse the node since its size is now variable
+ foldNodeCompletely();
+
+ ++NumFoldsOOBOffset;
+ }
+ }
+}
//===----------------------------------------------------------------------===//
// ReachabilityCloner Implementation
//===----------------------------------------------------------------------===//
@@ -733,7 +753,12 @@
DSNodeHandle &NH = NodeMap[SN];
if (!NH.isNull()) { // Node already mapped?
DSNode *NHN = NH.getNode();
- return DSNodeHandle(NHN, NH.getOffset() + SrcNH.getOffset());
+ unsigned NewOffset = NH.getOffset() + SrcNH.getOffset();
+ if (NHN) {
+ NHN->checkOffsetFoldIfNeeded(NewOffset);
+ NHN = NH.getNode();
+ }
+ return DSNodeHandle(NHN, NewOffset);
}
// If SrcNH has globals and the destination graph has one of the same globals,
@@ -749,7 +774,12 @@
merge(GI->second, Src->getNodeForValue(GV));
assert(!NH.isNull() && "Didn't merge node!");
DSNode *NHN = NH.getNode();
- return DSNodeHandle(NHN, NH.getOffset()+SrcNH.getOffset());
+ unsigned NewOffset = NH.getOffset() + SrcNH.getOffset();
+ if (NHN) {
+ NHN->checkOffsetFoldIfNeeded(NewOffset);
+ NHN = NH.getNode();
+ }
+ return DSNodeHandle(NHN, NewOffset);
}
}
}
@@ -797,7 +827,13 @@
}
NH.getNode()->mergeGlobals(*SN);
- return DSNodeHandle(NH.getNode(), NH.getOffset()+SrcNH.getOffset());
+ DSNode* NHN = NH.getNode();
+ unsigned NewOffset = NH.getOffset() + SrcNH.getOffset();
+ if (NHN) {
+ NHN->checkOffsetFoldIfNeeded(NewOffset);
+ NHN = NH.getNode();
+ }
+ return DSNodeHandle(NHN, NewOffset);
}
void ReachabilityCloner::merge(const DSNodeHandle &NH,
Modified: poolalloc/trunk/lib/DSA/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=159498&r1=159497&r2=159498&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Local.cpp (original)
+++ poolalloc/trunk/lib/DSA/Local.cpp Sat Jun 30 18:04:50 2012
@@ -804,23 +804,9 @@
// Check the offset
DSNode *N = Value.getNode();
- Offset = Value.getOffset();
- if (N &&
- !N->isNodeCompletelyFolded() &&
- (N->getSize() != 0 || Offset != 0) &&
- !N->isForwarding()) {
- if ((Offset >= (int)N->getSize()) || Offset < 0) {
- // Accessing offsets out of node size range
- // This is seen in the "magic" struct in named (from bind), where the
- // fourth field is an array of length 0, presumably used to create struct
- // instances of different sizes
+ if (N) N->checkOffsetFoldIfNeeded(Value.getOffset());
- // Collapse the node since its size is now variable
- N->foldNodeCompletely();
- }
- }
-
- // Value is now the pointer we want to GEP to be...
+ // Value is now the pointer we want to GEP to be...
setDestTo(GEP, Value);
}
More information about the llvm-commits
mailing list