From: Benjamin Kramer Date: Thu, 2 Apr 2015 13:31:50 +0000 (+0000) Subject: [alignof] Put back the hack for old versions of GCC. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=8d70064a4ac2ae09b8003173e751cfad9dc15400;p=oota-llvm.git [alignof] Put back the hack for old versions of GCC. This works around a bug (PR56859) that is fixed in all versions of GCC I tested with but was present in 4.8.0. Using 4.8.0 is of course a terrible idea, but looks like we can't drop it just yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233916 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Support/AlignOf.h b/include/llvm/Support/AlignOf.h index f30467d5440..061d5acf232 100644 --- a/include/llvm/Support/AlignOf.h +++ b/include/llvm/Support/AlignOf.h @@ -70,11 +70,38 @@ inline unsigned alignOf() { return AlignOf::Alignment; } // MSVC requires special handling here. #ifndef _MSC_VER +#if __has_feature(cxx_alignas) template struct AlignedCharArray { - LLVM_ALIGNAS(Alignment) char buffer[Size]; + alignas(Alignment) char buffer[Size]; }; +#elif defined(__GNUC__) || defined(__IBM_ATTRIBUTES) +/// \brief Create a type with an aligned char buffer. +template +struct AlignedCharArray; + +#define LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(x) \ + template \ + struct AlignedCharArray { \ + __attribute__((aligned(x))) char buffer[Size]; \ + }; + +LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(1) +LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(2) +LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(4) +LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(8) +LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(16) +LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(32) +LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(64) +LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(128) + +#undef LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT + +#else +# error No supported align as directive. +#endif + #else // _MSC_VER /// \brief Create a type with an aligned char buffer.