[poolalloc] r177652 - More formatting and commenting added to the local pass of DSA.

John Criswell criswell at uiuc.edu
Thu Mar 21 11:52:48 PDT 2013


Author: criswell
Date: Thu Mar 21 13:52:48 2013
New Revision: 177652

URL: http://llvm.org/viewvc/llvm-project?rev=177652&view=rev
Log:
More formatting and commenting added to the local pass of DSA.
No functionality changes.

Modified:
    poolalloc/branches/release_32/lib/DSA/Local.cpp

Modified: poolalloc/branches/release_32/lib/DSA/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/branches/release_32/lib/DSA/Local.cpp?rev=177652&r1=177651&r2=177652&view=diff
==============================================================================
--- poolalloc/branches/release_32/lib/DSA/Local.cpp (original)
+++ poolalloc/branches/release_32/lib/DSA/Local.cpp Thu Mar 21 13:52:48 2013
@@ -738,42 +738,51 @@ void GraphBuilder::visitGetElementPtrIns
       // increment the offset by the actual byte offset being accessed
 
       unsigned requiredSize = TD.getTypeAllocSize(STy) + NodeH.getOffset() + Offset;
-      if(!NodeH.getNode()->isArrayNode() || NodeH.getNode()->getSize() <= 0){
+
+      //
+      // Grow the DSNode size as needed.
+      //
+      if (!NodeH.getNode()->isArrayNode() || NodeH.getNode()->getSize() <= 0){
         if (requiredSize > NodeH.getNode()->getSize())
           NodeH.getNode()->growSize(requiredSize);
       }
+
       Offset += (unsigned)TD.getStructLayout(STy)->getElementOffset(FieldNo);
-      if(TypeInferenceOptimize) {
-        if(ArrayType* AT = dyn_cast<ArrayType>(STy->getTypeAtIndex(FieldNo))) {
+      if (TypeInferenceOptimize) {
+        if (ArrayType* AT = dyn_cast<ArrayType>(STy->getTypeAtIndex(FieldNo))) {
           NodeH.getNode()->mergeTypeInfo(AT, NodeH.getOffset() + Offset);
-          if((++I) == E) {
+          if ((++I) == E) {
             break;
           }
+
           // Check if we are still indexing into an array.
           // We only record the topmost array type of any nested array.
           // Keep skipping indexes till we reach a non-array type.
           // J is the type of the next index.
           // Uncomment the line below to get all the nested types.
           gep_type_iterator J = I;
-          while(isa<ArrayType>(*(++J))) {
+          while (isa<ArrayType>(*(++J))) {
             //      NodeH.getNode()->mergeTypeInfo(AT1, NodeH.getOffset() + Offset);
             if((++I) == E) {
               break;
             }
             J = I;
           }
-          if((I) == E) {
+          if ((I) == E) {
             break;
           }
         }
       }
-    } else if(ArrayType *ATy = dyn_cast<ArrayType>(*I)) {
+    } else if (ArrayType *ATy = dyn_cast<ArrayType>(*I)) {
       // indexing into an array.
       NodeH.getNode()->setArrayMarker();
       Type *CurTy = ATy->getElementType();
 
-      if(!isa<ArrayType>(CurTy) &&
-         NodeH.getNode()->getSize() <= 0) {
+      //
+      // Ensure that the DSNode's size is large enough to contain one
+      // element of the type to which the pointer points.
+      //
+      if (!isa<ArrayType>(CurTy) && NodeH.getNode()->getSize() <= 0) {
         NodeH.getNode()->growSize(TD.getTypeAllocSize(CurTy));
       } else if(isa<ArrayType>(CurTy) && NodeH.getNode()->getSize() <= 0){
         Type *ETy = (cast<ArrayType>(CurTy))->getElementType();





More information about the llvm-commits mailing list