@@ -67,9 +67,6 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
67
67
// convenient way to iterate over the cloned region.
68
68
SmallVector<SILBasicBlock *, 8 > preorderBlocks;
69
69
70
- // / Set of basic blocks where unreachable was inserted.
71
- SmallPtrSet<SILBasicBlock *, 32 > BlocksWithUnreachables;
72
-
73
70
// Keep track of the last cloned block in function order. For single block
74
71
// regions, this will be the start block.
75
72
SILBasicBlock *lastClonedBB = nullptr ;
@@ -97,7 +94,6 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
97
94
ValueMap.clear ();
98
95
BBMap.clear ();
99
96
preorderBlocks.clear ();
100
- BlocksWithUnreachables.clear ();
101
97
}
102
98
103
99
// / Clients of SILCloner who want to know about any newly created
@@ -170,12 +166,6 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
170
166
asImpl ().mapValue (origValue, mappedValue);
171
167
}
172
168
173
- // / Mark a block containing an unreachable instruction for use in the `fixUp`
174
- // / callback.
175
- void addBlockWithUnreachable (SILBasicBlock *BB) {
176
- BlocksWithUnreachables.insert (BB);
177
- }
178
-
179
169
// / Register a re-mapping for opened existentials.
180
170
void registerOpenedExistentialRemapping (ArchetypeType *From,
181
171
ArchetypeType *To) {
@@ -787,32 +777,6 @@ SILCloner<ImplClass>::doFixUp(SILFunction *F) {
787
777
}
788
778
}
789
779
790
- // Remove any code after unreachable instructions.
791
-
792
- // NOTE: It is unfortunate that it essentially duplicates the code from
793
- // sil-combine, but doing so allows for avoiding any cross-layer invocations
794
- // between SIL and SILOptimizer layers.
795
-
796
- for (auto *BB : BlocksWithUnreachables) {
797
- for (auto &I : *BB) {
798
- if (!isa<UnreachableInst>(&I))
799
- continue ;
800
-
801
- // Collect together all the instructions after this point
802
- llvm::SmallVector<SILInstruction *, 32 > ToRemove;
803
- for (auto Inst = BB->rbegin (); &*Inst != &I; ++Inst)
804
- ToRemove.push_back (&*Inst);
805
-
806
- for (auto *Inst : ToRemove) {
807
- // Replace any non-dead results with SILUndef values
808
- Inst->replaceAllUsesOfAllResultsWithUndef ();
809
- Inst->eraseFromParent ();
810
- }
811
- }
812
- }
813
-
814
- BlocksWithUnreachables.clear ();
815
-
816
780
// Call any cleanup specific to the CRTP extensions.
817
781
asImpl ().fixUp (F);
818
782
}
0 commit comments