Skip to content

Commit 1dc8cbb

Browse files
committed
SIL: remove some dead code from SILCloner
NFC
1 parent e3ade39 commit 1dc8cbb

File tree

2 files changed

+0
-37
lines changed

2 files changed

+0
-37
lines changed

include/swift/SIL/SILCloner.h

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
6767
// convenient way to iterate over the cloned region.
6868
SmallVector<SILBasicBlock *, 8> preorderBlocks;
6969

70-
/// Set of basic blocks where unreachable was inserted.
71-
SmallPtrSet<SILBasicBlock *, 32> BlocksWithUnreachables;
72-
7370
// Keep track of the last cloned block in function order. For single block
7471
// regions, this will be the start block.
7572
SILBasicBlock *lastClonedBB = nullptr;
@@ -97,7 +94,6 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
9794
ValueMap.clear();
9895
BBMap.clear();
9996
preorderBlocks.clear();
100-
BlocksWithUnreachables.clear();
10197
}
10298

10399
/// Clients of SILCloner who want to know about any newly created
@@ -170,12 +166,6 @@ class SILCloner : protected SILInstructionVisitor<ImplClass> {
170166
asImpl().mapValue(origValue, mappedValue);
171167
}
172168

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-
179169
/// Register a re-mapping for opened existentials.
180170
void registerOpenedExistentialRemapping(ArchetypeType *From,
181171
ArchetypeType *To) {
@@ -787,32 +777,6 @@ SILCloner<ImplClass>::doFixUp(SILFunction *F) {
787777
}
788778
}
789779

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-
816780
// Call any cleanup specific to the CRTP extensions.
817781
asImpl().fixUp(F);
818782
}

include/swift/SIL/TypeSubstCloner.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ class TypeSubstCloner : public SILClonerWithScopes<ImplClass> {
137137
using SILClonerWithScopes<ImplClass>::getOpBasicBlock;
138138
using SILClonerWithScopes<ImplClass>::recordClonedInstruction;
139139
using SILClonerWithScopes<ImplClass>::recordFoldedValue;
140-
using SILClonerWithScopes<ImplClass>::addBlockWithUnreachable;
141140
using SILClonerWithScopes<ImplClass>::OpenedArchetypesTracker;
142141

143142
TypeSubstCloner(SILFunction &To,

0 commit comments

Comments
 (0)