Skip to content

Commit

Permalink
IRGen: Class layout now uses TypeInfo to figure out if types are fixe…
Browse files Browse the repository at this point in the history
…d-size

The classifyTypeSize() method was duplicating work done by IRGen's
type lowering, and it was slightly wrong in a few cases. After the
class archetype spare bits cleanup, the only remaining usage of this
method is in class layout. Just use TypeInfo instead.
  • Loading branch information
slavapestov committed Nov 15, 2015
1 parent 7237098 commit c469b20
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/IRGen/GenClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,17 +280,17 @@ namespace {
if (!var->hasStorage()) return;

SILType fieldType = classType.getFieldType(var, *IGM.SILMod);
switch (IGM.classifyTypeSize(fieldType, ResilienceScope::Component)) {
case ObjectSize::Fixed:
auto &fieldTI = IGM.getTypeInfo(fieldType);
if (fieldTI.isFixedSize())
return;
case ObjectSize::Resilient:
IsObjectResilient = true;
return;
case ObjectSize::Dependent:
IsObjectResilient = IsObjectGenericallyArranged = true;
return;
}
llvm_unreachable("bad ObjectSize value");

// If the field type is not fixed-size, the size either depends
// on generic parameters, or resilient types. In the former case,
// we store field offsets in type metadata.
if (fieldType.hasArchetype())
IsObjectGenericallyArranged = true;

IsObjectResilient = true;
}
};
} // end anonymous namespace.
Expand Down

0 comments on commit c469b20

Please sign in to comment.