[cfe-dev] clang forcing 8-bytes alignment preference for 64-bit type. Why?

Francois Pichet pichet2000 at gmail.com
Sun Apr 21 10:45:43 PDT 2013


>From ASTContext.cpp

unsigned ASTContext::getPreferredTypeAlign(const Type *T) const {
  unsigned ABIAlign = getTypeAlign(T);

  // Double and long long should be naturally aligned if possible.
  if (const ComplexType* CT = T->getAs<ComplexType>())
    T = CT->getElementType().getTypePtr();
  if (T->isSpecificBuiltinType(BuiltinType::Double) ||
      T->isSpecificBuiltinType(BuiltinType::LongLong) ||
      T->isSpecificBuiltinType(BuiltinType::ULongLong))
    return std::max(ABIAlign, (unsigned)getTypeSize(T));

  return ABIAlign;
}


Why is it necessary for clang to force 8-byte alignment for 8-byte type?
That information can already be specified in TargetInfo if the architecture
requires such alignment preference.

I am asking because I am working on a CPU where 8-byte alignment for 64-bit
type is not required (4-bytes is just as fine).

I would like to remove that special case forcing for 64-bit type in
ASTContext::getPreferredTypeAlign.

Any objection?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130421/a2975c45/attachment.html>


More information about the cfe-dev mailing list