Skip to content

Commit 58d1a57

Browse files
committed
[AST] NFC: Repack misc SILBoxType bits
1 parent d6ea606 commit 58d1a57

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

include/swift/AST/Types.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,13 @@ class alignas(1 << TypeAlignInBits) TypeBase {
339339
};
340340
NUMBITS(SILFunctionType, NumTypeBaseBits + 12);
341341

342+
struct SILBoxTypeBitfields {
343+
unsigned : NumTypeBaseBits;
344+
unsigned : 32 - NumTypeBaseBits; // unused / padding
345+
unsigned NumGenericArgs : 32;
346+
};
347+
NUMBITS(SILBoxType, 64);
348+
342349
struct AnyMetatypeTypeBitfields {
343350
unsigned : NumTypeBaseBits;
344351
/// The representation of the metatype.
@@ -379,6 +386,7 @@ class alignas(1 << TypeAlignInBits) TypeBase {
379386
TypeVariableTypeBitfields TypeVariableTypeBits;
380387
ArchetypeTypeBitfields ArchetypeTypeBits;
381388
SILFunctionTypeBitfields SILFunctionTypeBits;
389+
SILBoxTypeBitfields SILBoxTypeBits;
382390
AnyMetatypeTypeBitfields AnyMetatypeTypeBits;
383391
ProtocolCompositionTypeBitfields ProtocolCompositionTypeBits;
384392
TupleTypeBitfields TupleTypeBits;
@@ -3806,7 +3814,6 @@ class SILBoxType final : public TypeBase,
38063814
friend TrailingObjects;
38073815

38083816
SILLayout *Layout;
3809-
unsigned NumGenericArgs;
38103817

38113818
static RecursiveTypeProperties
38123819
getRecursivePropertiesFromSubstitutions(SubstitutionList Args);
@@ -3822,7 +3829,7 @@ class SILBoxType final : public TypeBase,
38223829
SILLayout *getLayout() const { return Layout; }
38233830
SubstitutionList getGenericArgs() const {
38243831
return llvm::makeArrayRef(getTrailingObjects<Substitution>(),
3825-
NumGenericArgs);
3832+
SILBoxTypeBits.NumGenericArgs);
38263833
}
38273834

38283835
// In SILType.h:

lib/AST/Type.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4103,10 +4103,8 @@ void SILBoxType::Profile(llvm::FoldingSetNodeID &id, SILLayout *Layout,
41034103
SILBoxType::SILBoxType(ASTContext &C,
41044104
SILLayout *Layout, SubstitutionList Args)
41054105
: TypeBase(TypeKind::SILBox, &C,
4106-
getRecursivePropertiesFromSubstitutions(Args)),
4107-
Layout(Layout),
4108-
NumGenericArgs(Args.size())
4109-
{
4106+
getRecursivePropertiesFromSubstitutions(Args)), Layout(Layout) {
4107+
SILBoxTypeBits.NumGenericArgs = Args.size();
41104108
#ifndef NDEBUG
41114109
// Check that the generic args are reasonable for the box's signature.
41124110
if (Layout->getGenericSignature())
@@ -4115,9 +4113,8 @@ SILBoxType::SILBoxType(ASTContext &C,
41154113
assert(arg.getReplacement()->isCanonical() &&
41164114
"box arguments must be canonical types!");
41174115
#endif
4118-
auto paramsBuf = getTrailingObjects<Substitution>();
4119-
for (unsigned i = 0; i < NumGenericArgs; ++i)
4120-
::new (paramsBuf + i) Substitution(Args[i]);
4116+
std::uninitialized_copy(Args.begin(), Args.end(),
4117+
getTrailingObjects<Substitution>());
41214118
}
41224119

41234120
RecursiveTypeProperties SILBoxType::

0 commit comments

Comments
 (0)