[cfe-commits] r130948 - in /cfe/trunk: lib/AST/ASTContext.cpp test/CodeGen/packed-arrays.c test/CodeGen/packed-structure.c

Fariborz Jahanian fjahanian at apple.com
Thu May 5 14:19:15 PDT 2011


Author: fjahanian
Date: Thu May  5 16:19:14 2011
New Revision: 130948

URL: http://llvm.org/viewvc/llvm-project?rev=130948&view=rev
Log:
__alignof attribute on the field must consider
packed attribute on the field. //rdar://9217290

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/test/CodeGen/packed-arrays.c
    cfe/trunk/test/CodeGen/packed-structure.c

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=130948&r1=130947&r2=130948&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu May  5 16:19:14 2011
@@ -635,6 +635,10 @@
       UseAlignAttrOnly = true;
     }
   }
+  else if (isa<FieldDecl>(D))
+      UseAlignAttrOnly = 
+        D->hasAttr<PackedAttr>() ||
+        cast<FieldDecl>(D)->getParent()->hasAttr<PackedAttr>();
 
   // If we're using the align attribute only, just ignore everything
   // else about the declaration and its type.

Modified: cfe/trunk/test/CodeGen/packed-arrays.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/packed-arrays.c?rev=130948&r1=130947&r2=130948&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/packed-arrays.c (original)
+++ cfe/trunk/test/CodeGen/packed-arrays.c Thu May  5 16:19:14 2011
@@ -34,10 +34,8 @@
 
 // CHECK: @align0_x = global i32 1
 int align0_x = __alignof(((struct s0*) 0)->x);
-// We are currently incompatible with GCC here. <rdar://problem/9217290>
 //
-// CHECK-XFAIL: @align1_x = global i32 1
-// CHECK: @align1_x = global i32 4
+// CHECK: @align1_x = global i32 1
 int align1_x = __alignof(((struct s1*) 0)->x);
 // CHECK: @align2_x = global i32 1
 int align2_x = __alignof(((struct s2*) 0)->x);
@@ -66,22 +64,22 @@
   return *(a->x + 1);
 }
 
+// Note that we are incompatible with GCC on this example.
+// 
 // CHECK: define i32 @f1_a
-// CHECK:   load i32* %{{.*}}, align 4
+// CHECK:   load i32* %{{.*}}, align 1
 // CHECK: }
 // CHECK: define i32 @f1_b
 // CHECK:   load i32* %{{.*}}, align 4
 // CHECK: }
 
-// Note that we are incompatible with GCC on these two examples.
+// Note that we are incompatible with GCC on this example.
 //
 // CHECK: define i32 @f1_c
-// CHECK-XFAIL:   load i32* %{{.*}}, align 1
 // CHECK:   load i32* %{{.*}}, align 4
 // CHECK: }
 // CHECK: define i32 @f1_d
-// CHECK-XFAIL:   load i32* %{{.*}}, align 1
-// CHECK:   load i32* %{{.*}}, align 4
+// CHECK:   load i32* %{{.*}}, align 1
 // CHECK: }
 int f1_a(struct s1 *a) {
   return a->x[1];

Modified: cfe/trunk/test/CodeGen/packed-structure.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/packed-structure.c?rev=130948&r1=130947&r2=130948&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/packed-structure.c (original)
+++ cfe/trunk/test/CodeGen/packed-structure.c Thu May  5 16:19:14 2011
@@ -10,8 +10,7 @@
 
 // CHECK-GLOBAL: @s0_align_x = global i32 4
 
-// FIXME: This should be 1 to match gcc. PR7951.
-// CHECK-GLOBAL: @s0_align_y = global i32 4
+// CHECK-GLOBAL: @s0_align_y = global i32 1
 
 // CHECK-GLOBAL: @s0_align = global i32 4
 int s0_align_x = __alignof(((struct s0*)0)->x);
@@ -27,7 +26,7 @@
 // with align 1 (in 2363.1 at least).
 //
 // CHECK-FUNCTIONS: define i32 @s0_load_y
-// CHECK-FUNCTIONS: [[s0_load_y:%.*]] = load i32* {{.*}}, align 4
+// CHECK-FUNCTIONS: [[s0_load_y:%.*]] = load i32* {{.*}}, align 1
 // CHECK-FUNCTIONS: ret i32 [[s0_load_y]]
 int s0_load_y(struct s0 *a) { return a->y; }
 // CHECK-FUNCTIONS: define void @s0_copy
@@ -92,11 +91,11 @@
   short aShort;
   int anInt;
 };
-// CHECK-GLOBAL: @s3_1 = global i32 2
+// CHECK-GLOBAL: @s3_1 = global i32 1
 int s3_1 = __alignof(((struct s3*) 0)->anInt);
 // CHECK-FUNCTIONS: define i32 @test3(
 int test3(struct s3 *ptr) {
   // CHECK-FUNCTIONS:      [[PTR:%.*]] = getelementptr inbounds {{%.*}}* {{%.*}}, i32 0, i32 1
-  // CHECK-FUNCTIONS-NEXT: load i32* [[PTR]], align 2
+  // CHECK-FUNCTIONS-NEXT: load i32* [[PTR]], align 1
   return ptr->anInt;
 }





More information about the cfe-commits mailing list