summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-10-19 19:41:46 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-10-19 19:41:46 +0000
commitbf972bb2e0ca5b44a639743f02033fae2b6d2f4c (patch)
treecc4dbb6c33fb4f6de947514137fa8cb735142e8b
parentb27a3b0d43adbff9bb3ecb9afaa87ab420032735 (diff)
downloadbcm5719-llvm-bf972bb2e0ca5b44a639743f02033fae2b6d2f4c.tar.gz
bcm5719-llvm-bf972bb2e0ca5b44a639743f02033fae2b6d2f4c.zip
Revert r220153: "CodeGen: ConstStructBuilder must verify packed constraints after padding"
This commit caused two tests in LNT to regress. I'm able to reproduce on any platform and will send reproduction steps to the original commit log. This should restore the LNT bots that have been failing. llvm-svn: 220169
-rw-r--r--clang/lib/CodeGen/CGExprConstant.cpp19
-rw-r--r--clang/test/CodeGen/const-init.c11
2 files changed, 9 insertions, 21 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index dd87dd4657e..421e7deccc3 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -106,6 +106,15 @@ AppendBytes(CharUnits FieldOffsetInChars, llvm::Constant *InitCst) {
CharUnits AlignedNextFieldOffsetInChars =
NextFieldOffsetInChars.RoundUpToAlignment(FieldAlignment);
+ if (AlignedNextFieldOffsetInChars > FieldOffsetInChars) {
+ assert(!Packed && "Alignment is wrong even with a packed struct!");
+
+ // Convert the struct to a packed struct.
+ ConvertStructToPacked();
+
+ AlignedNextFieldOffsetInChars = NextFieldOffsetInChars;
+ }
+
if (AlignedNextFieldOffsetInChars < FieldOffsetInChars) {
// We need to append padding.
AppendPadding(FieldOffsetInChars - NextFieldOffsetInChars);
@@ -113,16 +122,6 @@ AppendBytes(CharUnits FieldOffsetInChars, llvm::Constant *InitCst) {
assert(NextFieldOffsetInChars == FieldOffsetInChars &&
"Did not add enough padding!");
- AlignedNextFieldOffsetInChars =
- NextFieldOffsetInChars.RoundUpToAlignment(FieldAlignment);
- }
-
- if (AlignedNextFieldOffsetInChars > FieldOffsetInChars) {
- assert(!Packed && "Alignment is wrong even with a packed struct!");
-
- // Convert the struct to a packed struct.
- ConvertStructToPacked();
-
AlignedNextFieldOffsetInChars = NextFieldOffsetInChars;
}
diff --git a/clang/test/CodeGen/const-init.c b/clang/test/CodeGen/const-init.c
index ccc6604c456..7d7ccae370d 100644
--- a/clang/test/CodeGen/const-init.c
+++ b/clang/test/CodeGen/const-init.c
@@ -159,14 +159,3 @@ void g29() {
static int b[1] = { "asdf" }; // expected-warning {{incompatible pointer to integer conversion initializing 'int' with an expression of type 'char [5]'}}
static int c[1] = { L"a" };
}
-
-// PR21300
-void g30() {
-#pragma pack(1)
- static struct {
- int : 1;
- int x;
- } a = {};
- // CHECK: @g30.a = internal global %struct.anon.1 <{ i8 undef, i32 0 }>, align 1
-#pragma pack()
-}
OpenPOWER on IntegriCloud