@@ -572,8 +572,28 @@ bool irgen::isTypeMetadataAccessTrivial(IRGenModule &IGM, CanType type) {
572
572
if (nominalDecl->isGenericContext ())
573
573
return false ;
574
574
575
+ auto expansion = ResilienceExpansion::Maximal;
576
+
577
+ // Normally, if a value type is known to have a fixed layout to us, we will
578
+ // have emitted fully initialized metadata for it, including a payload size
579
+ // field for enum metadata for example, allowing the type metadata to be
580
+ // used in other resilience domains without initialization.
581
+ //
582
+ // However, when -enable-resilience-bypass is on, we might be using a value
583
+ // type from another module built with resilience enabled. In that case, the
584
+ // type looks like it has fixed size to us, since we're bypassing resilience,
585
+ // but the metadata still requires runtime initialization, so its incorrect
586
+ // to reference it directly.
587
+ //
588
+ // While unconditionally using minimal expansion is correct, it is not as
589
+ // efficient as it should be, so only do so if -enable-resilience-bypass is on.
590
+ //
591
+ // FIXME: All of this goes away once lldb supports resilience.
592
+ if (IGM.IRGen .Opts .EnableResilienceBypass )
593
+ expansion = ResilienceExpansion::Minimal;
594
+
575
595
// Resiliently-sized metadata access always requires an accessor.
576
- return (IGM.getTypeInfoForUnlowered (type).isFixedSize ());
596
+ return (IGM.getTypeInfoForUnlowered (type).isFixedSize (expansion ));
577
597
}
578
598
579
599
// The empty tuple type has a singleton metadata.
0 commit comments