From ba945626b094899c7a4cae587398a69097da560c Mon Sep 17 00:00:00 2001 From: Bradley Smith Date: Tue, 28 Apr 2015 11:24:54 +0000 Subject: [ARM/AArch64] Enforce alignment for bitfielded structs When creating a global variable with a type of a struct with bitfields, we must forcibly set the alignment of the global from the RecordDecl. We must do this so that the proper bitfield alignment makes its way down to LLVM, since clang will mangle the bitfields into one large type. llvm-svn: 235976 --- clang/lib/Basic/TargetInfo.cpp | 1 + clang/lib/Basic/Targets.cpp | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'clang/lib/Basic') diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp index 330258b025b..cb6449f9741 100644 --- a/clang/lib/Basic/TargetInfo.cpp +++ b/clang/lib/Basic/TargetInfo.cpp @@ -75,6 +75,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) { RegParmMax = 0; SSERegParmMax = 0; HasAlignMac68kSupport = false; + EnforceBitfieldContainerAlignment = false; // Default to no types using fpret. RealTypeUsesObjCFPRet = 0; diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 047cf0d5b5c..3d6f4f95944 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -3983,6 +3983,9 @@ class ARMTargetInfo : public TargetInfo { ZeroLengthBitfieldBoundary = 0; + // Enforce the alignment of bitfield structs + EnforceBitfieldContainerAlignment = true; + // Thumb1 add sp, #imm requires the immediate value be multiple of 4, // so set preferred for small types to 32. if (T.isOSBinFormatMachO()) { @@ -4825,6 +4828,9 @@ public: UseBitFieldTypeAlignment = true; UseZeroLengthBitfieldAlignment = true; + // Enforce the alignment of bitfield structs + EnforceBitfieldContainerAlignment = true; + // AArch64 targets default to using the ARM C++ ABI. TheCXXABI.set(TargetCXXABI::GenericAArch64); } -- cgit v1.2.3