[llvm-commits] CVS: llvm/lib/Target/TargetData.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed May 21 13:09:01 PDT 2003


Changes in directory llvm/lib/Target:

TargetData.cpp updated: 1.31 -> 1.32

---
Log message:

* Fix divide by zero error with empty structs
* Empty structs should have ALIGNMENT 1, not SIZE 1.



---
Diffs of the changes:

Index: llvm/lib/Target/TargetData.cpp
diff -u llvm/lib/Target/TargetData.cpp:1.31 llvm/lib/Target/TargetData.cpp:1.32
--- llvm/lib/Target/TargetData.cpp:1.31	Sat Apr 26 15:10:58 2003
+++ llvm/lib/Target/TargetData.cpp	Wed May 21 13:08:44 2003
@@ -56,15 +56,13 @@
     StructSize += TySize;                 // Consume space for this data item
   }
 
+  // Empty structures have alignment of 1 byte.
+  if (StructAlignment == 0) StructAlignment = 1;
+
   // Add padding to the end of the struct so that it could be put in an array
   // and all array elements would be aligned correctly.
   if (StructSize % StructAlignment != 0)
     StructSize = (StructSize/StructAlignment + 1) * StructAlignment;
-
-  if (StructSize == 0) {
-    StructSize = 1;           // Empty struct is 1 byte
-    StructAlignment = 1;
-  }
 }
 
 Annotation *TargetData::TypeAnFactory(AnnotationID AID, const Annotable *T,





More information about the llvm-commits mailing list