File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -2181,6 +2181,10 @@ llvm::Value *EnumTypeLayoutEntry::isBitwiseTakable(IRGenFunction &IGF) const {
2181
2181
llvm::Constant *
2182
2182
EnumTypeLayoutEntry::layoutString (IRGenModule &IGM,
2183
2183
GenericSignature genericSig) const {
2184
+ if (_layoutString) {
2185
+ return *_layoutString;
2186
+ }
2187
+
2184
2188
switch (copyDestroyKind (IGM)) {
2185
2189
case CopyDestroyStrategy::TriviallyDestroyable:
2186
2190
case CopyDestroyStrategy::Normal: {
@@ -2192,7 +2196,7 @@ EnumTypeLayoutEntry::layoutString(IRGenModule &IGM,
2192
2196
2193
2197
if (containsArchetypeField () || containsResilientField () ||
2194
2198
isMultiPayloadEnum () || !refCountString (IGM, B, genericSig)) {
2195
- return nullptr ;
2199
+ return *(_layoutString = llvm::Optional<llvm::Constant *>( nullptr )) ;
2196
2200
}
2197
2201
2198
2202
ConstantInitBuilder IB (IGM);
@@ -2207,8 +2211,9 @@ EnumTypeLayoutEntry::layoutString(IRGenModule &IGM,
2207
2211
" type_layout_string" , genericSig.getCanonicalSignature (),
2208
2212
ty.getASTType ()->mapTypeOutOfContext ()->getCanonicalType ());
2209
2213
2210
- return SB.finishAndCreateGlobal (symbolName, IGM.getPointerAlignment (),
2211
- /* constant*/ true );
2214
+ _layoutString = SB.finishAndCreateGlobal (symbolName, IGM.getPointerAlignment (),
2215
+ /* constant*/ true );
2216
+ return *_layoutString;
2212
2217
}
2213
2218
}
2214
2219
}
You can’t perform that action at this time.
0 commit comments