// ARC layout strings only include the class's ivars. In non-fragile
// runtimes, that means starting at InstanceStart, rounded up to word
// alignment. In fragile runtimes, there's no InstanceStart, so it means
- // starting at the end of the superclass, rounded up to word alignment.
+ // starting at the offset of the first ivar, rounded up to word alignment.
//
// MRC weak layout strings follow the ARC style.
CharUnits baseOffset;
if (isNonFragileABI()) {
baseOffset = beginOffset; // InstanceStart
- } else if (auto superClass = OI->getSuperClass()) {
- auto startOffset =
- CGM.getContext().getASTObjCInterfaceLayout(superClass).getSize();
- baseOffset = startOffset;
+ } else if (!ivars.empty()) {
+ baseOffset =
+ CharUnits::fromQuantity(ComputeIvarBaseOffset(CGM, OMD, ivars[0]));
} else {
baseOffset = CharUnits::Zero();
}
- (void) run;
@end
+// The ivars in HighlyAlignedSubclass should be placed in the tail-padding
+// of the superclass. Ensure that they're still covered by layouts.
+@interface HighlyAligned : Object {
+ __attribute__((aligned(32))) void *array[2];
+}
+@end
+// CHECK-MODERN: @"OBJC_IVAR_$_HighlyAlignedSubclass.ivar2" = global i64 24,
+// CHECK-MODERN: @"OBJC_IVAR_$_HighlyAlignedSubclass.ivar" = global i64 16,
+// CHECK-MODERN: @OBJC_CLASS_NAME_{{.*}} = {{.*}} c"\02\00"
+// CHECK-MODERN: @"\01l_OBJC_CLASS_RO_$_HighlyAlignedSubclass" = {{.*}} {
+// CHECK-FRAGILE: @OBJC_INSTANCE_VARIABLES_HighlyAlignedSubclass = {{.*}}, i32 8 }, {{.*}}, i32 12 }]
+// CHECK-FRAGILE: @OBJC_CLASS_NAME_{{.*}} = {{.*}} c"\02\00"
+// CHECK-FRAGILE: @OBJC_CLASS_HighlyAlignedSubclass
+@interface HighlyAlignedSubclass : HighlyAligned {
+ __weak id ivar;
+ __weak id ivar2;
+}
+@end
+@implementation HighlyAlignedSubclass @end
+
// CHECK-MODERN: @OBJC_CLASS_NAME_{{.*}} = {{.*}} c"\01\00"
// CHECK-MODERN: @"\01l_OBJC_CLASS_RO_$_Foo" = {{.*}} { i32 772
// 772 == 0x304