@@ -1630,26 +1630,33 @@ emitAssociatedTypeMetadataRecord(const RootProtocolConformance *conformance) {
1630
1630
builder.emit ();
1631
1631
}
1632
1632
1633
- void IRGenModule::emitBuiltinReflectionMetadata () {
1634
- if (getSwiftModule ()-> isStdlibModule ()) {
1635
- BuiltinTypes. insert (Context.TheNativeObjectType );
1636
- BuiltinTypes. insert (Context.getAnyObjectType ());
1637
- BuiltinTypes. insert (Context.TheBridgeObjectType );
1638
- BuiltinTypes. insert (Context.TheRawPointerType );
1639
- BuiltinTypes. insert (Context.TheUnsafeValueBufferType );
1633
+ llvm::ArrayRef<CanType> IRGenModule::getOrCreateSpecialStlibBuiltinTypes () {
1634
+ if (SpecialStdlibBuiltinTypes. empty ()) {
1635
+ SpecialStdlibBuiltinTypes. push_back (Context.TheNativeObjectType );
1636
+ SpecialStdlibBuiltinTypes. push_back (Context.getAnyObjectType ());
1637
+ SpecialStdlibBuiltinTypes. push_back (Context.TheBridgeObjectType );
1638
+ SpecialStdlibBuiltinTypes. push_back (Context.TheRawPointerType );
1639
+ SpecialStdlibBuiltinTypes. push_back (Context.TheUnsafeValueBufferType );
1640
1640
1641
1641
// This would not be necessary if RawPointer had the same set of
1642
1642
// extra inhabitants as these. But maybe it's best not to codify
1643
1643
// that in the ABI anyway.
1644
- CanType thinFunction = CanFunctionType::get (
1645
- {}, Context.TheEmptyTupleType ,
1646
- AnyFunctionType::ExtInfo ().withRepresentation (
1647
- FunctionTypeRepresentation::Thin));
1648
- BuiltinTypes.insert (thinFunction);
1649
-
1650
- CanType anyMetatype = CanExistentialMetatypeType::get (
1651
- Context.TheAnyType );
1652
- BuiltinTypes.insert (anyMetatype);
1644
+ CanType thinFunction =
1645
+ CanFunctionType::get ({}, Context.TheEmptyTupleType ,
1646
+ AnyFunctionType::ExtInfo ().withRepresentation (
1647
+ FunctionTypeRepresentation::Thin));
1648
+ SpecialStdlibBuiltinTypes.push_back (thinFunction);
1649
+
1650
+ CanType anyMetatype = CanExistentialMetatypeType::get (Context.TheAnyType );
1651
+ SpecialStdlibBuiltinTypes.push_back (anyMetatype);
1652
+ }
1653
+ return SpecialStdlibBuiltinTypes;
1654
+ }
1655
+
1656
+ void IRGenModule::emitBuiltinReflectionMetadata () {
1657
+ if (getSwiftModule ()->isStdlibModule ()) {
1658
+ auto SpecialBuiltins = getOrCreateSpecialStlibBuiltinTypes ();
1659
+ BuiltinTypes.insert (SpecialBuiltins.begin (), SpecialBuiltins.end ());
1653
1660
}
1654
1661
1655
1662
for (auto builtinType : BuiltinTypes)
0 commit comments