]> granicus.if.org Git - clang/commitdiff
implement rdar://10639962 by keeping track of increased alignment
authorChris Lattner <sabre@nondot.org>
Wed, 4 Jan 2012 22:35:55 +0000 (22:35 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 4 Jan 2012 22:35:55 +0000 (22:35 +0000)
information even in subscripting operations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147557 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp
test/CodeGen/alignment.c

index 4c23c061a70e0beaee3d62ed1d08ec210f18537d..c6ba65c03c42296e676bcc56d25dcdc98e21074e 100644 (file)
@@ -1702,13 +1702,17 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) {
   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 &&
index e1c9e9eb557984cdbe832a466940a84e516189f2..9384ec83d14aaa6cf4074f83b79a1db0b728f316 100644 (file)
@@ -47,3 +47,13 @@ void test3(packedfloat3 *p) {
 // 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
+