[llvm-commits] [dragonegg] r164837 - in /dragonegg/trunk: src/Convert.cpp test/validator/BitfieldRefAlignment.cpp
Duncan Sands
baldrick at free.fr
Fri Sep 28 12:31:18 PDT 2012
Author: baldrick
Date: Fri Sep 28 14:31:18 2012
New Revision: 164837
URL: http://llvm.org/viewvc/llvm-project?rev=164837&view=rev
Log:
Correct alignment computation when loading from a BIT_FIELD_REF.
Added:
dragonegg/trunk/test/validator/BitfieldRefAlignment.cpp
Modified:
dragonegg/trunk/src/Convert.cpp
Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=164837&r1=164836&r2=164837&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Fri Sep 28 14:31:18 2012
@@ -6063,6 +6063,8 @@
// than this. e.g. check out when compiling unwind-dw2-fde-darwin.c.
Ptr.Ptr = Builder.CreateBitCast(Ptr.Ptr, ValTy->getPointerTo());
Ptr.Ptr = Builder.CreateGEP(Ptr.Ptr, Builder.getInt32(UnitOffset));
+ unsigned OctetOffset = (UnitOffset * ValueSizeInBits) / 8;
+ Ptr.setAlignment(MinAlign(Ptr.getAlignment(), OctetOffset));
BitStart -= UnitOffset*ValueSizeInBits;
}
Added: dragonegg/trunk/test/validator/BitfieldRefAlignment.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/test/validator/BitfieldRefAlignment.cpp?rev=164837&view=auto
==============================================================================
--- dragonegg/trunk/test/validator/BitfieldRefAlignment.cpp (added)
+++ dragonegg/trunk/test/validator/BitfieldRefAlignment.cpp Fri Sep 28 14:31:18 2012
@@ -0,0 +1,15 @@
+// RUN: %dragonegg -S %s -o - | FileCheck %s
+// Overaligned load of field bf.
+
+struct S {
+ char s;
+ char bf : 3;
+};
+
+void bar(S &);
+
+void foo(S &rhs) {
+ if (rhs.bf == 0)
+ bar(rhs);
+// CHECK: load i8* {{.*}}, align 1
+}
More information about the llvm-commits
mailing list