16
16
17
17
#include " GenExistential.h"
18
18
19
- #include " TypeLayout.h"
20
19
#include " swift/AST/ASTContext.h"
21
20
#include " swift/AST/Decl.h"
22
21
#include " swift/AST/ExistentialLayout.h"
29
28
#include " llvm/IR/DerivedTypes.h"
30
29
#include " llvm/IR/Function.h"
31
30
#include " llvm/IR/Module.h"
32
- #include " llvm/Support/ErrorHandling.h"
33
31
#include " llvm/Support/raw_ostream.h"
34
32
35
33
#include " BitPatternBuilder.h"
@@ -685,16 +683,7 @@ namespace {
685
683
IsOptional (isOptional) {} \
686
684
TypeLayoutEntry *buildTypeLayoutEntry (IRGenModule &IGM, \
687
685
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); \
698
687
} \
699
688
void emitValueAssignWithCopy (IRGenFunction &IGF, \
700
689
Address dest, Address src) const { \
@@ -742,16 +731,7 @@ namespace {
742
731
} \
743
732
TypeLayoutEntry *buildTypeLayoutEntry (IRGenModule &IGM, \
744
733
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); \
755
735
} \
756
736
llvm::Type *getValueType () const { \
757
737
return ValueType; \
@@ -798,7 +778,7 @@ namespace {
798
778
spareBits, align, IsPOD, IsFixedSize) {} \
799
779
TypeLayoutEntry *buildTypeLayoutEntry (IRGenModule &IGM, \
800
780
SILType T) const override { \
801
- return IGM.typeLayoutCache .getOrCreateScalarEntry (*this , T, ScalarKind::POD ); \
781
+ return IGM.typeLayoutCache .getOrCreateScalarEntry (*this , T); \
802
782
} \
803
783
const LoadableTypeInfo & \
804
784
getValueTypeInfoForExtraInhabitants (IRGenModule &IGM) const { \
@@ -867,8 +847,7 @@ class OpaqueExistentialTypeInfo final :
867
847
868
848
TypeLayoutEntry *buildTypeLayoutEntry (IRGenModule &IGM,
869
849
SILType T) const override {
870
- return IGM.typeLayoutCache .getOrCreateScalarEntry (
871
- *this , T, ScalarKind::ExistentialReference);
850
+ return IGM.typeLayoutCache .getOrCreateScalarEntry (*this , T);
872
851
}
873
852
874
853
Address projectWitnessTable (IRGenFunction &IGF, Address obj,
@@ -1016,21 +995,7 @@ class ClassExistentialTypeInfo final
1016
995
1017
996
TypeLayoutEntry *buildTypeLayoutEntry (IRGenModule &IGM,
1018
997
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);
1034
999
}
1035
1000
1036
1001
// / Given an explosion with multiple pointer elements in them, pack them
@@ -1362,8 +1327,7 @@ class ExistentialMetatypeTypeInfo final
1362
1327
1363
1328
TypeLayoutEntry *buildTypeLayoutEntry (IRGenModule &IGM,
1364
1329
SILType T) const override {
1365
- return IGM.typeLayoutCache .getOrCreateScalarEntry (*this , T,
1366
- ScalarKind::POD);
1330
+ return IGM.typeLayoutCache .getOrCreateScalarEntry (*this , T);
1367
1331
}
1368
1332
1369
1333
void emitValueRetain (IRGenFunction &IGF, llvm::Value *value,
@@ -1389,27 +1353,17 @@ class ErrorExistentialTypeInfo : public HeapTypeInfo<ErrorExistentialTypeInfo>
1389
1353
ReferenceCounting Refcounting;
1390
1354
1391
1355
public:
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,
1394
1359
const ProtocolDecl *errorProto,
1395
1360
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) {}
1398
1363
1399
1364
TypeLayoutEntry *buildTypeLayoutEntry (IRGenModule &IGM,
1400
1365
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);
1413
1367
}
1414
1368
1415
1369
ReferenceCounting getReferenceCounting () const {
@@ -2292,25 +2246,6 @@ void irgen::emitDeallocateBoxedOpaqueExistentialBuffer(
2292
2246
return ;
2293
2247
}
2294
2248
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
-
2314
2249
static llvm::Constant *
2315
2250
getProjectBoxedOpaqueExistentialFunction (IRGenFunction &IGF,
2316
2251
OpenedExistentialAccess accessKind,
0 commit comments