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 {
21812181llvm::Constant *
21822182EnumTypeLayoutEntry::layoutString (IRGenModule &IGM,
21832183 GenericSignature genericSig) const {
2184+ if (_layoutString) {
2185+ return *_layoutString;
2186+ }
2187+
21842188 switch (copyDestroyKind (IGM)) {
21852189 case CopyDestroyStrategy::TriviallyDestroyable:
21862190 case CopyDestroyStrategy::Normal: {
@@ -2192,7 +2196,7 @@ EnumTypeLayoutEntry::layoutString(IRGenModule &IGM,
21922196
21932197 if (containsArchetypeField () || containsResilientField () ||
21942198 isMultiPayloadEnum () || !refCountString (IGM, B, genericSig)) {
2195- return nullptr ;
2199+ return *(_layoutString = llvm::Optional<llvm::Constant *>( nullptr )) ;
21962200 }
21972201
21982202 ConstantInitBuilder IB (IGM);
@@ -2207,8 +2211,9 @@ EnumTypeLayoutEntry::layoutString(IRGenModule &IGM,
22072211 " type_layout_string" , genericSig.getCanonicalSignature (),
22082212 ty.getASTType ()->mapTypeOutOfContext ()->getCanonicalType ());
22092213
2210- return SB.finishAndCreateGlobal (symbolName, IGM.getPointerAlignment (),
2211- /* constant*/ true );
2214+ _layoutString = SB.finishAndCreateGlobal (symbolName, IGM.getPointerAlignment (),
2215+ /* constant*/ true );
2216+ return *_layoutString;
22122217 }
22132218 }
22142219}
You can’t perform that action at this time.
0 commit comments