@@ -315,9 +315,8 @@ getRuntimeVersionThatSupportsDemanglingType(CanType type) {
315
315
// where completing the metadata during demangling might cause cyclic
316
316
// dependencies.
317
317
static std::pair<llvm::Constant *, unsigned >
318
- getTypeRefByFunction (IRGenModule &IGM,
319
- CanGenericSignature sig,
320
- CanType t) {
318
+ getTypeRefByFunction (IRGenModule &IGM, CanGenericSignature sig, CanType t,
319
+ MangledTypeRefRole role) {
321
320
IRGenMangler mangler (IGM.Context );
322
321
std::string symbolName =
323
322
mangler.mangleSymbolNameForMangledMetadataAccessorString (
@@ -433,7 +432,11 @@ getTypeRefByFunction(IRGenModule &IGM,
433
432
// Form the mangled name with its relative reference.
434
433
auto S = B.beginStruct ();
435
434
S.setPacked (true );
436
- S.add (llvm::ConstantInt::get (IGM.Int8Ty , 255 ));
435
+ if (role == MangledTypeRefRole::DefaultAssociatedTypeWitness) {
436
+ S.add (llvm::ConstantInt::get (
437
+ IGM.Int8Ty ,
438
+ ProtocolRequirementFlags::AssociatedTypeInProtocolContextByte));
439
+ }
437
440
S.add (llvm::ConstantInt::get (IGM.Int8Ty , 9 ));
438
441
S.addCompactFunctionReference (accessor);
439
442
@@ -513,7 +516,7 @@ getTypeRefImpl(IRGenModule &IGM,
513
516
// the field will be artificially hidden to reflectors.
514
517
if (isAlwaysNoncopyable) {
515
518
IGM.IRGen .noteUseOfTypeMetadata (type);
516
- return getTypeRefByFunction (IGM, sig, type);
519
+ return getTypeRefByFunction (IGM, sig, type, role );
517
520
}
518
521
}
519
522
LLVM_FALLTHROUGH;
@@ -524,12 +527,12 @@ getTypeRefImpl(IRGenModule &IGM,
524
527
// ensuring that we can always reconstruct type metadata from a mangled name
525
528
// in-process.
526
529
IGM.IRGen .noteUseOfTypeMetadata (type);
527
-
530
+
528
531
// If the minimum deployment target's runtime demangler wouldn't understand
529
532
// this mangled name, then fall back to generating a "mangled name" with a
530
533
// symbolic reference with a callback function.
531
534
if (mangledNameIsUnknownToDeployTarget (IGM, type)) {
532
- return getTypeRefByFunction (IGM, sig, type);
535
+ return getTypeRefByFunction (IGM, sig, type, role );
533
536
}
534
537
535
538
break ;
0 commit comments