diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/Target/TargetData.cpp | 25 | ||||
-rw-r--r-- | llvm/lib/Target/X86/X86Subtarget.h | 2 |
3 files changed, 25 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index d512ef9b1d1..e18beb5018a 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -3870,7 +3870,8 @@ TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG) { Flags |= ISD::ParamFlags::ByVal; const PointerType *Ty = cast<PointerType>(I->getType()); const StructType *STy = cast<StructType>(Ty->getElementType()); - unsigned StructAlign = Log2_32(getTargetData()->getABITypeAlignment(STy)); + unsigned StructAlign = + Log2_32(getTargetData()->getCallFrameTypeAlignment(STy)); unsigned StructSize = getTargetData()->getTypeSize(STy); Flags |= (StructAlign << ISD::ParamFlags::ByValAlignOffs); Flags |= (StructSize << ISD::ParamFlags::ByValSizeOffs); @@ -3999,7 +4000,8 @@ TargetLowering::LowerCallTo(SDOperand Chain, const Type *RetTy, Flags |= ISD::ParamFlags::ByVal; const PointerType *Ty = cast<PointerType>(Args[i].Ty); const StructType *STy = cast<StructType>(Ty->getElementType()); - unsigned StructAlign = Log2_32(getTargetData()->getABITypeAlignment(STy)); + unsigned StructAlign = + Log2_32(getTargetData()->getCallFrameTypeAlignment(STy)); unsigned StructSize = getTargetData()->getTypeSize(STy); Flags |= (StructAlign << ISD::ParamFlags::ByValAlignOffs); Flags |= (StructSize << ISD::ParamFlags::ByValSizeOffs); diff --git a/llvm/lib/Target/TargetData.cpp b/llvm/lib/Target/TargetData.cpp index bb1fff5de5f..9f7cb003791 100644 --- a/llvm/lib/Target/TargetData.cpp +++ b/llvm/lib/Target/TargetData.cpp @@ -182,7 +182,8 @@ void TargetData::init(const std::string &TargetDescription) { setAlignment(VECTOR_ALIGN, 8, 8, 64); // v2i32 setAlignment(VECTOR_ALIGN, 16, 16, 128); // v16i8, v8i16, v4i32, ... setAlignment(AGGREGATE_ALIGN, 0, 8, 0); // struct, union, class, ... - + setAlignment(STACK_ALIGN, 0, 8, 0); // objects on the stack + while (!temp.empty()) { std::string token = getToken(temp, "-"); std::string arg0 = getToken(token, ":"); @@ -204,10 +205,16 @@ void TargetData::init(const std::string &TargetDescription) { case 'i': case 'v': case 'f': - case 'a': { - AlignTypeEnum align_type = - (*p == 'i' ? INTEGER_ALIGN : (*p == 'f' ? FLOAT_ALIGN : - (*p == 'v' ? VECTOR_ALIGN : AGGREGATE_ALIGN))); + case 'a': + case 's': { + AlignTypeEnum align_type; + switch(*p) { + case 'i': align_type = INTEGER_ALIGN; break; + case 'v': align_type = VECTOR_ALIGN; break; + case 'f': align_type = FLOAT_ALIGN; break; + case 'a': align_type = AGGREGATE_ALIGN; break; + case 's': align_type = STACK_ALIGN; break; + } uint32_t size = (uint32_t) atoi(++p); unsigned char abi_align = atoi(getToken(token, ":").c_str()) / 8; unsigned char pref_align = atoi(getToken(token, ":").c_str()) / 8; @@ -529,6 +536,14 @@ unsigned char TargetData::getABITypeAlignment(const Type *Ty) const { return getAlignment(Ty, true); } +unsigned char TargetData::getCallFrameTypeAlignment(const Type *Ty) const { + for (unsigned i = 0, e = Alignments.size(); i != e; ++i) + if (Alignments[i].AlignType == STACK_ALIGN) + return Alignments[i].ABIAlign; + + return getABITypeAlignment(Ty); +} + unsigned char TargetData::getPrefTypeAlignment(const Type *Ty) const { return getAlignment(Ty, false); } diff --git a/llvm/lib/Target/X86/X86Subtarget.h b/llvm/lib/Target/X86/X86Subtarget.h index 493c801f8ce..d939bc00c54 100644 --- a/llvm/lib/Target/X86/X86Subtarget.h +++ b/llvm/lib/Target/X86/X86Subtarget.h @@ -146,7 +146,7 @@ public: std::string getDataLayout() const { const char *p; if (is64Bit()) - p = "e-p:64:64-f64:64:64-i64:64:64-f80:128:128"; + p = "e-p:64:64-s:64-f64:64:64-i64:64:64-f80:128:128"; else { if (isTargetDarwin()) p = "e-p:32:32-f64:32:64-i64:32:64-f80:128:128"; |