@@ -173,7 +173,19 @@ class PrintMetadataSource
173
173
};
174
174
175
175
Optional<llvm::VersionTuple>
176
- swift::irgen::getRuntimeVersionThatSupportsDemanglingType (CanType type) {
176
+ getRuntimeVersionThatSupportsDemanglingType (CanType type) {
177
+ // The Swift 5.5 runtime is the first version able to demangle types
178
+ // related to concurrency.
179
+ bool needsConcurrency = type.findIf ([](CanType t) -> bool {
180
+ if (auto fn = dyn_cast<AnyFunctionType>(t)) {
181
+ return fn->isAsync () || fn->isSendable () || fn->hasGlobalActor ();
182
+ }
183
+ return false ;
184
+ });
185
+ if (needsConcurrency) {
186
+ return llvm::VersionTuple (5 , 5 );
187
+ }
188
+
177
189
// Associated types of opaque types weren't mangled in a usable form by the
178
190
// Swift 5.1 runtime, so we needed to add a new mangling in 5.2.
179
191
if (type->hasOpaqueArchetype ()) {
@@ -192,16 +204,6 @@ swift::irgen::getRuntimeVersionThatSupportsDemanglingType(CanType type) {
192
204
// involving them.
193
205
}
194
206
195
- bool needsConcurrency = type.findIf ([](CanType t) -> bool {
196
- if (auto fn = dyn_cast<AnyFunctionType>(t)) {
197
- return fn->isAsync () || fn->isSendable () || fn->hasGlobalActor ();
198
- }
199
- return false ;
200
- });
201
- if (needsConcurrency) {
202
- return llvm::VersionTuple (5 , 5 );
203
- }
204
-
205
207
return None;
206
208
}
207
209
@@ -281,6 +283,20 @@ getTypeRefByFunction(IRGenModule &IGM,
281
283
return {constant, 6 };
282
284
}
283
285
286
+ bool swift::irgen::mangledNameIsUnknownToDeployTarget (IRGenModule &IGM,
287
+ CanType type) {
288
+ if (auto runtimeCompatVersion = getSwiftRuntimeCompatibilityVersionForTarget (
289
+ IGM.Context .LangOpts .Target )) {
290
+ if (auto minimumSupportedRuntimeVersion =
291
+ getRuntimeVersionThatSupportsDemanglingType (type)) {
292
+ if (*runtimeCompatVersion < *minimumSupportedRuntimeVersion) {
293
+ return true ;
294
+ }
295
+ }
296
+ }
297
+ return false ;
298
+ }
299
+
284
300
static std::pair<llvm::Constant *, unsigned >
285
301
getTypeRefImpl (IRGenModule &IGM,
286
302
CanType type,
@@ -297,16 +313,10 @@ getTypeRefImpl(IRGenModule &IGM,
297
313
// If the minimum deployment target's runtime demangler wouldn't understand
298
314
// this mangled name, then fall back to generating a "mangled name" with a
299
315
// symbolic reference with a callback function.
300
- if (auto runtimeCompatVersion = getSwiftRuntimeCompatibilityVersionForTarget
301
- (IGM.Context .LangOpts .Target )) {
302
- if (auto minimumSupportedRuntimeVersion =
303
- getRuntimeVersionThatSupportsDemanglingType (type)) {
304
- if (*runtimeCompatVersion < *minimumSupportedRuntimeVersion) {
305
- return getTypeRefByFunction (IGM, sig, type);
306
- }
307
- }
316
+ if (mangledNameIsUnknownToDeployTarget (IGM, type)) {
317
+ return getTypeRefByFunction (IGM, sig, type);
308
318
}
309
-
319
+
310
320
break ;
311
321
312
322
case MangledTypeRefRole::Reflection:
0 commit comments