summaryrefslogtreecommitdiff
path: root/lib/Target/TargetData.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-05-21 18:08:44 +0000
committerChris Lattner <sabre@nondot.org>2003-05-21 18:08:44 +0000
commit4e840d4db71faebb52f5e94ca2a8d1c00ecef09b (patch)
tree2a98ceef1bbc8165abdec3a627b4f939d449b1f5 /lib/Target/TargetData.cpp
parent77c9fcb797ca391b355fbead8f35942805e5be94 (diff)
downloadllvm-4e840d4db71faebb52f5e94ca2a8d1c00ecef09b.tar.gz
llvm-4e840d4db71faebb52f5e94ca2a8d1c00ecef09b.tar.bz2
llvm-4e840d4db71faebb52f5e94ca2a8d1c00ecef09b.tar.xz
* Fix divide by zero error with empty structs
* Empty structs should have ALIGNMENT 1, not SIZE 1. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6263 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/TargetData.cpp')
-rw-r--r--lib/Target/TargetData.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp
index 158f57e3ac..1c6f9d1aa3 100644
--- a/lib/Target/TargetData.cpp
+++ b/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,