Skip to content

Commit 7660df3

Browse files
committed
IRGen: Stop using FieldAccess::NonConstantIndirect
I'm not ripping it out completely, because I'm going to repurpose it for something else.
1 parent cc8da2e commit 7660df3

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

lib/IRGen/GenClass.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,6 @@ namespace {
170170
// - or has a field with resilient layout.
171171
bool ClassMetadataRequiresDynamicInitialization = false;
172172

173-
// Does the superclass have a fixed number of stored properties?
174-
// If not, and the class has generally-dependent layout, we have to
175-
// access stored properties through an indirect offset into the field
176-
// offset vector.
177-
bool ClassHasFixedFieldCount = true;
178-
179173
// Does the class have a fixed size up until the current point?
180174
// If not, we have to access stored properties either ivar offset globals,
181175
// or through the field offset vector, based on whether the layout has
@@ -304,9 +298,7 @@ namespace {
304298
//
305299
// FIXME: We need to implement indirect field/vtable entry access
306300
// before we can enable this
307-
if (IGM.Context.LangOpts.EnableClassResilience) {
308-
ClassHasFixedFieldCount = false;
309-
} else {
301+
if (!IGM.Context.LangOpts.EnableClassResilience) {
310302
addFieldsForClass(superclass, superclassType);
311303
NumInherited = Elements.size();
312304
}
@@ -405,16 +397,7 @@ namespace {
405397

406398
// If layout depends on generic parameters, we have to load the
407399
// offset from the class metadata.
408-
409-
// If the layout of the class metadata is statically known, then
410-
// there should be a fixed offset to the right offset.
411-
if (ClassHasFixedFieldCount) {
412-
return FieldAccess::ConstantIndirect;
413-
}
414-
415-
// Otherwise, the offset of the offset is stored in a global variable
416-
// that will be set up by the runtime.
417-
return FieldAccess::NonConstantIndirect;
400+
return FieldAccess::ConstantIndirect;
418401
}
419402
};
420403
} // end anonymous namespace

test/IRGen/class_resilience.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
// CHECK: @_T016class_resilience33ClassWithResilientlySizedPropertyC5colors5Int32VvpWvd = {{(protected )?}}global [[INT]] 0
1515

1616
// CHECK: @_T016class_resilience14ResilientChildC5fields5Int32VvpWvd = {{(protected )?}}global [[INT]] {{8|16}}
17-
// CHECK: @_T016class_resilience21ResilientGenericChildC5fields5Int32VvpWvi = {{(protected )?}}global [[INT]] {{56|88}}
1817

1918
// CHECK: @_T016class_resilience26ClassWithResilientPropertyCMo = {{(protected )?}}constant [[INT]] {{52|80}}
2019

@@ -231,10 +230,8 @@ public class MyResilientChild : MyResilientParent {
231230

232231
// CHECK-NEXT: [[ADDR:%.*]] = getelementptr inbounds %T16class_resilience21ResilientGenericChildC, %T16class_resilience21ResilientGenericChildC* %0, i32 0, i32 0, i32 0
233232
// CHECK-NEXT: [[ISA:%.*]] = load %swift.type*, %swift.type** [[ADDR]]
234-
// CHECK-NEXT: [[INDIRECT_OFFSET:%.*]] = load [[INT]], [[INT]]* @_T016class_resilience21ResilientGenericChildC5fields5Int32VvpWvi
235-
// CHECK-NEXT: [[ISA_ADDR:%.*]] = bitcast %swift.type* [[ISA]] to i8*
236-
// CHECK-NEXT: [[FIELD_OFFSET_TMP:%.*]] = getelementptr inbounds i8, i8* [[ISA_ADDR]], [[INT]] [[INDIRECT_OFFSET]]
237-
// CHECK-NEXT: [[FIELD_OFFSET_ADDR:%.*]] = bitcast i8* [[FIELD_OFFSET_TMP]] to [[INT]]*
233+
// CHECK-NEXT: [[ISA_ADDR:%.*]] = bitcast %swift.type* [[ISA]] to [[INT]]*
234+
// CHECK-NEXT: [[FIELD_OFFSET_ADDR:%.*]] = getelementptr inbounds [[INT]], [[INT]]* [[ISA_ADDR]], [[INT]] 11
238235
// CHECK-NEXT: [[FIELD_OFFSET:%.*]] = load [[INT]], [[INT]]* [[FIELD_OFFSET_ADDR:%.*]]
239236
// CHECK-NEXT: [[OBJECT:%.*]] = bitcast %T16class_resilience21ResilientGenericChildC* %0 to i8*
240237
// CHECK-NEXT: [[ADDR:%.*]] = getelementptr inbounds i8, i8* [[OBJECT]], [[INT]] [[FIELD_OFFSET]]

0 commit comments

Comments
 (0)