@@ -2591,15 +2591,17 @@ void irgen::emitLazyTypeContextDescriptor(IRGenModule &IGM,
2591
2591
auto &ti = IGM.getTypeInfo (lowered);
2592
2592
auto *typeLayoutEntry =
2593
2593
ti.buildTypeLayoutEntry (IGM, lowered, /* useStructLayouts*/ true );
2594
- if (IGM.Context .LangOpts .hasFeature (Feature::LayoutStringValueWitnesses)) {
2594
+ if (IGM.Context .LangOpts .hasFeature (Feature::LayoutStringValueWitnesses) &&
2595
+ IGM.getOptions ().EnableLayoutStringValueWitnesses ) {
2595
2596
2596
2597
auto genericSig =
2597
2598
lowered.getNominalOrBoundGenericNominal ()->getGenericSignature ();
2598
2599
hasLayoutString = !!typeLayoutEntry->layoutString (IGM, genericSig);
2599
2600
}
2600
2601
2601
2602
if (auto sd = dyn_cast<StructDecl>(type)) {
2602
- if (IGM.Context .LangOpts .hasFeature (Feature::LayoutStringValueWitnessesInstantiation)) {
2603
+ if (IGM.Context .LangOpts .hasFeature (Feature::LayoutStringValueWitnessesInstantiation) &&
2604
+ IGM.getOptions ().EnableLayoutStringValueWitnessesInstantiation ) {
2603
2605
hasLayoutString |= requiresForeignTypeMetadata (type) ||
2604
2606
needsSingletonMetadataInitialization (IGM, type) ||
2605
2607
(type->isGenericContext () && !isa<FixedTypeInfo>(ti));
@@ -2896,7 +2898,8 @@ static void emitInitializeFieldOffsetVectorWithLayoutString(
2896
2898
bool isVWTMutable, MetadataDependencyCollector *collector) {
2897
2899
auto &IGM = IGF.IGM ;
2898
2900
assert (IGM.Context .LangOpts .hasFeature (
2899
- Feature::LayoutStringValueWitnessesInstantiation));
2901
+ Feature::LayoutStringValueWitnessesInstantiation) &&
2902
+ IGM.getOptions ().EnableLayoutStringValueWitnesses );
2900
2903
2901
2904
auto *target = T.getStructOrBoundGenericStruct ();
2902
2905
@@ -3008,7 +3011,9 @@ static void emitInitializeValueMetadata(IRGenFunction &IGF,
3008
3011
3009
3012
if (IGM.Context .LangOpts .hasFeature (Feature::LayoutStringValueWitnesses) &&
3010
3013
IGM.Context .LangOpts .hasFeature (
3011
- Feature::LayoutStringValueWitnessesInstantiation)) {
3014
+ Feature::LayoutStringValueWitnessesInstantiation) &&
3015
+ IGM.getOptions ().EnableLayoutStringValueWitnesses &&
3016
+ IGM.getOptions ().EnableLayoutStringValueWitnessesInstantiation ) {
3012
3017
emitInitializeFieldOffsetVectorWithLayoutString (IGF, loweredTy, metadata,
3013
3018
isVWTMutable, collector);
3014
3019
} else {
@@ -3123,7 +3128,8 @@ namespace {
3123
3128
Impl &asImpl () { return *static_cast <Impl*>(this ); }
3124
3129
3125
3130
llvm::Constant *emitLayoutString () {
3126
- if (!IGM.Context .LangOpts .hasFeature (Feature::LayoutStringValueWitnesses))
3131
+ if (!IGM.Context .LangOpts .hasFeature (Feature::LayoutStringValueWitnesses) ||
3132
+ !IGM.getOptions ().EnableLayoutStringValueWitnesses )
3127
3133
return nullptr ;
3128
3134
auto lowered = getLoweredTypeInPrimaryContext (
3129
3135
IGM, Target->getDeclaredType ()->getCanonicalType ());
@@ -3206,7 +3212,8 @@ namespace {
3206
3212
asImpl ().emitInitializeMetadata (IGF, metadata, false , collector);
3207
3213
3208
3214
if (IGM.Context .LangOpts .hasFeature (
3209
- Feature::LayoutStringValueWitnesses)) {
3215
+ Feature::LayoutStringValueWitnesses) &&
3216
+ IGM.getOptions ().EnableLayoutStringValueWitnesses ) {
3210
3217
if (auto *layoutString = getLayoutString ()) {
3211
3218
auto layoutStringCast = IGF.Builder .CreateBitCast (layoutString,
3212
3219
IGM.Int8PtrTy );
@@ -3782,7 +3789,8 @@ namespace {
3782
3789
}
3783
3790
3784
3791
llvm::Constant *emitLayoutString () {
3785
- if (!IGM.Context .LangOpts .hasFeature (Feature::LayoutStringValueWitnesses))
3792
+ if (!IGM.Context .LangOpts .hasFeature (Feature::LayoutStringValueWitnesses) ||
3793
+ !IGM.getOptions ().EnableLayoutStringValueWitnesses )
3786
3794
return nullptr ;
3787
3795
auto lowered = getLoweredTypeInPrimaryContext (
3788
3796
IGM, Target->getDeclaredType ()->getCanonicalType ());
@@ -4986,11 +4994,13 @@ namespace {
4986
4994
}
4987
4995
4988
4996
bool hasLayoutString () {
4989
- if (!IGM.Context .LangOpts .hasFeature (Feature::LayoutStringValueWitnesses)) {
4997
+ if (!IGM.Context .LangOpts .hasFeature (Feature::LayoutStringValueWitnesses) ||
4998
+ !IGM.getOptions ().EnableLayoutStringValueWitnesses ) {
4990
4999
return false ;
4991
5000
}
4992
5001
4993
- if (IGM.Context .LangOpts .hasFeature (Feature::LayoutStringValueWitnessesInstantiation)) {
5002
+ if (IGM.Context .LangOpts .hasFeature (Feature::LayoutStringValueWitnessesInstantiation) &&
5003
+ IGM.getOptions ().EnableLayoutStringValueWitnessesInstantiation ) {
4994
5004
return !!getLayoutString () || needsSingletonMetadataInitialization (IGM, Target);
4995
5005
}
4996
5006
@@ -5029,7 +5039,8 @@ namespace {
5029
5039
}
5030
5040
5031
5041
llvm::Constant *emitLayoutString () {
5032
- if (!IGM.Context .LangOpts .hasFeature (Feature::LayoutStringValueWitnesses))
5042
+ if (!IGM.Context .LangOpts .hasFeature (Feature::LayoutStringValueWitnesses) ||
5043
+ !IGM.getOptions ().EnableLayoutStringValueWitnesses )
5033
5044
return nullptr ;
5034
5045
auto lowered = getLoweredTypeInPrimaryContext (
5035
5046
IGM, Target->getDeclaredType ()->getCanonicalType ());
@@ -5180,12 +5191,14 @@ namespace {
5180
5191
5181
5192
bool hasLayoutString () {
5182
5193
if (!IGM.Context .LangOpts .hasFeature (
5183
- Feature::LayoutStringValueWitnesses)) {
5194
+ Feature::LayoutStringValueWitnesses) ||
5195
+ !IGM.getOptions ().EnableLayoutStringValueWitnesses ) {
5184
5196
return false ;
5185
5197
}
5186
5198
return !!getLayoutString () ||
5187
5199
(IGM.Context .LangOpts .hasFeature (
5188
5200
Feature::LayoutStringValueWitnessesInstantiation) &&
5201
+ IGM.getOptions ().EnableLayoutStringValueWitnessesInstantiation &&
5189
5202
(HasDependentVWT || HasDependentMetadata) &&
5190
5203
!isa<FixedTypeInfo>(IGM.getTypeInfo (getLoweredType ())));
5191
5204
}
@@ -5445,7 +5458,8 @@ namespace {
5445
5458
}
5446
5459
5447
5460
llvm::Constant *emitLayoutString () {
5448
- if (!IGM.Context .LangOpts .hasFeature (Feature::LayoutStringValueWitnesses))
5461
+ if (!IGM.Context .LangOpts .hasFeature (Feature::LayoutStringValueWitnesses) ||
5462
+ !IGM.getOptions ().EnableLayoutStringValueWitnesses )
5449
5463
return nullptr ;
5450
5464
auto lowered = getLoweredTypeInPrimaryContext (
5451
5465
IGM, Target->getDeclaredType ()->getCanonicalType ());
0 commit comments