@@ -247,9 +247,9 @@ namespace {
247
247
248
248
using super::asDerived;
249
249
using super::emitCopyOfTables;
250
- using super::getNumStoredProtocols;
251
250
252
251
protected:
252
+ using super::getNumStoredProtocols;
253
253
const ReferenceCounting Refcounting;
254
254
255
255
template <class ... As>
@@ -618,13 +618,13 @@ namespace {
618
618
};
619
619
620
620
// / A type implementation for existential types.
621
- #define LOADABLE_REF_STORAGE_HELPER (Name ) \
621
+ #define REF_STORAGE_HELPER (Name, Super ) \
622
622
private: \
623
623
bool shouldStoreExtraInhabitantsInRef (IRGenModule &IGM) const { \
624
- if (getNumStoredProtocols () == 0 ) \
624
+ if (IGM.getReferenceStorageExtraInhabitantCount ( \
625
+ ReferenceOwnership::Name, Refcounting) > 1 ) \
625
626
return true ; \
626
- return IGM.getReferenceStorageExtraInhabitantCount ( \
627
- ReferenceOwnership::Name, Refcounting) > 1 ; \
627
+ return getNumStoredProtocols () == 0 ; \
628
628
} \
629
629
public: \
630
630
bool mayHaveExtraInhabitants (IRGenModule &IGM) const override { \
@@ -635,7 +635,7 @@ namespace {
635
635
return IGM.getReferenceStorageExtraInhabitantCount ( \
636
636
ReferenceOwnership::Name, Refcounting) - IsOptional; \
637
637
} else { \
638
- return LoadableTypeInfo ::getFixedExtraInhabitantCount (IGM); \
638
+ return Super ::getFixedExtraInhabitantCount (IGM); \
639
639
} \
640
640
} \
641
641
APInt getFixedExtraInhabitantValue (IRGenModule &IGM, \
@@ -647,8 +647,7 @@ namespace {
647
647
ReferenceOwnership::Name, \
648
648
Refcounting); \
649
649
} else { \
650
- return LoadableTypeInfo::getFixedExtraInhabitantValue (IGM, \
651
- bits, index); \
650
+ return Super::getFixedExtraInhabitantValue (IGM, bits, index); \
652
651
} \
653
652
} \
654
653
llvm::Value *getExtraInhabitantIndex (IRGenFunction &IGF, Address src, \
@@ -658,7 +657,7 @@ namespace {
658
657
return IGF.getReferenceStorageExtraInhabitantIndex (valueSrc, \
659
658
ReferenceOwnership::Name, Refcounting); \
660
659
} else { \
661
- return LoadableTypeInfo ::getExtraInhabitantIndex (IGF, src, T); \
660
+ return Super ::getExtraInhabitantIndex (IGF, src, T); \
662
661
} \
663
662
} \
664
663
void storeExtraInhabitant (IRGenFunction &IGF, llvm::Value *index, \
@@ -668,7 +667,7 @@ namespace {
668
667
return IGF.storeReferenceStorageExtraInhabitant (index, valueDest, \
669
668
ReferenceOwnership::Name, Refcounting); \
670
669
} else { \
671
- return LoadableTypeInfo ::storeExtraInhabitant (IGF, index, dest, T); \
670
+ return Super ::storeExtraInhabitant (IGF, index, dest, T); \
672
671
} \
673
672
} \
674
673
APInt getFixedExtraInhabitantMask (IRGenModule &IGM) const override { \
@@ -680,14 +679,15 @@ namespace {
680
679
bits = bits.zextOrTrunc (getFixedSize ().getValueInBits ()); \
681
680
return bits; \
682
681
} else { \
683
- return LoadableTypeInfo ::getFixedExtraInhabitantMask (IGM); \
682
+ return Super ::getFixedExtraInhabitantMask (IGM); \
684
683
} \
685
684
}
686
685
#define NEVER_LOADABLE_CHECKED_REF_STORAGE (Name, name, ...) \
687
686
class AddressOnly ##Name##ClassExistentialTypeInfo final : \
688
687
public AddressOnlyClassExistentialTypeInfoBase< \
689
688
AddressOnly##Name##ClassExistentialTypeInfo, \
690
689
FixedTypeInfo> { \
690
+ bool IsOptional; \
691
691
public: \
692
692
AddressOnly##Name##ClassExistentialTypeInfo( \
693
693
ArrayRef<ProtocolEntry> protocols, \
@@ -700,7 +700,8 @@ namespace {
700
700
ty, size, std::move(spareBits), \
701
701
align, IsNotPOD, \
702
702
IsNotBitwiseTakable, \
703
- IsFixedSize) {} \
703
+ IsFixedSize), \
704
+ IsOptional (isOptional) {} \
704
705
void emitValueAssignWithCopy (IRGenFunction &IGF, \
705
706
Address dest, Address src) const { \
706
707
IGF.emit ##Name##CopyAssign (dest, src, Refcounting); \
@@ -721,6 +722,7 @@ namespace {
721
722
IGF.emit ##Name##Destroy (addr, Refcounting); \
722
723
} \
723
724
StringRef getStructNameSuffix () const { return " ." #name " ref" ; } \
725
+ REF_STORAGE_HELPER (Name, FixedTypeInfo) \
724
726
};
725
727
#define ALWAYS_LOADABLE_CHECKED_REF_STORAGE (Name, ...) \
726
728
class Loadable ##Name##ClassExistentialTypeInfo final \
@@ -767,7 +769,7 @@ namespace {
767
769
getValueTypeInfoForExtraInhabitants (IRGenModule &IGM) const { \
768
770
llvm_unreachable (" should have overridden all actual uses of this" ); \
769
771
} \
770
- LOADABLE_REF_STORAGE_HELPER (Name) \
772
+ REF_STORAGE_HELPER (Name, LoadableTypeInfo ) \
771
773
};
772
774
#define SOMETIMES_LOADABLE_CHECKED_REF_STORAGE (Name, name, ...) \
773
775
NEVER_LOADABLE_CHECKED_REF_STORAGE (Name, name, " ..." ) \
@@ -794,16 +796,16 @@ namespace {
794
796
else \
795
797
return IGM.getUnknownObjectTypeInfo (); \
796
798
} \
797
- /* FIXME -- Use LOADABLE_REF_STORAGE_HELPER and make */ \
798
- /* getValueTypeInfoForExtraInhabitantsThis call llvm_unreachable() */ \
799
+ /* FIXME -- Use REF_STORAGE_HELPER and make */ \
800
+ /* getValueTypeInfoForExtraInhabitants call llvm_unreachable() */ \
799
801
void emitValueRetain (IRGenFunction &IGF, llvm::Value *value, \
800
802
Atomicity atomicity) const {} \
801
803
void emitValueRelease (IRGenFunction &IGF, llvm::Value *value, \
802
804
Atomicity atomicity) const {} \
803
805
void emitValueFixLifetime (IRGenFunction &IGF, llvm::Value *value) const {} \
804
806
};
805
807
#include " swift/AST/ReferenceStorage.def"
806
- #undef LOADABLE_REF_STORAGE_HELPER
808
+ #undef REF_STORAGE_HELPER
807
809
} // end anonymous namespace
808
810
809
811
0 commit comments