diff options
author | Cameron Zwarich <zwarich@apple.com> | 2011-04-13 06:03:16 +0000 |
---|---|---|
committer | Cameron Zwarich <zwarich@apple.com> | 2011-04-13 06:03:16 +0000 |
commit | cdf59f70166708800e38593c1b2b97c60a9ba688 (patch) | |
tree | d03173cdd521fcf9e20dbccff758044ad39a82ef /llvm/lib | |
parent | b9c9e34cb35faa7df67f73de07b0d867fa4e366a (diff) | |
download | bcm5719-llvm-cdf59f70166708800e38593c1b2b97c60a9ba688.tar.gz bcm5719-llvm-cdf59f70166708800e38593c1b2b97c60a9ba688.zip |
If a global variable has a specified alignment that is less than the preferred
alignment for its type, use the minimum of the specified alignment and the ABI
alignment. This fixes <rdar://problem/9275290>.
llvm-svn: 129428
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/TargetData.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Target/TargetData.cpp b/llvm/lib/Target/TargetData.cpp index c628df04e71..d15855ce126 100644 --- a/llvm/lib/Target/TargetData.cpp +++ b/llvm/lib/Target/TargetData.cpp @@ -617,8 +617,12 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy, Value* const* Indices, unsigned TargetData::getPreferredAlignment(const GlobalVariable *GV) const { const Type *ElemType = GV->getType()->getElementType(); unsigned Alignment = getPrefTypeAlignment(ElemType); - if (GV->getAlignment() > Alignment) - Alignment = GV->getAlignment(); + unsigned GVAlignment = GV->getAlignment(); + if (GVAlignment >= Alignment) { + Alignment = GVAlignment; + } else if (GVAlignment != 0) { + Alignment = std::min(GVAlignment, getABITypeAlignment(ElemType)); + } if (GV->hasInitializer()) { if (Alignment < 16) { |