@@ -130,10 +130,24 @@ class LinkEntity {
130130 // / is a ConstructorDecl* inside a class.
131131 DispatchThunkInitializer,
132132
133- // / A method dispatch thunk for an allocating constructor. The pointer is a
134- // / ConstructorDecl* inside a protocol or a class.
133+ // / A method dispatch thunk for an allocating constructor. The pointer is
134+ // / a ConstructorDecl* inside a protocol or a class.
135135 DispatchThunkAllocator,
136136
137+ // / An async function pointer for a method dispatch thunk. The pointer is
138+ // / a FuncDecl* inside a protocol or a class.
139+ DispatchThunkAsyncFunctionPointer,
140+
141+ // / An async function pointer for a method dispatch thunk for an
142+ // / initializing constructor. The pointer is a ConstructorDecl* inside a
143+ // / class.
144+ DispatchThunkInitializerAsyncFunctionPointer,
145+
146+ // / An async function pointer for a method dispatch thunk for an allocating
147+ // / constructor. The pointer is a ConstructorDecl* inside a protocol or
148+ // / a class.
149+ DispatchThunkAllocatorAsyncFunctionPointer,
150+
137151 // / A method descriptor. The pointer is a FuncDecl* inside a protocol
138152 // / or a class.
139153 MethodDescriptor,
@@ -295,7 +309,7 @@ class LinkEntity {
295309
296310 // / The same as AsyncFunctionPointer but with a different stored value, for
297311 // / use by TBDGen.
298- // / The pointer is a AbstractStorageDecl *.
312+ // / The pointer is an AbstractFunctionDecl *.
299313 AsyncFunctionPointerAST,
300314
301315 // / The pointer is a SILFunction*.
@@ -861,7 +875,8 @@ class LinkEntity {
861875 }
862876
863877 static LinkEntity
864- forSILFunction (SILFunction *F, bool IsDynamicallyReplaceableImplementation) {
878+ forSILFunction (SILFunction *F,
879+ bool IsDynamicallyReplaceableImplementation=false ) {
865880 LinkEntity entity;
866881 entity.Pointer = F;
867882 entity.SecondaryPointer = nullptr ;
@@ -1100,12 +1115,36 @@ class LinkEntity {
11001115 return entity;
11011116 }
11021117
1103- static LinkEntity forAsyncFunctionPointer (SILFunction *silFunction ) {
1118+ static LinkEntity forAsyncFunctionPointer (LinkEntity other ) {
11041119 LinkEntity entity;
1105- entity.Pointer = silFunction ;
1120+ entity.Pointer = other. Pointer ;
11061121 entity.SecondaryPointer = nullptr ;
1107- entity.Data = LINKENTITY_SET_FIELD (
1108- Kind, unsigned (LinkEntity::Kind::AsyncFunctionPointer));
1122+
1123+ switch (other.getKind ()) {
1124+ case LinkEntity::Kind::SILFunction:
1125+ entity.Data = LINKENTITY_SET_FIELD (
1126+ Kind, unsigned (LinkEntity::Kind::AsyncFunctionPointer));
1127+ break ;
1128+
1129+ case LinkEntity::Kind::DispatchThunk:
1130+ entity.Data = LINKENTITY_SET_FIELD (
1131+ Kind, unsigned (LinkEntity::Kind::DispatchThunkAsyncFunctionPointer));
1132+ break ;
1133+
1134+ case LinkEntity::Kind::DispatchThunkInitializer:
1135+ entity.Data = LINKENTITY_SET_FIELD (
1136+ Kind, unsigned (LinkEntity::Kind::DispatchThunkInitializerAsyncFunctionPointer));
1137+ break ;
1138+
1139+ case LinkEntity::Kind::DispatchThunkAllocator:
1140+ entity.Data = LINKENTITY_SET_FIELD (
1141+ Kind, unsigned (LinkEntity::Kind::DispatchThunkAllocatorAsyncFunctionPointer));
1142+ break ;
1143+
1144+ default :
1145+ llvm_unreachable (" Link entity kind cannot have an async function pointer" );
1146+ }
1147+
11091148 return entity;
11101149 }
11111150
@@ -1115,6 +1154,39 @@ class LinkEntity {
11151154 return entity;
11161155 }
11171156
1157+ LinkEntity getUnderlyingEntityForAsyncFunctionPointer () const {
1158+ LinkEntity entity;
1159+ entity.Pointer = Pointer;
1160+ entity.SecondaryPointer = nullptr ;
1161+
1162+ switch (getKind ()) {
1163+ case LinkEntity::Kind::AsyncFunctionPointer:
1164+ entity.Data = LINKENTITY_SET_FIELD (
1165+ Kind, unsigned (LinkEntity::Kind::SILFunction));
1166+ break ;
1167+
1168+ case LinkEntity::Kind::DispatchThunkAsyncFunctionPointer:
1169+ entity.Data = LINKENTITY_SET_FIELD (
1170+ Kind, unsigned (LinkEntity::Kind::DispatchThunk));
1171+ break ;
1172+
1173+ case LinkEntity::Kind::DispatchThunkInitializerAsyncFunctionPointer:
1174+ entity.Data = LINKENTITY_SET_FIELD (
1175+ Kind, unsigned (LinkEntity::Kind::DispatchThunkInitializer));
1176+ break ;
1177+
1178+ case LinkEntity::Kind::DispatchThunkAllocatorAsyncFunctionPointer:
1179+ entity.Data = LINKENTITY_SET_FIELD (
1180+ Kind, unsigned (LinkEntity::Kind::DispatchThunkAllocator));
1181+ break ;
1182+
1183+ default :
1184+ llvm_unreachable (" Link entity is not an async function pointer" );
1185+ }
1186+
1187+ return entity;
1188+ }
1189+
11181190 void mangle (llvm::raw_ostream &out) const ;
11191191 void mangle (SmallVectorImpl<char > &buffer) const ;
11201192 std::string mangleAsString () const ;
0 commit comments