diff options
author | Chad Rosier <mcrosier@apple.com> | 2011-07-25 19:39:39 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2011-07-25 19:39:39 +0000 |
commit | 822f54a7ba3eca643104623e8048be20a3391b19 (patch) | |
tree | 719e3f1babf4490a1e9a26dfe4a88d475aec6da1 /lib/AST/ExprConstant.cpp | |
parent | 01231610bc89a8d3ae1bdfee0063af9386fd82a4 (diff) |
Allow target to specify about using minimum alignment vs preferred. Takes care of
FIXME: Override "preferred align" for double and long long for ARM apcs-gnu ABI.
Also part of rdar://9802874
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135940 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r-- | lib/AST/ExprConstant.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index fdcff0a4da..1435627562 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -1592,10 +1592,15 @@ CharUnits IntExprEvaluator::GetAlignOfType(QualType T) { // result shall be the alignment of the referenced type." if (const ReferenceType *Ref = T->getAs<ReferenceType>()) T = Ref->getPointeeType(); - - // __alignof is defined to return the preferred alignment. - return Info.Ctx.toCharUnitsFromBits( - Info.Ctx.getPreferredTypeAlign(T.getTypePtr())); + + // __alignof defaults to returning the preferred alignment, but + // can be overridden by the specific target. + if (Info.Ctx.Target.usePreferredTypeAlign()) + return Info.Ctx.toCharUnitsFromBits( + Info.Ctx.getPreferredTypeAlign(T.getTypePtr())); + else + return Info.Ctx.toCharUnitsFromBits( + Info.Ctx.getTypeAlign(T.getTypePtr())); } CharUnits IntExprEvaluator::GetAlignOfExpr(const Expr *E) { |