Skip to content

Commit be27850

Browse files
authored
Revert "Track dependencies of SIL instructions on opened archetypes which they use"
1 parent d4d4c61 commit be27850

31 files changed

+382
-1892
lines changed

include/swift/SIL/SILBuilder.h

+41-81
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "swift/SIL/SILDebugScope.h"
1717
#include "swift/SIL/SILFunction.h"
1818
#include "swift/SIL/SILModule.h"
19-
#include "swift/SIL/SILOpenedArchetypesTracker.h"
2019
#include "llvm/ADT/PointerUnion.h"
2120
#include "llvm/ADT/StringExtras.h"
2221

@@ -41,16 +40,6 @@ class SILBuilder {
4140
/// recorded in this list.
4241
SmallVectorImpl<SILInstruction *> *InsertedInstrs = nullptr;
4342

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-
5443
public:
5544
SILBuilder(SILFunction &F) : F(F), BB(0) {}
5645

@@ -86,19 +75,6 @@ class SILBuilder {
8675
return F.getModule().getTypeLowering(T);
8776
}
8877

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-
10278
void setCurrentDebugScope(const SILDebugScope *DS) { CurDebugScope = DS; }
10379
const SILDebugScope *getCurrentDebugScope() const { return CurDebugScope; }
10480

@@ -238,57 +214,54 @@ class SILBuilder {
238214
SILDebugVariable Var = SILDebugVariable()) {
239215
Loc.markAsPrologue();
240216
return insert(AllocStackInst::create(getSILDebugLocation(Loc),
241-
elementType, F, OpenedArchetypes,
242-
Var));
217+
elementType, F, Var));
243218
}
244219

245220
AllocRefInst *createAllocRef(SILLocation Loc, SILType elementType, bool objc,
246221
bool canAllocOnStack) {
247222
// AllocRefInsts expand to function calls and can therefore not be
248223
// counted towards the function prologue.
249224
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));
253227
}
254228

255229
AllocRefDynamicInst *createAllocRefDynamic(SILLocation Loc, SILValue operand,
256230
SILType type, bool objc) {
257231
// AllocRefDynamicInsts expand to function calls and can therefore
258232
// not be counted towards the function prologue.
259233
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));
262236
}
263237

264238
AllocValueBufferInst *
265239
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));
268242
}
269243

270244
AllocBoxInst *createAllocBox(SILLocation Loc, SILType ElementType,
271245
SILDebugVariable Var = SILDebugVariable()) {
272246
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));
275249
}
276250

277251
AllocExistentialBoxInst *
278252
createAllocExistentialBox(SILLocation Loc, SILType ExistentialType,
279253
CanType ConcreteType,
280254
ArrayRef<ProtocolConformanceRef> Conformances) {
281255
return insert(AllocExistentialBoxInst::create(
282-
getSILDebugLocation(Loc), ExistentialType, ConcreteType, Conformances,
283-
&F, OpenedArchetypes));
256+
getSILDebugLocation(Loc), ExistentialType, ConcreteType,
257+
Conformances, &F));
284258
}
285259

286260
ApplyInst *createApply(SILLocation Loc, SILValue Fn, SILType SubstFnTy,
287261
SILType Result, ArrayRef<Substitution> Subs,
288262
ArrayRef<SILValue> Args, bool isNonThrowing) {
289263
return insert(ApplyInst::create(getSILDebugLocation(Loc), Fn, SubstFnTy,
290-
Result, Subs, Args, isNonThrowing, F,
291-
OpenedArchetypes));
264+
Result, Subs, Args, isNonThrowing, F));
292265
}
293266

294267
ApplyInst *createApply(SILLocation Loc, SILValue Fn, ArrayRef<SILValue> Args,
@@ -305,18 +278,16 @@ class SILBuilder {
305278
SILBasicBlock *errorBB) {
306279
return insertTerminator(TryApplyInst::create(getSILDebugLocation(Loc),
307280
fn, substFnTy, subs, args,
308-
normalBB, errorBB, F,
309-
OpenedArchetypes));
281+
normalBB, errorBB, F));
310282
}
311283

312284
PartialApplyInst *createPartialApply(SILLocation Loc, SILValue Fn,
313285
SILType SubstFnTy,
314286
ArrayRef<Substitution> Subs,
315287
ArrayRef<SILValue> Args,
316288
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));
320291
}
321292

322293
BuiltinInst *createBuiltin(SILLocation Loc, Identifier Name, SILType ResultTy,
@@ -555,8 +526,8 @@ class SILBuilder {
555526

556527
UncheckedRefCastInst *createUncheckedRefCast(SILLocation Loc, SILValue Op,
557528
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));
560531
}
561532

562533
UncheckedRefCastAddrInst *
@@ -568,20 +539,20 @@ class SILBuilder {
568539

569540
UncheckedAddrCastInst *createUncheckedAddrCast(SILLocation Loc, SILValue Op,
570541
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));
573544
}
574545

575546
UncheckedTrivialBitCastInst *
576547
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));
579550
}
580551

581552
UncheckedBitwiseCastInst *
582553
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));
585556
}
586557

587558
RefToBridgeObjectInst *createRefToBridgeObject(SILLocation Loc, SILValue Ref,
@@ -677,8 +648,8 @@ class SILBuilder {
677648

678649
UnconditionalCheckedCastInst *
679650
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));
682653
}
683654

