Skip to content

Commit 3f6bd9d

Browse files
committed
[NFC] IRGen: Store SILType in metadata collector.
1 parent babdbda commit 3f6bd9d

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

lib/IRGen/GenExistential.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ namespace {
253253
asDerived().emitValueAssignWithCopy(IGF, destValue, srcValue);
254254
emitCopyOfTables(IGF, dest, src);
255255
} else {
256-
OutliningMetadataCollector collector(IGF, LayoutIsNeeded,
256+
OutliningMetadataCollector collector(T, IGF, LayoutIsNeeded,
257257
DeinitIsNotNeeded);
258258
collector.emitCallToOutlinedCopy(dest, src, T, *this,
259259
IsNotInitialization, IsNotTake);
@@ -268,7 +268,7 @@ namespace {
268268
asDerived().emitValueInitializeWithCopy(IGF, destValue, srcValue);
269269
emitCopyOfTables(IGF, dest, src);
270270
} else {
271-
OutliningMetadataCollector collector(IGF, LayoutIsNeeded,
271+
OutliningMetadataCollector collector(T, IGF, LayoutIsNeeded,
272272
DeinitIsNotNeeded);
273273
collector.emitCallToOutlinedCopy(dest, src, T, *this,
274274
IsInitialization, IsNotTake);
@@ -283,7 +283,7 @@ namespace {
283283
asDerived().emitValueAssignWithTake(IGF, destValue, srcValue);
284284
emitCopyOfTables(IGF, dest, src);
285285
} else {
286-
OutliningMetadataCollector collector(IGF, LayoutIsNeeded,
286+
OutliningMetadataCollector collector(T, IGF, LayoutIsNeeded,
287287
DeinitIsNotNeeded);
288288
collector.emitCallToOutlinedCopy(dest, src, T, *this,
289289
IsNotInitialization, IsTake);
@@ -298,7 +298,7 @@ namespace {
298298
asDerived().emitValueInitializeWithTake(IGF, destValue, srcValue);
299299
emitCopyOfTables(IGF, dest, src);
300300
} else {
301-
OutliningMetadataCollector collector(IGF, LayoutIsNeeded,
301+
OutliningMetadataCollector collector(T, IGF, LayoutIsNeeded,
302302
DeinitIsNotNeeded);
303303
collector.emitCallToOutlinedCopy(dest, src, T, *this,
304304
IsInitialization, IsTake);
@@ -311,7 +311,7 @@ namespace {
311311
Address valueAddr = projectValue(IGF, existential);
312312
asDerived().emitValueDestroy(IGF, valueAddr);
313313
} else {
314-
OutliningMetadataCollector collector(IGF, LayoutIsNeeded,
314+
OutliningMetadataCollector collector(T, IGF, LayoutIsNeeded,
315315
DeinitIsNeeded);
316316
collector.emitCallToOutlinedDestroy(existential, T, *this);
317317
}
@@ -968,7 +968,7 @@ class OpaqueExistentialTypeInfo final :
968968
srcBuffer);
969969
} else {
970970
// Create an outlined function to avoid explosion
971-
OutliningMetadataCollector collector(IGF, LayoutIsNeeded,
971+
OutliningMetadataCollector collector(T, IGF, LayoutIsNeeded,
972972
DeinitIsNotNeeded);
973973
collector.emitCallToOutlinedCopy(dest, src, T, *this,
974974
IsInitialization, IsNotTake);
@@ -985,7 +985,7 @@ class OpaqueExistentialTypeInfo final :
985985
IGF.emitMemCpy(dest, src, getLayout().getSize(IGF.IGM));
986986
} else {
987987
// Create an outlined function to avoid explosion
988-
OutliningMetadataCollector collector(IGF, LayoutIsNeeded,
988+
OutliningMetadataCollector collector(T, IGF, LayoutIsNeeded,
989989
DeinitIsNotNeeded);
990990
collector.emitCallToOutlinedCopy(dest, src, T, *this,
991991
IsInitialization, IsTake);

lib/IRGen/GenType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ void LoadableTypeInfo::initializeWithCopy(IRGenFunction &IGF, Address destAddr,
184184
loadAsCopy(IGF, srcAddr, copy);
185185
initialize(IGF, copy, destAddr, true);
186186
} else {
187-
OutliningMetadataCollector collector(IGF, LayoutIsNeeded,
187+
OutliningMetadataCollector collector(T, IGF, LayoutIsNeeded,
188188
DeinitIsNotNeeded);
189189
// No need to collect anything because we assume loadable types can be
190190
// loaded without enums.

lib/IRGen/Outlining.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ using namespace swift;
3333
using namespace irgen;
3434

3535
OutliningMetadataCollector::OutliningMetadataCollector(
36-
IRGenFunction &IGF, LayoutIsNeeded_t needsLayout,
36+
SILType T, IRGenFunction &IGF, LayoutIsNeeded_t needsLayout,
3737
DeinitIsNeeded_t needsDeinitTypes)
38-
: IGF(IGF), needsLayout(needsLayout), needsDeinit(needsDeinitTypes) {}
38+
: T(T), IGF(IGF), needsLayout(needsLayout), needsDeinit(needsDeinitTypes) {}
3939

4040
void OutliningMetadataCollector::collectTypeMetadata(SILType ty) {
4141
// If the type has no archetypes, we can emit it from scratch in the callee.
@@ -180,7 +180,7 @@ bool TypeInfo::withWitnessableMetadataCollector(
180180
}
181181

182182
if (needsCollector) {
183-
OutliningMetadataCollector collector(IGF, needsLayout, needsDeinit);
183+
OutliningMetadataCollector collector(T, IGF, needsLayout, needsDeinit);
184184
if (needsDeinit || needsLayout) {
185185
// Only collect if anything would be collected.
186186
collectMetadataForOutlining(collector, T);
@@ -479,7 +479,8 @@ llvm::Constant *IRGenModule::getOrCreateRetainFunction(const TypeInfo &ti,
479479

480480
void TypeInfo::callOutlinedRelease(IRGenFunction &IGF, Address addr, SILType T,
481481
Atomicity atomicity) const {
482-
OutliningMetadataCollector collector(IGF, LayoutIsNotNeeded, DeinitIsNeeded);
482+
OutliningMetadataCollector collector(T, IGF, LayoutIsNotNeeded,
483+
DeinitIsNeeded);
483484
collectMetadataForOutlining(collector, T);
484485
collector.emitCallToOutlinedRelease(addr, T, *this, atomicity);
485486
}

lib/IRGen/Outlining.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "IRGen.h"
2121
#include "LocalTypeDataKind.h"
2222
#include "swift/Basic/LLVM.h"
23+
#include "swift/SIL/SILType.h"
2324
#include "llvm/ADT/MapVector.h"
2425

2526
namespace llvm {
@@ -33,6 +34,7 @@ class CanType;
3334
enum IsInitialization_t : bool;
3435
enum IsTake_t : bool;
3536
class SILType;
37+
class NominalTypeDecl;
3638

3739
namespace irgen {
3840
class Address;
@@ -60,6 +62,7 @@ enum DeinitIsNeeded_t : bool {
6062
/// - emit the call to the outlined copy/destroy helper
6163
class OutliningMetadataCollector {
6264
public:
65+
SILType T;
6366
IRGenFunction &IGF;
6467
const unsigned needsLayout : 1;
6568
const unsigned needsDeinit : 1;
@@ -69,7 +72,8 @@ class OutliningMetadataCollector {
6972
friend class IRGenModule;
7073

7174
public:
72-
OutliningMetadataCollector(IRGenFunction &IGF, LayoutIsNeeded_t needsLayout,
75+
OutliningMetadataCollector(SILType T, IRGenFunction &IGF,
76+
LayoutIsNeeded_t needsLayout,
7377
DeinitIsNeeded_t needsDeinitTypes);
7478

7579
void collectTypeMetadata(SILType type);

0 commit comments

Comments
 (0)