@@ -1630,26 +1630,33 @@ emitAssociatedTypeMetadataRecord(const RootProtocolConformance *conformance) {
16301630 builder.emit ();
16311631}
16321632
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 );
16401640
16411641 // This would not be necessary if RawPointer had the same set of
16421642 // extra inhabitants as these. But maybe it's best not to codify
16431643 // 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 ());
16531660 }
16541661
16551662 for (auto builtinType : BuiltinTypes)
0 commit comments