[cfe-commits] r147557 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp test/CodeGen/alignment.c
Chris Lattner
sabre at nondot.org
Wed Jan 4 14:35:55 PST 2012
Author: lattner
Date: Wed Jan 4 16:35:55 2012
New Revision: 147557
URL: http://llvm.org/viewvc/llvm-project?rev=147557&view=rev
Log:
implement rdar://10639962 by keeping track of increased alignment
information even in subscripting operations.
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/test/CodeGen/alignment.c
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=147557&r1=147556&r2=147557&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Jan 4 16:35:55 2012
@@ -1702,13 +1702,17 @@
assert(!T.isNull() &&
"CodeGenFunction::EmitArraySubscriptExpr(): Illegal base type");
+
// Limit the alignment to that of the result type.
+ LValue LV;
if (!ArrayAlignment.isZero()) {
CharUnits Align = getContext().getTypeAlignInChars(T);
ArrayAlignment = std::min(Align, ArrayAlignment);
+ LV = MakeAddrLValue(Address, T, ArrayAlignment);
+ } else {
+ LV = MakeNaturalAlignAddrLValue(Address, T);
}
- LValue LV = MakeAddrLValue(Address, T, ArrayAlignment);
LV.getQuals().setAddressSpace(E->getBase()->getType().getAddressSpace());
if (getContext().getLangOptions().ObjC1 &&
Modified: cfe/trunk/test/CodeGen/alignment.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/alignment.c?rev=147557&r1=147556&r2=147557&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/alignment.c (original)
+++ cfe/trunk/test/CodeGen/alignment.c Wed Jan 4 16:35:55 2012
@@ -47,3 +47,13 @@
// CHECK: ret void
+
+typedef float __attribute__((vector_size(16), aligned(64))) float4align64;
+
+// rdar://10639962 - Typedef alignment lost in p[]-style dereferencing
+void test4(float4align64 *p) {
+ p[0] = (float4align64){ 3.2f, 2.3f, 0.1f, 0.0f };
+}
+// CHECK: @test4(
+// CHECK: store <4 x float> {{.*}}, <4 x float>* %arrayidx, align 64
+
More information about the cfe-commits
mailing list