summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2019-08-09 19:29:05 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2019-08-09 19:29:05 +0000
commita5af238343e77f405cbed7b751f24fe6c3b101b7 (patch)
tree406f1763c512c382baa807f89f978398538ee630 /clang/lib/CodeGen/CodeGenModule.cpp
parent41ac83de6aded1daf983f86a9bf0409d4e383d84 (diff)
downloadbcm5719-llvm-a5af238343e77f405cbed7b751f24fe6c3b101b7.tar.gz
bcm5719-llvm-a5af238343e77f405cbed7b751f24fe6c3b101b7.zip
CodeGen: ensure 8-byte aligned String Swift CF ABI
CFStrings should be 8-byte aligned when built for the Swift CF runtime ABI as the atomic CF info field must be properly aligned. This is a problem on 32-bit platforms which would give the structure 4-byte alignment rather than 8-byte alignment. llvm-svn: 368471
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 6ff72ec045e..b650526629b 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4669,7 +4669,10 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) {
}
Fields.addInt(LengthTy, StringLength);
- CharUnits Alignment = getPointerAlign();
+ // Swift ABI requires 8-byte alignment to ensure that the _Atomic(uint64_t) is
+ // properly aligned on 32-bit platforms.
+ CharUnits Alignment =
+ IsSwiftABI ? Context.toCharUnitsFromBits(64) : getPointerAlign();
// The struct.
GV = Fields.finishAndCreateGlobal("_unnamed_cfstring_", Alignment,
OpenPOWER on IntegriCloud