diff options
author | Sumant Kowshik <kowshik@uiuc.edu> | 2005-12-06 18:04:30 +0000 |
---|---|---|
committer | Sumant Kowshik <kowshik@uiuc.edu> | 2005-12-06 18:04:30 +0000 |
commit | a69fcbdeb89d51cd67a739391022b8f9d2ac6474 (patch) | |
tree | 0c9ed4038a3a2df7d05f69d6511b3985319ca1ea /llvm/lib/Analysis/DataStructure | |
parent | 1473162af017f590746663a65ba1a842f70bb1ed (diff) | |
download | bcm5719-llvm-a69fcbdeb89d51cd67a739391022b8f9d2ac6474.tar.gz bcm5719-llvm-a69fcbdeb89d51cd67a739391022b8f9d2ac6474.zip |
Collapsing node if variable length struct with final field of length zero
llvm-svn: 24621
Diffstat (limited to 'llvm/lib/Analysis/DataStructure')
-rw-r--r-- | llvm/lib/Analysis/DataStructure/Local.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/DataStructure/Local.cpp b/llvm/lib/Analysis/DataStructure/Local.cpp index dfd34297f3f..75ad018c149 100644 --- a/llvm/lib/Analysis/DataStructure/Local.cpp +++ b/llvm/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); } |