diff options
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/ELFWriter.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/MachOWriter.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/MachineFunction.cpp | 3 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 13 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 15 |
5 files changed, 17 insertions, 18 deletions
diff --git a/lib/CodeGen/ELFWriter.cpp b/lib/CodeGen/ELFWriter.cpp index 4f988070fd..3b9653740c 100644 --- a/lib/CodeGen/ELFWriter.cpp +++ b/lib/CodeGen/ELFWriter.cpp @@ -241,7 +241,7 @@ void ELFWriter::EmitGlobal(GlobalVariable *GV) { } const Type *GVType = (const Type*)GV->getType(); - unsigned Align = TM.getTargetData()->getTypeAlignment(GVType); + unsigned Align = TM.getTargetData()->getTypeAlignmentPref(GVType); unsigned Size = TM.getTargetData()->getTypeSize(GVType); // If this global has a zero initializer, it is part of the .bss or common diff --git a/lib/CodeGen/MachOWriter.cpp b/lib/CodeGen/MachOWriter.cpp index 64e11010b3..82dcf1861b 100644 --- a/lib/CodeGen/MachOWriter.cpp +++ b/lib/CodeGen/MachOWriter.cpp @@ -309,7 +309,7 @@ void MachOWriter::AddSymbolToSection(MachOSection *Sec, GlobalVariable *GV) { unsigned Size = TM.getTargetData()->getTypeSize(Ty); unsigned Align = GV->getAlignment(); if (Align == 0) - Align = TM.getTargetData()->getTypeAlignment(Ty); + Align = TM.getTargetData()->getTypeAlignmentPref(Ty); MachOSym Sym(GV, Mang->getValueName(GV), Sec->Index, TM); diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index d26b3258fe..0cba1567e1 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -123,7 +123,8 @@ MachineFunction::MachineFunction(const Function *F, const TargetData &TD = *TM.getTargetData(); bool IsPic = TM.getRelocationModel() == Reloc::PIC_; unsigned EntrySize = IsPic ? 4 : TD.getPointerSize(); - unsigned Alignment = IsPic ? TD.getIntAlignment() : TD.getPointerAlignment(); + unsigned Alignment = IsPic ? TD.getIntABIAlignment() + : TD.getPointerABIAlignment(); JumpTableInfo = new MachineJumpTableInfo(EntrySize, Alignment); BasicBlocks.Parent = this; diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index d83dcc4d50..c8804e907a 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -3029,7 +3029,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { // new ones, as reuse may inhibit scheduling. const Type *Ty = MVT::getTypeForValueType(ExtraVT); unsigned TySize = (unsigned)TLI.getTargetData()->getTypeSize(Ty); - unsigned Align = TLI.getTargetData()->getTypeAlignment(Ty); + unsigned Align = TLI.getTargetData()->getTypeAlignmentPref(Ty); MachineFunction &MF = DAG.getMachineFunction(); int SSFI = MF.getFrameInfo()->CreateStackObject((unsigned)TySize, Align); @@ -3937,7 +3937,9 @@ SDOperand SelectionDAGLegalize::ExpandBUILD_VECTOR(SDNode *Node) { SDOperand SelectionDAGLegalize::CreateStackTemporary(MVT::ValueType VT) { MachineFrameInfo *FrameInfo = DAG.getMachineFunction().getFrameInfo(); unsigned ByteSize = MVT::getSizeInBits(VT)/8; - int FrameIdx = FrameInfo->CreateStackObject(ByteSize, ByteSize); + const Type *Ty = MVT::getTypeForValueType(VT); + unsigned StackAlign = (unsigned)TLI.getTargetData()->getTypeAlignmentPref(Ty); + int FrameIdx = FrameInfo->CreateStackObject(ByteSize, StackAlign); return DAG.getFrameIndex(FrameIdx, TLI.getPointerTy()); } @@ -4242,9 +4244,12 @@ SDOperand SelectionDAGLegalize::ExpandLegalINT_TO_FP(bool isSigned, if (Op0.getValueType() == MVT::i32) { // simple 32-bit [signed|unsigned] integer to float/double expansion - // get the stack frame index of a 8 byte buffer + // get the stack frame index of a 8 byte buffer, pessimistically aligned MachineFunction &MF = DAG.getMachineFunction(); - int SSFI = MF.getFrameInfo()->CreateStackObject(8, 8); + const Type *F64Type = MVT::getTypeForValueType(MVT::f64); + unsigned StackAlign = + (unsigned)TLI.getTargetData()->getTypeAlignmentPref(F64Type); + int SSFI = MF.getFrameInfo()->CreateStackObject(8, StackAlign); // get address of 8 byte buffer SDOperand StackSlot = DAG.getFrameIndex(SSFI, TLI.getPointerTy()); // word offset constant for Hi/Lo address computation diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 7e6a75d772..e8d58453c2 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -244,17 +244,9 @@ FunctionLoweringInfo::FunctionLoweringInfo(TargetLowering &tli, const Type *Ty = AI->getAllocatedType(); uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty); unsigned Align = - std::max((unsigned)TLI.getTargetData()->getTypeAlignment(Ty), + std::max((unsigned)TLI.getTargetData()->getTypeAlignmentPref(Ty), AI->getAlignment()); - // If the alignment of the value is smaller than the size of the - // value, and if the size of the value is particularly small - // (<= 8 bytes), round up to the size of the value for potentially - // better performance. - // - // FIXME: This could be made better with a preferred alignment hook in - // TargetData. It serves primarily to 8-byte align doubles for X86. - if (Align < TySize && TySize <= 8) Align = TySize; TySize *= CUI->getZExtValue(); // Get total allocated size. if (TySize == 0) TySize = 1; // Don't create zero-sized stack objects. StaticAllocaMap[AI] = @@ -1729,8 +1721,9 @@ void SelectionDAGLowering::visitAlloca(AllocaInst &I) { const Type *Ty = I.getAllocatedType(); uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty); - unsigned Align = std::max((unsigned)TLI.getTargetData()->getTypeAlignment(Ty), - I.getAlignment()); + unsigned Align = + std::max((unsigned)TLI.getTargetData()->getTypeAlignmentPref(Ty), + I.getAlignment()); SDOperand AllocSize = getValue(I.getArraySize()); MVT::ValueType IntPtr = TLI.getPointerTy(); |