From 0408f6805c164f317937e97d7bc222781164bfeb Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Thu, 29 May 2008 10:58:49 +0000 Subject: Always use packed structs. This isn't really very nice, but there's nothing fundamentally wrong with it. Emitting unpacked structs where possible is more work for almost no practical benefit. We'll probably want to fix it at some point anyway, but it's low priority. The issue with long double in particular is that LLVM thinks an X86 long double is 10 bytes, while clang considers it for all purposes to be either 12 or 16 bytes, depending on the platform, even in a packed struct. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51673 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenTypes.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'lib/CodeGen/CodeGenTypes.cpp') diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index 5efde77a7d..ec4f6df2b4 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -482,14 +482,13 @@ void RecordOrganizer::layoutStructFields(const ASTRecordLayout &RL) { // FIXME : Use SmallVector uint64_t llvmSize = 0; std::vector LLVMFields; - bool packedStruct = false; int NumMembers = RD.getNumMembers(); for (int curField = 0; curField < NumMembers; curField++) { const FieldDecl *FD = RD.getMember(curField); uint64_t offset = RL.getFieldOffset(curField); const llvm::Type *Ty = CGT.ConvertTypeRecursive(FD->getType()); - uint64_t size = CGT.getTargetData().getABITypeSize(Ty) * 8; + uint64_t size = CGT.getTargetData().getTypeStoreSizeInBits(Ty); if (FD->isBitField()) { Expr *BitWidth = FD->getBitWidth(); @@ -513,12 +512,6 @@ void RecordOrganizer::layoutStructFields(const ASTRecordLayout &RL) { llvmSize += 8; } - unsigned Align = CGT.getTargetData().getABITypeAlignment(Ty) * 8; - if (llvmSize % Align) - packedStruct = true; - else if (offset == 0 && RL.getAlignment() % Align) - packedStruct = true; - llvmSize += size; CGT.addFieldInfo(FD, LLVMFields.size()); LLVMFields.push_back(Ty); @@ -530,7 +523,7 @@ void RecordOrganizer::layoutStructFields(const ASTRecordLayout &RL) { llvmSize += 8; } - STy = llvm::StructType::get(LLVMFields, packedStruct); + STy = llvm::StructType::get(LLVMFields, true); assert(CGT.getTargetData().getABITypeSizeInBits(STy) == RL.getSize()); } -- cgit v1.2.3