Skip to content

Commit 476f069

Browse files
Merge pull request swiftlang#40142 from aschwaighofer/revert_typelayout
Revert "Merge pull request swiftlang#37116 from gmittert/Descaling"
2 parents 8a6c4b3 + 7c7dd66 commit 476f069

18 files changed

+108
-647
lines changed

lib/IRGen/ClassTypeInfo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
#include "ClassLayout.h"
2121
#include "HeapTypeInfo.h"
22-
#include "TypeLayout.h"
2322

2423
namespace swift {
2524
namespace irgen {
@@ -47,7 +46,7 @@ class ClassTypeInfo : public HeapTypeInfo<ClassTypeInfo> {
4746
ClassTypeInfo(llvm::PointerType *irType, Size size, SpareBitVector spareBits,
4847
Alignment align, ClassDecl *theClass,
4948
ReferenceCounting refcount)
50-
: HeapTypeInfo(refcount, irType, size, std::move(spareBits), align),
49+
: HeapTypeInfo(irType, size, std::move(spareBits), align),
5150
TheClass(theClass), Refcount(refcount) {}
5251

5352
ReferenceCounting getReferenceCounting() const { return Refcount; }

lib/IRGen/GenArchetype.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include "GenArchetype.h"
1818

19-
#include "TypeLayout.h"
2019
#include "swift/AST/ASTContext.h"
2120
#include "swift/AST/Decl.h"
2221
#include "swift/AST/GenericEnvironment.h"
@@ -127,11 +126,13 @@ class ClassArchetypeTypeInfo
127126
{
128127
ReferenceCounting RefCount;
129128

130-
ClassArchetypeTypeInfo(llvm::PointerType *storageType, Size size,
131-
const SpareBitVector &spareBits, Alignment align,
129+
ClassArchetypeTypeInfo(llvm::PointerType *storageType,
130+
Size size, const SpareBitVector &spareBits,
131+
Alignment align,
132132
ReferenceCounting refCount)
133-
: HeapTypeInfo(refCount, storageType, size, spareBits, align),
134-
RefCount(refCount) {}
133+
: HeapTypeInfo(storageType, size, spareBits, align),
134+
RefCount(refCount)
135+
{}
135136

136137
public:
137138
static const ClassArchetypeTypeInfo *create(llvm::PointerType *storageType,

lib/IRGen/GenConcurrency.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ class ExecutorTypeInfo :
5353

5454
TypeLayoutEntry *buildTypeLayoutEntry(IRGenModule &IGM,
5555
SILType T) const override {
56-
return IGM.typeLayoutCache.getOrCreateScalarEntry(*this, T,
57-
ScalarKind::POD);
56+
return IGM.typeLayoutCache.getOrCreateScalarEntry(*this, T);
5857
}
5958

6059
static Size getSecondElementOffset(IRGenModule &IGM) {

lib/IRGen/GenDiffFunc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class DifferentiableFuncTypeInfo final
120120
TypeLayoutEntry *buildTypeLayoutEntry(IRGenModule &IGM,
121121
SILType T) const override {
122122
if (!IGM.getOptions().ForceStructTypeLayouts || !areFieldsABIAccessible()) {
123-
return IGM.typeLayoutCache.getOrCreateTypeInfoBasedEntry(*this, T);
123+
return IGM.typeLayoutCache.getOrCreateScalarEntry(*this, T);
124124
}
125125

126126
if (getFields().empty()) {
@@ -292,7 +292,7 @@ class LinearFuncTypeInfo final
292292
TypeLayoutEntry *buildTypeLayoutEntry(IRGenModule &IGM,
293293
SILType T) const override {
294294
if (!IGM.getOptions().ForceStructTypeLayouts || !areFieldsABIAccessible()) {
295-
return IGM.typeLayoutCache.getOrCreateTypeInfoBasedEntry(*this, T);
295+
return IGM.typeLayoutCache.getOrCreateScalarEntry(*this, T);
296296
}
297297

298298
if (getFields().empty()) {

lib/IRGen/GenEnum.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@
9898
//
9999
//===----------------------------------------------------------------------===//
100100

101-
#include "TypeLayout.h"
102101
#define DEBUG_TYPE "enum-layout"
103102
#include "llvm/Support/Debug.h"
104103

@@ -386,10 +385,9 @@ namespace {
386385
return IGM.typeLayoutCache.getEmptyEntry();
387386
if (!ElementsAreABIAccessible)
388387
return IGM.typeLayoutCache.getOrCreateResilientEntry(T);
389-
390-
if (TIK >= Loadable && !IGM.getOptions().ForceStructTypeLayouts)
391-
return IGM.typeLayoutCache.getOrCreateTypeInfoBasedEntry(getTypeInfo(),
392-
T);
388+
if (TIK >= Loadable) {
389+
return IGM.typeLayoutCache.getOrCreateScalarEntry(getTypeInfo(), T);
390+
}
393391

394392
return getSingleton()->buildTypeLayoutEntry(IGM,
395393
getSingletonType(IGM, T));
@@ -1081,8 +1079,7 @@ namespace {
10811079

10821080
TypeLayoutEntry *buildTypeLayoutEntry(IRGenModule &IGM,
10831081
SILType T) const override {
1084-
return IGM.typeLayoutCache.getOrCreateScalarEntry(getTypeInfo(), T,
1085-
ScalarKind::POD);
1082+
return IGM.typeLayoutCache.getOrCreateScalarEntry(getTypeInfo(), T);
10861083
}
10871084

10881085

@@ -1234,8 +1231,7 @@ namespace {
12341231

12351232
TypeLayoutEntry *buildTypeLayoutEntry(IRGenModule &IGM,
12361233
SILType T) const override {
1237-
return IGM.typeLayoutCache.getOrCreateScalarEntry(getTypeInfo(), T,
1238-
ScalarKind::POD);
1234+
return IGM.typeLayoutCache.getOrCreateScalarEntry(getTypeInfo(), T);
12391235
}
12401236

12411237
/// \group Extra inhabitants for C-compatible enums.
@@ -3511,10 +3507,9 @@ namespace {
35113507
if (!ElementsAreABIAccessible)
35123508
return IGM.typeLayoutCache.getOrCreateResilientEntry(T);
35133509

3514-
if (!IGM.getOptions().ForceStructTypeLayouts && (AllowFixedLayoutOptimizations && TIK >= Loadable)) {
3510+
if (AllowFixedLayoutOptimizations && TIK >= Loadable) {
35153511
// The type layout entry code does not handle spare bits atm.
3516-
return IGM.typeLayoutCache.getOrCreateTypeInfoBasedEntry(getTypeInfo(),
3517-
T);
3512+
return IGM.typeLayoutCache.getOrCreateScalarEntry(getTypeInfo(), T);
35183513
}
35193514

35203515
unsigned emptyCases = ElementsWithNoPayload.size();

lib/IRGen/GenExistential.cpp

Lines changed: 12 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
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"
@@ -29,7 +28,6 @@
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

13911355
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,
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-
23142249
static llvm::Constant *
23152250
getProjectBoxedOpaqueExistentialFunction(IRGenFunction &IGF,
23162251
OpenedExistentialAccess accessKind,

lib/IRGen/GenExistential.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,6 @@ namespace irgen {
9595
void emitDeallocateBoxedOpaqueExistentialBuffer(IRGenFunction &IGF,
9696
SILType existentialType,
9797
Address existentialContainer);
98-
99-
/// Free the storage for an opaque existential in the existential
100-
/// container.
101-
/// If the value is not stored inline, this will free the box for the
102-
/// value.
103-
void emitDestroyBoxedOpaqueExistentialBuffer(IRGenFunction &IGF,
104-
SILType existentialType,
105-
Address existentialContainer);
10698
Address emitOpaqueBoxedExistentialProjection(
10799
IRGenFunction &IGF, OpenedExistentialAccess accessKind, Address base,
108100
SILType existentialType, CanArchetypeType openedArchetype);

lib/IRGen/GenFunc.cpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ namespace {
156156

157157
TypeLayoutEntry *buildTypeLayoutEntry(IRGenModule &IGM,
158158
SILType T) const override {
159-
return IGM.typeLayoutCache.getOrCreateScalarEntry(*this, T,
160-
ScalarKind::POD);
159+
return IGM.typeLayoutCache.getOrCreateScalarEntry(*this, T);
161160
}
162161

163162
bool mayHaveExtraInhabitants(IRGenModule &IGM) const override {
@@ -224,13 +223,7 @@ namespace {
224223

225224
TypeLayoutEntry *buildTypeLayoutEntry(IRGenModule &IGM,
226225
SILType T) const override {
227-
if (isPOD(ResilienceExpansion::Maximal)) {
228-
return IGM.typeLayoutCache.getOrCreateScalarEntry(*this, T,
229-
ScalarKind::POD);
230-
} else {
231-
return IGM.typeLayoutCache.getOrCreateScalarEntry(
232-
*this, T, ScalarKind::ThickFunc);
233-
}
226+
return IGM.typeLayoutCache.getOrCreateScalarEntry(*this, T);
234227
}
235228

236229
static Size getFirstElementSize(IRGenModule &IGM) {
@@ -392,19 +385,20 @@ namespace {
392385
public FuncSignatureInfo
393386
{
394387
public:
395-
BlockTypeInfo(CanSILFunctionType ty, llvm::PointerType *storageType,
388+
BlockTypeInfo(CanSILFunctionType ty,
389+
llvm::PointerType *storageType,
396390
Size size, SpareBitVector spareBits, Alignment align)
397-
: HeapTypeInfo(ReferenceCounting::Block, storageType, size, spareBits,
398-
align),
399-
FuncSignatureInfo(ty) {}
391+
: HeapTypeInfo(storageType, size, spareBits, align),
392+
FuncSignatureInfo(ty)
393+
{
394+
}
400395

401396
ReferenceCounting getReferenceCounting() const {
402397
return ReferenceCounting::Block;
403398
}
404399
TypeLayoutEntry *buildTypeLayoutEntry(IRGenModule &IGM,
405400
SILType T) const override {
406-
return IGM.typeLayoutCache.getOrCreateScalarEntry(
407-
*this, T, ScalarKind::BlockReference);
401+
return IGM.typeLayoutCache.getOrCreateScalarEntry(*this, T);
408402
}
409403
};
410404

@@ -426,8 +420,7 @@ namespace {
426420

427421
TypeLayoutEntry *buildTypeLayoutEntry(IRGenModule &IGM,
428422
SILType T) const override {
429-
return IGM.typeLayoutCache.getOrCreateScalarEntry(
430-
*this, T, ScalarKind::BlockStorage);
423+
return IGM.typeLayoutCache.getOrCreateScalarEntry(*this, T);
431424
}
432425
// The lowered type should be an LLVM struct comprising the block header
433426
// (IGM.ObjCBlockStructTy) as its first element and the capture as its

0 commit comments

Comments
 (0)