diff options
| author | Chris Lattner <sabre@nondot.org> | 2003-05-21 18:08:44 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2003-05-21 18:08:44 +0000 |
| commit | 6532e427b40faaa97a5ab1a6322224dd765b4728 (patch) | |
| tree | f6c331e067d849521532cb9400b77fa45a9adccf /llvm/lib/Target | |
| parent | 2a651d7a0e4a5bb263d05eaf0145a0938df5f509 (diff) | |
| download | bcm5719-llvm-6532e427b40faaa97a5ab1a6322224dd765b4728.tar.gz bcm5719-llvm-6532e427b40faaa97a5ab1a6322224dd765b4728.zip | |
* Fix divide by zero error with empty structs
* Empty structs should have ALIGNMENT 1, not SIZE 1.
llvm-svn: 6263
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/TargetData.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/llvm/lib/Target/TargetData.cpp b/llvm/lib/Target/TargetData.cpp index 158f57e3acc..1c6f9d1aa31 100644 --- a/llvm/lib/Target/TargetData.cpp +++ b/llvm/lib/Target/TargetData.cpp @@ -56,15 +56,13 @@ StructLayout::StructLayout(const StructType *ST, const TargetData &TD) 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, |

