From ca0ed744852a7d9625572fbb793f65e81225a3e8 Mon Sep 17 00:00:00 2001 From: Duncan Sands Date: Mon, 5 Nov 2007 00:04:43 +0000 Subject: Eliminate the remaining uses of getTypeSize. This should only effect x86 when using long double. Now 12/16 bytes are output for long double globals (the exact amount depends on the alignment). This brings globals in line with the rest of LLVM: the space reserved for an object is now always the ABI size. One tricky point is that only 10 bytes should be output for long double if it is a field in a packed struct, which is the reason for the additional argument to EmitGlobalConstant. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43688 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MachOWriter.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib/CodeGen/MachOWriter.cpp') diff --git a/lib/CodeGen/MachOWriter.cpp b/lib/CodeGen/MachOWriter.cpp index 0c743759da..9389088f20 100644 --- a/lib/CodeGen/MachOWriter.cpp +++ b/lib/CodeGen/MachOWriter.cpp @@ -259,7 +259,7 @@ void MachOCodeEmitter::emitConstantPool(MachineConstantPool *MCP) { // "giant object for PIC" optimization. for (unsigned i = 0, e = CP.size(); i != e; ++i) { const Type *Ty = CP[i].getType(); - unsigned Size = TM.getTargetData()->getTypeSize(Ty); + unsigned Size = TM.getTargetData()->getABITypeSize(Ty); MachOWriter::MachOSection *Sec = MOW.getConstSection(CP[i].Val.ConstVal); OutputBuffer SecDataOut(Sec->SectionData, is64Bit, isLittleEndian); @@ -333,7 +333,7 @@ MachOWriter::~MachOWriter() { void MachOWriter::AddSymbolToSection(MachOSection *Sec, GlobalVariable *GV) { const Type *Ty = GV->getType()->getElementType(); - unsigned Size = TM.getTargetData()->getTypeSize(Ty); + unsigned Size = TM.getTargetData()->getABITypeSize(Ty); unsigned Align = GV->getAlignment(); if (Align == 0) Align = TM.getTargetData()->getPrefTypeAlignment(Ty); @@ -380,7 +380,7 @@ void MachOWriter::AddSymbolToSection(MachOSection *Sec, GlobalVariable *GV) { void MachOWriter::EmitGlobal(GlobalVariable *GV) { const Type *Ty = GV->getType()->getElementType(); - unsigned Size = TM.getTargetData()->getTypeSize(Ty); + unsigned Size = TM.getTargetData()->getABITypeSize(Ty); bool NoInit = !GV->hasInitializer(); // If this global has a zero initializer, it is part of the .bss or common @@ -803,7 +803,8 @@ void MachOWriter::InitMem(const Constant *C, void *Addr, intptr_t Offset, if (isa(PC)) { continue; } else if (const ConstantVector *CP = dyn_cast(PC)) { - unsigned ElementSize = TD->getTypeSize(CP->getType()->getElementType()); + unsigned ElementSize = + TD->getABITypeSize(CP->getType()->getElementType()); for (unsigned i = 0, e = CP->getNumOperands(); i != e; ++i) WorkList.push_back(CPair(CP->getOperand(i), PA+i*ElementSize)); } else if (const ConstantExpr *CE = dyn_cast(PC)) { @@ -904,9 +905,10 @@ void MachOWriter::InitMem(const Constant *C, void *Addr, intptr_t Offset, abort(); } } else if (isa(PC)) { - memset((void*)PA, 0, (size_t)TD->getTypeSize(PC->getType())); + memset((void*)PA, 0, (size_t)TD->getABITypeSize(PC->getType())); } else if (const ConstantArray *CPA = dyn_cast(PC)) { - unsigned ElementSize = TD->getTypeSize(CPA->getType()->getElementType()); + unsigned ElementSize = + TD->getABITypeSize(CPA->getType()->getElementType()); for (unsigned i = 0, e = CPA->getNumOperands(); i != e; ++i) WorkList.push_back(CPair(CPA->getOperand(i), PA+i*ElementSize)); } else if (const ConstantStruct *CPS = dyn_cast(PC)) { -- cgit v1.2.3