16
16
#include " swift/SIL/SILDebugScope.h"
17
17
#include " swift/SIL/SILFunction.h"
18
18
#include " swift/SIL/SILModule.h"
19
- #include " swift/SIL/SILOpenedArchetypesTracker.h"
20
19
#include " llvm/ADT/PointerUnion.h"
21
20
#include " llvm/ADT/StringExtras.h"
22
21
@@ -41,16 +40,6 @@ class SILBuilder {
41
40
// / recorded in this list.
42
41
SmallVectorImpl<SILInstruction *> *InsertedInstrs = nullptr ;
43
42
44
- // / An immutable view on the set of available opened archetypes.
45
- // / It is passed down to SILInstruction constructors and create
46
- // / methods.
47
- SILOpenedArchetypesState OpenedArchetypes;
48
-
49
- // / Maps opened archetypes to their definitions. If provided,
50
- // / can be used by the builder. It is supposed to be used
51
- // / only by SILGen or SIL deserializers.
52
- SILOpenedArchetypesTracker *OpenedArchetypesTracker = nullptr ;
53
-
54
43
public:
55
44
SILBuilder (SILFunction &F) : F(F), BB(0 ) {}
56
45
@@ -86,19 +75,6 @@ class SILBuilder {
86
75
return F.getModule ().getTypeLowering (T);
87
76
}
88
77
89
- void setOpenedArchetypesTracker (SILOpenedArchetypesTracker *Tracker) {
90
- this ->OpenedArchetypesTracker = Tracker;
91
- this ->OpenedArchetypes .setOpenedArchetypesTracker (OpenedArchetypesTracker);
92
- }
93
-
94
- SILOpenedArchetypesTracker *getOpenedArchetypesTracker () const {
95
- return OpenedArchetypesTracker;
96
- }
97
-
98
- SILOpenedArchetypesState &getOpenedArchetypes () {
99
- return OpenedArchetypes;
100
- }
101
-
102
78
void setCurrentDebugScope (const SILDebugScope *DS) { CurDebugScope = DS; }
103
79
const SILDebugScope *getCurrentDebugScope () const { return CurDebugScope; }
104
80
@@ -238,57 +214,54 @@ class SILBuilder {
238
214
SILDebugVariable Var = SILDebugVariable()) {
239
215
Loc.markAsPrologue ();
240
216
return insert (AllocStackInst::create (getSILDebugLocation (Loc),
241
- elementType, F, OpenedArchetypes,
242
- Var));
217
+ elementType, F, Var));
243
218
}
244
219
245
220
AllocRefInst *createAllocRef (SILLocation Loc, SILType elementType, bool objc,
246
221
bool canAllocOnStack) {
247
222
// AllocRefInsts expand to function calls and can therefore not be
248
223
// counted towards the function prologue.
249
224
assert (!Loc.isInPrologue ());
250
- return insert (AllocRefInst::create (getSILDebugLocation (Loc), elementType, F,
251
- objc, canAllocOnStack,
252
- OpenedArchetypes));
225
+ return insert (new (F.getModule ()) AllocRefInst (
226
+ getSILDebugLocation (Loc), elementType, F, objc, canAllocOnStack));
253
227
}
254
228
255
229
AllocRefDynamicInst *createAllocRefDynamic (SILLocation Loc, SILValue operand,
256
230
SILType type, bool objc) {
257
231
// AllocRefDynamicInsts expand to function calls and can therefore
258
232
// not be counted towards the function prologue.
259
233
assert (!Loc.isInPrologue ());
260
- return insert (AllocRefDynamicInst::create ( getSILDebugLocation (Loc), operand,
261
- type, objc, F, OpenedArchetypes ));
234
+ return insert (new (F. getModule ()) AllocRefDynamicInst (
235
+ getSILDebugLocation (Loc), operand, type, objc ));
262
236
}
263
237
264
238
AllocValueBufferInst *
265
239
createAllocValueBuffer (SILLocation Loc, SILType valueType, SILValue operand) {
266
- return insert (AllocValueBufferInst::create (
267
- getSILDebugLocation (Loc), valueType, operand, F, OpenedArchetypes ));
240
+ return insert (new (F. getModule ()) AllocValueBufferInst (
241
+ getSILDebugLocation (Loc), valueType, operand));
268
242
}
269
243
270
244
AllocBoxInst *createAllocBox (SILLocation Loc, SILType ElementType,
271
245
SILDebugVariable Var = SILDebugVariable()) {
272
246
Loc.markAsPrologue ();
273
- return insert (AllocBoxInst::create ( getSILDebugLocation (Loc), ElementType, F,
274
- OpenedArchetypes , Var));
247
+ return insert (
248
+ AllocBoxInst::create ( getSILDebugLocation (Loc), ElementType, F , Var));
275
249
}
276
250
277
251
AllocExistentialBoxInst *
278
252
createAllocExistentialBox (SILLocation Loc, SILType ExistentialType,
279
253
CanType ConcreteType,
280
254
ArrayRef<ProtocolConformanceRef> Conformances) {
281
255
return insert (AllocExistentialBoxInst::create (
282
- getSILDebugLocation (Loc), ExistentialType, ConcreteType, Conformances,
283
- &F, OpenedArchetypes ));
256
+ getSILDebugLocation (Loc), ExistentialType, ConcreteType,
257
+ Conformances, &F ));
284
258
}
285
259
286
260
ApplyInst *createApply (SILLocation Loc, SILValue Fn, SILType SubstFnTy,
287
261
SILType Result, ArrayRef<Substitution> Subs,
288
262
ArrayRef<SILValue> Args, bool isNonThrowing) {
289
263
return insert (ApplyInst::create (getSILDebugLocation (Loc), Fn, SubstFnTy,
290
- Result, Subs, Args, isNonThrowing, F,
291
- OpenedArchetypes));
264
+ Result, Subs, Args, isNonThrowing, F));
292
265
}
293
266
294
267
ApplyInst *createApply (SILLocation Loc, SILValue Fn, ArrayRef<SILValue> Args,
@@ -305,18 +278,16 @@ class SILBuilder {
305
278
SILBasicBlock *errorBB) {
306
279
return insertTerminator (TryApplyInst::create (getSILDebugLocation (Loc),
307
280
fn, substFnTy, subs, args,
308
- normalBB, errorBB, F,
309
- OpenedArchetypes));
281
+ normalBB, errorBB, F));
310
282
}
311
283
312
284
PartialApplyInst *createPartialApply (SILLocation Loc, SILValue Fn,
313
285
SILType SubstFnTy,
314
286
ArrayRef<Substitution> Subs,
315
287
ArrayRef<SILValue> Args,
316
288
SILType ClosureTy) {
317
- return insert (PartialApplyInst::create (getSILDebugLocation (Loc), Fn,
318
- SubstFnTy, Subs, Args, ClosureTy, F,
319
- OpenedArchetypes));
289
+ return insert (PartialApplyInst::create (
290
+ getSILDebugLocation (Loc), Fn, SubstFnTy, Subs, Args, ClosureTy, F));
320
291
}
321
292
322
293
BuiltinInst *createBuiltin (SILLocation Loc, Identifier Name, SILType ResultTy,
@@ -555,8 +526,8 @@ class SILBuilder {
555
526
556
527
UncheckedRefCastInst *createUncheckedRefCast (SILLocation Loc, SILValue Op,
557
528
SILType Ty) {
558
- return insert (UncheckedRefCastInst::create ( getSILDebugLocation (Loc), Op, Ty,
559
- F, OpenedArchetypes ));
529
+ return insert (new (F. getModule ()) UncheckedRefCastInst (
530
+ getSILDebugLocation (Loc), Op, Ty ));
560
531
}
561
532
562
533
UncheckedRefCastAddrInst *
@@ -568,20 +539,20 @@ class SILBuilder {
568
539
569
540
UncheckedAddrCastInst *createUncheckedAddrCast (SILLocation Loc, SILValue Op,
570
541
SILType Ty) {
571
- return insert (UncheckedAddrCastInst::create ( getSILDebugLocation (Loc), Op,
572
- Ty, F, OpenedArchetypes ));
542
+ return insert (new (F. getModule ()) UncheckedAddrCastInst (
543
+ getSILDebugLocation (Loc), Op, Ty ));
573
544
}
574
545
575
546
UncheckedTrivialBitCastInst *
576
547
createUncheckedTrivialBitCast (SILLocation Loc, SILValue Op, SILType Ty) {
577
- return insert (UncheckedTrivialBitCastInst::create (
578
- getSILDebugLocation (Loc), Op, Ty, F, OpenedArchetypes ));
548
+ return insert (new (F. getModule ()) UncheckedTrivialBitCastInst (
549
+ getSILDebugLocation (Loc), Op, Ty));
579
550
}
580
551
581
552
UncheckedBitwiseCastInst *
582
553
createUncheckedBitwiseCast (SILLocation Loc, SILValue Op, SILType Ty) {
583
- return insert (UncheckedBitwiseCastInst::create ( getSILDebugLocation (Loc), Op,
584
- Ty, F, OpenedArchetypes ));
554
+ return insert (new (F. getModule ()) UncheckedBitwiseCastInst (
555
+ getSILDebugLocation (Loc), Op, Ty ));
585
556
}
586
557
587
558
RefToBridgeObjectInst *createRefToBridgeObject (SILLocation Loc, SILValue Ref,
@@ -677,8 +648,8 @@ class SILBuilder {
677
648
678
649
UnconditionalCheckedCastInst *
679
650
createUnconditionalCheckedCast (SILLocation Loc, SILValue op, SILType destTy) {
680
- return insert (UnconditionalCheckedCastInst::create (
681
- getSILDebugLocation (Loc), op, destTy, F, OpenedArchetypes ));
651
+ return insert (new (F. getModule ()) UnconditionalCheckedCastInst (
652
+ getSILDebugLocation (Loc), op, destTy));
682
653
}
683
654
684
655
UnconditionalCheckedCastAddrInst *createUnconditionalCheckedCastAddr (
@@ -925,10 +896,11 @@ class SILBuilder {
925
896
WitnessMethodInst *createWitnessMethod (SILLocation Loc, CanType LookupTy,
926
897
ProtocolConformanceRef Conformance,
927
898
SILDeclRef Member, SILType MethodTy,
899
+ SILValue OptionalOpenedExistential,
928
900
bool Volatile = false ) {
929
901
return insert (WitnessMethodInst::create (
930
902
getSILDebugLocation (Loc), LookupTy, Conformance, Member, MethodTy,
931
- &F, OpenedArchetypes , Volatile));
903
+ &F, OptionalOpenedExistential , Volatile));
932
904
}
933
905
934
906
DynamicMethodInst *createDynamicMethod (SILLocation Loc, SILValue Operand,
@@ -940,39 +912,27 @@ class SILBuilder {
940
912
941
913
OpenExistentialAddrInst *
942
914
createOpenExistentialAddr (SILLocation Loc, SILValue Operand, SILType SelfTy) {
943
- auto *I = insert (new (F.getModule ()) OpenExistentialAddrInst (
915
+ return insert (new (F.getModule ()) OpenExistentialAddrInst (
944
916
getSILDebugLocation (Loc), Operand, SelfTy));
945
- if (OpenedArchetypesTracker)
946
- OpenedArchetypesTracker->registerOpenedArchetypes (I);
947
- return I;
948
917
}
949
918
950
919
OpenExistentialMetatypeInst *createOpenExistentialMetatype (SILLocation Loc,
951
920
SILValue operand,
952
921
SILType selfTy) {
953
- auto *I = insert (new (F.getModule ()) OpenExistentialMetatypeInst (
922
+ return insert (new (F.getModule ()) OpenExistentialMetatypeInst (
954
923
getSILDebugLocation (Loc), operand, selfTy));
955
- if (OpenedArchetypesTracker)
956
- OpenedArchetypesTracker->registerOpenedArchetypes (I);
957
- return I;
958
924
}
959
925
960
926
OpenExistentialRefInst *
961
927
createOpenExistentialRef (SILLocation Loc, SILValue Operand, SILType Ty) {
962
- auto *I = insert (new (F.getModule ()) OpenExistentialRefInst (
928
+ return insert (new (F.getModule ()) OpenExistentialRefInst (
963
929
getSILDebugLocation (Loc), Operand, Ty));
964
- if (OpenedArchetypesTracker)
965
- OpenedArchetypesTracker->registerOpenedArchetypes (I);
966
- return I;
967
930
}
968
931
969
932
OpenExistentialBoxInst *
970
933
createOpenExistentialBox (SILLocation Loc, SILValue Operand, SILType Ty) {
971
- auto *I = insert (new (F.getModule ()) OpenExistentialBoxInst (
934
+ return insert (new (F.getModule ()) OpenExistentialBoxInst (
972
935
getSILDebugLocation (Loc), Operand, Ty));
973
- if (OpenedArchetypesTracker)
974
- OpenedArchetypesTracker->registerOpenedArchetypes (I);
975
- return I;
976
936
}
977
937
978
938
InitExistentialAddrInst *
@@ -982,25 +942,25 @@ class SILBuilder {
982
942
ArrayRef<ProtocolConformanceRef> Conformances) {
983
943
return insert (InitExistentialAddrInst::create (
984
944
getSILDebugLocation (Loc), Existential, FormalConcreteType,
985
- LoweredConcreteType, Conformances, &F, OpenedArchetypes ));
945
+ LoweredConcreteType, Conformances, &F));
986
946
}
987
947
988
948
InitExistentialMetatypeInst *
989
949
createInitExistentialMetatype (SILLocation Loc, SILValue metatype,
990
950
SILType existentialType,
991
951
ArrayRef<ProtocolConformanceRef> conformances) {
992
952
return insert (InitExistentialMetatypeInst::create (
993
- getSILDebugLocation (Loc), existentialType, metatype, conformances, &F,
994
- OpenedArchetypes ));
953
+ getSILDebugLocation (Loc), existentialType, metatype, conformances,
954
+ &F ));
995
955
}
996
956
997
957
InitExistentialRefInst *
998
958
createInitExistentialRef (SILLocation Loc, SILType ExistentialType,
999
959
CanType FormalConcreteType, SILValue Concrete,
1000
960
ArrayRef<ProtocolConformanceRef> Conformances) {
1001
961
return insert (InitExistentialRefInst::create (
1002
- getSILDebugLocation (Loc), ExistentialType, FormalConcreteType, Concrete,
1003
- Conformances, &F, OpenedArchetypes ));
962
+ getSILDebugLocation (Loc), ExistentialType, FormalConcreteType,
963
+ Concrete, Conformances, &F));
1004
964
}
1005
965
1006
966
DeinitExistentialAddrInst *createDeinitExistentialAddr (SILLocation Loc,
@@ -1032,8 +992,8 @@ class SILBuilder {
1032
992
}
1033
993
1034
994
MetatypeInst *createMetatype (SILLocation Loc, SILType Metatype) {
1035
- return insert (MetatypeInst::create ( getSILDebugLocation (Loc), Metatype,
1036
- &F, OpenedArchetypes ));
995
+ return insert (new (F. getModule ())
996
+ MetatypeInst ( getSILDebugLocation (Loc), Metatype ));
1037
997
}
1038
998
1039
999
ObjCMetatypeToObjectInst *
@@ -1346,9 +1306,9 @@ class SILBuilder {
1346
1306
SILValue op, SILType destTy,
1347
1307
SILBasicBlock *successBB,
1348
1308
SILBasicBlock *failureBB) {
1349
- return insertTerminator (CheckedCastBranchInst::create (
1350
- getSILDebugLocation (Loc), isExact, op, destTy, successBB, failureBB, F,
1351
- OpenedArchetypes ));
1309
+ return insertTerminator (new (F. getModule ()) CheckedCastBranchInst (
1310
+ getSILDebugLocation (Loc), isExact, op, destTy, successBB,
1311
+ failureBB ));
1352
1312
}
1353
1313
1354
1314
CheckedCastAddrBranchInst *
0 commit comments