@@ -1363,6 +1363,26 @@ class DirectConformanceInfo : public ConformanceInfo {
1363
1363
}
1364
1364
};
1365
1365
1366
+ // / Conformance info for a witness table that can be directly generated.
1367
+ class SpecializedConformanceInfo : public ConformanceInfo {
1368
+ friend ProtocolInfo;
1369
+
1370
+ const SpecializedProtocolConformance *Conformance;
1371
+ public:
1372
+ SpecializedConformanceInfo (const SpecializedProtocolConformance *C)
1373
+ : Conformance(C) {}
1374
+
1375
+ llvm::Value *getTable (IRGenFunction &IGF,
1376
+ llvm::Value **conformingMetadataCache) const override {
1377
+ return IGF.IGM .getAddrOfWitnessTable (Conformance);
1378
+ }
1379
+
1380
+ llvm::Constant *tryGetConstantTable (IRGenModule &IGM,
1381
+ CanType conformingType) const override {
1382
+ return IGM.getAddrOfWitnessTable (Conformance);
1383
+ }
1384
+ };
1385
+
1366
1386
// / Conformance info for a witness table that is (or may be) dependent.
1367
1387
class AccessorConformanceInfo : public ConformanceInfo {
1368
1388
friend ProtocolInfo;
@@ -2454,10 +2474,19 @@ IRGenModule::getConformanceInfo(const ProtocolDecl *protocol,
2454
2474
if (auto found = checkCache (conformance))
2455
2475
return *found;
2456
2476
2477
+ const ConformanceInfo *info;
2478
+
2479
+ if (Context.LangOpts .hasFeature (Feature::Embedded)) {
2480
+ if (auto *sc = dyn_cast<SpecializedProtocolConformance>(conformance)) {
2481
+ info = new SpecializedConformanceInfo (sc);
2482
+ Conformances.try_emplace (conformance, info);
2483
+ return *info;
2484
+ }
2485
+ }
2486
+
2457
2487
// Drill down to the root normal
2458
2488
auto rootConformance = conformance->getRootConformance ();
2459
2489
2460
- const ConformanceInfo *info;
2461
2490
// If the conformance is dependent in any way, we need to unique it.
2462
2491
// Under a relative protocol witness table implementation conformances are
2463
2492
// always direct.
@@ -2657,22 +2686,24 @@ void IRGenModule::emitSILWitnessTable(SILWitnessTable *wt) {
2657
2686
wtableBuilder.collectResilientWitnesses (resilientWitnesses);
2658
2687
}
2659
2688
2660
- // Collect the information that will go into the protocol conformance
2661
- // descriptor.
2662
- unsigned tablePrivateSize = wt->getConditionalConformances ().size ();
2663
- ConformanceDescription description (rootConf, wt, global, tableSize,
2664
- tablePrivateSize, isDependent);
2689
+ if (!Context.LangOpts .hasFeature (Feature::Embedded)) {
2690
+ // Collect the information that will go into the protocol conformance
2691
+ // descriptor.
2692
+ unsigned tablePrivateSize = wt->getConditionalConformances ().size ();
2693
+ ConformanceDescription description (rootConf, wt, global, tableSize,
2694
+ tablePrivateSize, isDependent);
2665
2695
2666
- // Build the instantiation function, we if need one.
2667
- description.instantiationFn = instantiationFunction;
2668
- description.resilientWitnesses = std::move (resilientWitnesses);
2696
+ // Build the instantiation function, we if need one.
2697
+ description.instantiationFn = instantiationFunction;
2698
+ description.resilientWitnesses = std::move (resilientWitnesses);
2669
2699
2670
- // Record this conformance descriptor.
2671
- addProtocolConformance (std::move (description));
2700
+ // Record this conformance descriptor.
2701
+ addProtocolConformance (std::move (description));
2672
2702
2673
- IRGen.noteUseOfTypeContextDescriptor (
2674
- conf->getDeclContext ()->getSelfNominalTypeDecl (),
2675
- RequireMetadata);
2703
+ IRGen.noteUseOfTypeContextDescriptor (
2704
+ conf->getDeclContext ()->getSelfNominalTypeDecl (),
2705
+ RequireMetadata);
2706
+ }
2676
2707
}
2677
2708
2678
2709
// / True if a function's signature in LLVM carries polymorphic parameters.
0 commit comments