684655
UnconditionalCheckedCastAddrInst *createUnconditionalCheckedCastAddr(
@@ -925,10 +896,11 @@ class SILBuilder {
925896
WitnessMethodInst *createWitnessMethod(SILLocation Loc, CanType LookupTy,
926897
ProtocolConformanceRef Conformance,
927898
SILDeclRef Member, SILType MethodTy,
899+
SILValue OptionalOpenedExistential,
928900
bool Volatile = false) {
929901
return insert(WitnessMethodInst::create(
930902
getSILDebugLocation(Loc), LookupTy, Conformance, Member, MethodTy,
931-
&F, OpenedArchetypes, Volatile));
903+
&F, OptionalOpenedExistential, Volatile));
932904
}
933905

934906
DynamicMethodInst *createDynamicMethod(SILLocation Loc, SILValue Operand,
@@ -940,39 +912,27 @@ class SILBuilder {
940912

941913
OpenExistentialAddrInst *
942914
createOpenExistentialAddr(SILLocation Loc, SILValue Operand, SILType SelfTy) {
943-
auto *I = insert(new (F.getModule()) OpenExistentialAddrInst(
915+
return insert(new (F.getModule()) OpenExistentialAddrInst(
944916
getSILDebugLocation(Loc), Operand, SelfTy));
945-
if (OpenedArchetypesTracker)
946-
OpenedArchetypesTracker->registerOpenedArchetypes(I);
947-
return I;
948917
}
949918

950919
OpenExistentialMetatypeInst *createOpenExistentialMetatype(SILLocation Loc,
951920
SILValue operand,
952921
SILType selfTy) {
953-
auto *I = insert(new (F.getModule()) OpenExistentialMetatypeInst(
922+
return insert(new (F.getModule()) OpenExistentialMetatypeInst(
954923
getSILDebugLocation(Loc), operand, selfTy));
955-
if (OpenedArchetypesTracker)
956-
OpenedArchetypesTracker->registerOpenedArchetypes(I);
957-
return I;
958924
}
959925

960926
OpenExistentialRefInst *
961927
createOpenExistentialRef(SILLocation Loc, SILValue Operand, SILType Ty) {
962-
auto *I = insert(new (F.getModule()) OpenExistentialRefInst(
928+
return insert(new (F.getModule()) OpenExistentialRefInst(
963929
getSILDebugLocation(Loc), Operand, Ty));
964-
if (OpenedArchetypesTracker)
965-
OpenedArchetypesTracker->registerOpenedArchetypes(I);
966-
return I;
967930
}
968931

969932
OpenExistentialBoxInst *
970933
createOpenExistentialBox(SILLocation Loc, SILValue Operand, SILType Ty) {
971-
auto *I = insert(new (F.getModule()) OpenExistentialBoxInst(
934+
return insert(new (F.getModule()) OpenExistentialBoxInst(
972935
getSILDebugLocation(Loc), Operand, Ty));
973-
if (OpenedArchetypesTracker)
974-
OpenedArchetypesTracker->registerOpenedArchetypes(I);
975-
return I;
976936
}
977937

978938
InitExistentialAddrInst *
@@ -982,25 +942,25 @@ class SILBuilder {
982942
ArrayRef<ProtocolConformanceRef> Conformances) {
983943
return insert(InitExistentialAddrInst::create(
984944
getSILDebugLocation(Loc), Existential, FormalConcreteType,
985-
LoweredConcreteType, Conformances, &F, OpenedArchetypes));
945+
LoweredConcreteType, Conformances, &F));
986946
}
987947

988948
InitExistentialMetatypeInst *
989949
createInitExistentialMetatype(SILLocation Loc, SILValue metatype,
990950
SILType existentialType,
991951
ArrayRef<ProtocolConformanceRef> conformances) {
992952
return insert(InitExistentialMetatypeInst::create(
993-
getSILDebugLocation(Loc), existentialType, metatype, conformances, &F,
994-
OpenedArchetypes));
953+
getSILDebugLocation(Loc), existentialType, metatype, conformances,
954+
&F));
995955
}
996956

997957
InitExistentialRefInst *
998958
createInitExistentialRef(SILLocation Loc, SILType ExistentialType,
999959
CanType FormalConcreteType, SILValue Concrete,
1000960
ArrayRef<ProtocolConformanceRef> Conformances) {
1001961
return insert(InitExistentialRefInst::create(
1002-
getSILDebugLocation(Loc), ExistentialType, FormalConcreteType, Concrete,
1003-
Conformances, &F, OpenedArchetypes));
962+
getSILDebugLocation(Loc), ExistentialType, FormalConcreteType,
963+
Concrete, Conformances, &F));
1004964
}
1005965

1006966
DeinitExistentialAddrInst *createDeinitExistentialAddr(SILLocation Loc,
@@ -1032,8 +992,8 @@ class SILBuilder {
1032992
}
1033993

1034994
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));
1037997
}
1038998

1039999
ObjCMetatypeToObjectInst *
@@ -1346,9 +1306,9 @@ class SILBuilder {
13461306
SILValue op, SILType destTy,
13471307
SILBasicBlock *successBB,
13481308
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));
13521312
}
13531313

13541314
CheckedCastAddrBranchInst *

0 commit comments

Comments
 (0)