2222#include " swift/SIL/Dominance.h"
2323#include " swift/SIL/SILBuilder.h"
2424#include " swift/SIL/SILDebugScope.h"
25- #include " swift/SIL/SILOpenedArchetypesTracker.h"
2625#include " swift/SIL/SILVisitor.h"
2726
2827namespace swift {
@@ -48,7 +47,6 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
4847 SILBuilder Builder;
4948 DominanceInfo *DomTree = nullptr ;
5049 TypeSubstitutionMap OpenedExistentialSubs;
51- SILOpenedArchetypesTracker OpenedArchetypesTracker;
5250
5351 // The old-to-new value map.
5452 llvm::DenseMap<SILValue, SILValue> ValueMap;
@@ -74,21 +72,10 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
7472public:
7573 using SILInstructionVisitor<ImplClass>::asImpl;
7674
77- explicit SILCloner (SILFunction &F,
78- SILOpenedArchetypesTracker &OpenedArchetypesTracker,
79- DominanceInfo *DT = nullptr )
80- : Builder(F), DomTree(DT),
81- OpenedArchetypesTracker(OpenedArchetypesTracker) {
82- Builder.setOpenedArchetypesTracker (&OpenedArchetypesTracker);
83- }
84-
8575 explicit SILCloner (SILFunction &F, DominanceInfo *DT = nullptr )
86- : Builder(F), DomTree(DT), OpenedArchetypesTracker(&F) {
87- Builder.setOpenedArchetypesTracker (&OpenedArchetypesTracker);
88- }
76+ : Builder(F), DomTree(DT) {}
8977
90- explicit SILCloner (SILGlobalVariable *GlobVar)
91- : Builder(GlobVar), OpenedArchetypesTracker(nullptr ) {}
78+ explicit SILCloner (SILGlobalVariable *GlobVar) : Builder(GlobVar) {}
9279
9380 void clearClonerState () {
9481 ValueMap.clear ();
@@ -385,15 +372,6 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
385372private:
386373 // / MARK: SILCloner implementation details hidden from CRTP extensions.
387374
388- // / SILVisitor CRTP callback. Preprocess any instruction before cloning.
389- void beforeVisit (SILInstruction *Orig) {
390- // Update the set of available opened archetypes with the opened
391- // archetypes used by the current instruction.
392- auto TypeDependentOperands = Orig->getTypeDependentOperands ();
393- Builder.getOpenedArchetypes ().addOpenedArchetypeOperands (
394- TypeDependentOperands);
395- }
396-
397375 void clonePhiArgs (SILBasicBlock *oldBB);
398376
399377 void visitBlocksDepthFirst (SILBasicBlock *StartBB);
@@ -418,7 +396,6 @@ class SILBuilderWithPostProcess : public SILBuilder {
418396 {
419397 setInsertionPoint (SC.getBuilder ().getInsertionBB (),
420398 SC.getBuilder ().getInsertionPoint ());
421- setOpenedArchetypesTracker (SC.getBuilder ().getOpenedArchetypesTracker ());
422399 }
423400
424401 ~SILBuilderWithPostProcess () {
@@ -437,27 +414,9 @@ class SILClonerWithScopes : public SILCloner<ImplClass> {
437414 friend class SILCloner <ImplClass>;
438415public:
439416 SILClonerWithScopes (SILFunction &To,
440- SILOpenedArchetypesTracker &OpenedArchetypesTracker,
441417 DominanceInfo *DT = nullptr ,
442418 bool Disable = false )
443- : SILCloner<ImplClass>(To, OpenedArchetypesTracker, DT) {
444-
445- // We only want to do this when we generate cloned functions, not
446- // when we inline.
447-
448- // FIXME: This is due to having TypeSubstCloner inherit from
449- // SILClonerWithScopes, and having TypeSubstCloner be used
450- // both by passes that clone whole functions and ones that
451- // inline functions.
452- if (Disable)
453- return ;
454-
455- scopeCloner.reset (new ScopeCloner (To));
456- }
457-
458- SILClonerWithScopes (SILFunction &To,
459- bool Disable = false )
460- : SILCloner<ImplClass>(To) {
419+ : SILCloner<ImplClass>(To, DT) {
461420
462421 // We only want to do this when we generate cloned functions, not
463422 // when we inline.
@@ -472,7 +431,6 @@ class SILClonerWithScopes : public SILCloner<ImplClass> {
472431 scopeCloner.reset (new ScopeCloner (To));
473432 }
474433
475-
476434private:
477435 std::unique_ptr<ScopeCloner> scopeCloner;
478436protected:
@@ -684,9 +642,7 @@ void SILCloner<ImplClass>::visitBlocksDepthFirst(SILBasicBlock *startBB) {
684642 if (BB != startBB)
685643 clonePhiArgs (BB);
686644
687- // Non-terminating instructions are cloned in the first preorder walk so
688- // that all opened existentials are registered with OpenedArchetypesTracker
689- // before phi argument type substitution in successors.
645+ // Non-terminating instructions are cloned in the first preorder walk.
690646 getBuilder ().setInsertionPoint (BBMap[BB]);
691647 asImpl ().visitInstructionsInBlock (BB);
692648
0 commit comments