summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/RecordLayoutBuilder.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2016-01-12 09:12:20 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2016-01-12 09:12:20 +0000
commit567e30f3c982e1ce651dbaaa68153f60f3cec916 (patch)
treeefe35d9493d24224e66309d8b4d9db7a32d74408 /clang/lib/AST/RecordLayoutBuilder.cpp
parent0a47e65d75aa3b200f80edbba67d69697023f027 (diff)
downloadbcm5719-llvm-567e30f3c982e1ce651dbaaa68153f60f3cec916.tar.gz
bcm5719-llvm-567e30f3c982e1ce651dbaaa68153f60f3cec916.zip
PR18513: make gcc compatible layout for bit-fields with explicit aligned attribute, by Dmitry Polukhin
Fix binary compatibility issue with GCC. Differential Revision: http://reviews.llvm.org/D14980 llvm-svn: 257462
Diffstat (limited to 'clang/lib/AST/RecordLayoutBuilder.cpp')
-rw-r--r--clang/lib/AST/RecordLayoutBuilder.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp
index bc3c2a831c4..bc5ae0ffc46 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1552,7 +1552,8 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
FieldAlign = 1;
// But, if there's an 'aligned' attribute on the field, honor that.
- if (unsigned ExplicitFieldAlign = D->getMaxAlignment()) {
+ unsigned ExplicitFieldAlign = D->getMaxAlignment();
+ if (ExplicitFieldAlign) {
FieldAlign = std::max(FieldAlign, ExplicitFieldAlign);
UnpackedFieldAlign = std::max(UnpackedFieldAlign, ExplicitFieldAlign);
}
@@ -1601,6 +1602,10 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
(AllowPadding &&
(FieldOffset & (FieldAlign-1)) + FieldSize > TypeSize)) {
FieldOffset = llvm::RoundUpToAlignment(FieldOffset, FieldAlign);
+ } else if (ExplicitFieldAlign) {
+ // TODO: figure it out what needs to be done on targets that don't honor
+ // bit-field type alignment like ARM APCS ABI.
+ FieldOffset = llvm::RoundUpToAlignment(FieldOffset, ExplicitFieldAlign);
}
// Repeat the computation for diagnostic purposes.
@@ -1609,6 +1614,9 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
(UnpackedFieldOffset & (UnpackedFieldAlign-1)) + FieldSize > TypeSize))
UnpackedFieldOffset = llvm::RoundUpToAlignment(UnpackedFieldOffset,
UnpackedFieldAlign);
+ else if (ExplicitFieldAlign)
+ UnpackedFieldOffset = llvm::RoundUpToAlignment(UnpackedFieldOffset,
+ ExplicitFieldAlign);
}
// If we're using external layout, give the external layout a chance
OpenPOWER on IntegriCloud