aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/DataStructure/Local.cpp
diff options
context:
space:
mode:
authorSumant Kowshik <kowshik@uiuc.edu>2005-12-06 18:04:30 +0000
committerSumant Kowshik <kowshik@uiuc.edu>2005-12-06 18:04:30 +0000
commit8a3802d5b2c366c1470695c183da87920748a27d (patch)
tree2ea8cff6b8fa10ecb7f96006920b185732b32055 /lib/Analysis/DataStructure/Local.cpp
parent14d1d22f370e47653d8f7e3f3ab4a409d24f878b (diff)
Collapsing node if variable length struct with final field of length zero
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24621 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/Local.cpp')
-rw-r--r--lib/Analysis/DataStructure/Local.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp
index dfd34297f3..75ad018c14 100644
--- a/lib/Analysis/DataStructure/Local.cpp
+++ b/lib/Analysis/DataStructure/Local.cpp
@@ -434,7 +434,24 @@ void GraphBuilder::visitGetElementPtrInst(User &GEP) {
// Add in the offset calculated...
Value.setOffset(Value.getOffset()+Offset);
- // Value is now the pointer we want to GEP to be...
+ // Check the offset
+ DSNode *N = Value.getNode();
+ if (N &&
+ !N->isNodeCompletelyFolded() &&
+ (N->getSize() != 0 || Offset != 0) &&
+ !N->isForwarding()) {
+ if ((Offset >= N->getSize()) || int(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
+
+ // Collapse the node since its size is now variable
+ N->foldNodeCompletely();
+ }
+ }
+
+ // Value is now the pointer we want to GEP to be...
setDestTo(GEP, Value);
}