[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Local.cpp

Sumant Kowshik kowshik at cs.uiuc.edu
Tue Dec 6 10:04:45 PST 2005



Changes in directory llvm/lib/Analysis/DataStructure:

Local.cpp updated: 1.134 -> 1.135
---
Log message:

Collapsing node if variable length struct with final field of length zero



---
Diffs of the changes:  (+18 -1)

 Local.cpp |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletion(-)


Index: llvm/lib/Analysis/DataStructure/Local.cpp
diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.134 llvm/lib/Analysis/DataStructure/Local.cpp:1.135
--- llvm/lib/Analysis/DataStructure/Local.cpp:1.134	Sat Jun 18 13:34:51 2005
+++ llvm/lib/Analysis/DataStructure/Local.cpp	Tue Dec  6 12:04:30 2005
@@ -434,7 +434,24 @@
   // 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);
 }
 






More information about the llvm-commits mailing list