1616
1717#include " GenExistential.h"
1818
19- #include " TypeLayout.h"
2019#include " swift/AST/ASTContext.h"
2120#include " swift/AST/Decl.h"
2221#include " swift/AST/ExistentialLayout.h"
2928#include " llvm/IR/DerivedTypes.h"
3029#include " llvm/IR/Function.h"
3130#include " llvm/IR/Module.h"
32- #include " llvm/Support/ErrorHandling.h"
3331#include " llvm/Support/raw_ostream.h"
3432
3533#include " BitPatternBuilder.h"
@@ -685,16 +683,7 @@ namespace {
685683 IsOptional (isOptional) {} \
686684 TypeLayoutEntry *buildTypeLayoutEntry (IRGenModule &IGM, \
687685 SILType T) const override { \
688- ScalarKind kind; \
689- switch (Refcounting) { \
690- case ReferenceCounting::Native: kind = ScalarKind::NativeStrongReference; break ; \
691- case ReferenceCounting::ObjC: kind = ScalarKind::ObjCReference; break ; \
692- case ReferenceCounting::Block: kind = ScalarKind::BlockReference; break ; \
693- case ReferenceCounting::Unknown: kind = ScalarKind::UnknownReference; break ; \
694- case ReferenceCounting::Bridge: kind = ScalarKind::BridgeReference; break ; \
695- case ReferenceCounting::Error: kind = ScalarKind::ErrorReference; break ; \
696- } \
697- return IGM.typeLayoutCache .getOrCreateScalarEntry (*this , T, kind); \
686+ return IGM.typeLayoutCache .getOrCreateScalarEntry (*this , T); \
698687 } \
699688 void emitValueAssignWithCopy (IRGenFunction &IGF, \
700689 Address dest, Address src) const { \
@@ -742,16 +731,7 @@ namespace {
742731 } \
743732 TypeLayoutEntry *buildTypeLayoutEntry (IRGenModule &IGM, \
744733 SILType T) const override { \
745- ScalarKind kind; \
746- switch (Refcounting) { \
747- case ReferenceCounting::Native: kind = ScalarKind::NativeStrongReference; break ; \
748- case ReferenceCounting::ObjC: kind = ScalarKind::ObjCReference; break ; \
749- case ReferenceCounting::Block: kind = ScalarKind::BlockReference; break ; \
750- case ReferenceCounting::Unknown: kind = ScalarKind::UnknownReference; break ; \
751- case ReferenceCounting::Bridge: kind = ScalarKind::BridgeReference; break ; \
752- case ReferenceCounting::Error: kind = ScalarKind::ErrorReference; break ; \
753- } \
754- return IGM.typeLayoutCache .getOrCreateScalarEntry (*this , T, kind); \
734+ return IGM.typeLayoutCache .getOrCreateScalarEntry (*this , T); \
755735 } \
756736 llvm::Type *getValueType () const { \
757737 return ValueType; \
@@ -798,7 +778,7 @@ namespace {
798778 spareBits, align, IsPOD, IsFixedSize) {} \
799779 TypeLayoutEntry *buildTypeLayoutEntry (IRGenModule &IGM, \
800780 SILType T) const override { \
801- return IGM.typeLayoutCache .getOrCreateScalarEntry (*this , T, ScalarKind::POD ); \
781+ return IGM.typeLayoutCache .getOrCreateScalarEntry (*this , T); \
802782 } \
803783 const LoadableTypeInfo & \
804784 getValueTypeInfoForExtraInhabitants (IRGenModule &IGM) const { \
@@ -867,8 +847,7 @@ class OpaqueExistentialTypeInfo final :
867847
868848 TypeLayoutEntry *buildTypeLayoutEntry (IRGenModule &IGM,
869849 SILType T) const override {
870- return IGM.typeLayoutCache .getOrCreateScalarEntry (
871- *this , T, ScalarKind::ExistentialReference);
850+ return IGM.typeLayoutCache .getOrCreateScalarEntry (*this , T);
872851 }
873852
874853 Address projectWitnessTable (IRGenFunction &IGF, Address obj,
@@ -1016,21 +995,7 @@ class ClassExistentialTypeInfo final
1016995
1017996 TypeLayoutEntry *buildTypeLayoutEntry (IRGenModule &IGM,
1018997 SILType T) const override {
1019- ScalarKind kind;
1020- switch (Refcounting) {
1021- case ReferenceCounting::Native:
1022- kind = ScalarKind::NativeStrongReference;
1023- break ;
1024- case ReferenceCounting::ObjC:
1025- kind = ScalarKind::ObjCReference;
1026- break ;
1027- case ReferenceCounting::Unknown:
1028- kind = ScalarKind::UnknownReference;
1029- break ;
1030- default :
1031- llvm_unreachable (" Unsupported refcounting style" );
1032- }
1033- return IGM.typeLayoutCache .getOrCreateScalarEntry (*this , T, kind);
998+ return IGM.typeLayoutCache .getOrCreateScalarEntry (*this , T);
1034999 }
10351000
10361001 // / Given an explosion with multiple pointer elements in them, pack them
@@ -1362,8 +1327,7 @@ class ExistentialMetatypeTypeInfo final
13621327
13631328 TypeLayoutEntry *buildTypeLayoutEntry (IRGenModule &IGM,
13641329 SILType T) const override {
1365- return IGM.typeLayoutCache .getOrCreateScalarEntry (*this , T,
1366- ScalarKind::POD);
1330+ return IGM.typeLayoutCache .getOrCreateScalarEntry (*this , T);
13671331 }
13681332
13691333 void emitValueRetain (IRGenFunction &IGF, llvm::Value *value,
@@ -1389,27 +1353,17 @@ class ErrorExistentialTypeInfo : public HeapTypeInfo<ErrorExistentialTypeInfo>
13891353 ReferenceCounting Refcounting;
13901354
13911355public:
1392- ErrorExistentialTypeInfo (llvm::PointerType *storage, Size size,
1393- SpareBitVector spareBits, Alignment align,
1356+ ErrorExistentialTypeInfo (llvm::PointerType *storage,
1357+ Size size, SpareBitVector spareBits,
1358+ Alignment align,
13941359 const ProtocolDecl *errorProto,
13951360 ReferenceCounting refcounting)
1396- : HeapTypeInfo(refcounting, storage, size, spareBits, align),
1397- ErrorProto (errorProto), Refcounting(refcounting) {}
1361+ : HeapTypeInfo(storage, size, spareBits, align), ErrorProto(errorProto ),
1362+ Refcounting (refcounting) {}
13981363
13991364 TypeLayoutEntry *buildTypeLayoutEntry (IRGenModule &IGM,
14001365 SILType T) const override {
1401- ScalarKind kind;
1402- switch (Refcounting) {
1403- case ReferenceCounting::Native:
1404- kind = ScalarKind::NativeStrongReference;
1405- break ;
1406- case ReferenceCounting::Error:
1407- kind = ScalarKind::ErrorReference;
1408- break ;
1409- default :
1410- llvm_unreachable (" unsupported refcounting type" );
1411- }
1412- return IGM.typeLayoutCache .getOrCreateScalarEntry (*this , T, kind);
1366+ return IGM.typeLayoutCache .getOrCreateScalarEntry (*this , T);
14131367 }
14141368
14151369 ReferenceCounting getReferenceCounting () const {
@@ -2292,25 +2246,6 @@ void irgen::emitDeallocateBoxedOpaqueExistentialBuffer(
22922246 return ;
22932247}
22942248
2295- void irgen::emitDestroyBoxedOpaqueExistentialBuffer (
2296- IRGenFunction &IGF, SILType existentialType, Address existentialContainer) {
2297-
2298- // Project to the existential buffer in the existential container.
2299- auto &existentialTI =
2300- IGF.getTypeInfo (existentialType).as <OpaqueExistentialTypeInfo>();
2301- OpaqueExistentialLayout existLayout = existentialTI.getLayout ();
2302-
2303- auto *deallocateFun =
2304- getDestroyBoxedOpaqueExistentialBufferFunction (IGF.IGM , existLayout);
2305- auto *bufferAddr = IGF.Builder .CreateBitCast (
2306- existentialContainer.getAddress (),
2307- IGF.IGM .getExistentialPtrTy (existLayout.getNumTables ()));
2308- auto *call = IGF.Builder .CreateCall (deallocateFun, {bufferAddr});
2309- call->setCallingConv (IGF.IGM .DefaultCC );
2310- call->setDoesNotThrow ();
2311- return ;
2312- }
2313-
23142249static llvm::Constant *
23152250getProjectBoxedOpaqueExistentialFunction (IRGenFunction &IGF,
23162251 OpenedExistentialAccess accessKind,
0 commit comments