11
11
// ===----------------------------------------------------------------------===//
12
12
13
13
#define DEBUG_TYPE " sil-semantic-arc-opts"
14
+ #include " swift/Basic/BlotSetVector.h"
14
15
#include " swift/Basic/STLExtras.h"
15
16
#include " swift/SIL/BasicBlockUtils.h"
16
17
#include " swift/SIL/BranchPropagatedUser.h"
17
18
#include " swift/SIL/MemAccessUtils.h"
18
19
#include " swift/SIL/OwnershipUtils.h"
19
- #include " swift/SILOptimizer/Utils/Local.h"
20
20
#include " swift/SIL/SILArgument.h"
21
21
#include " swift/SIL/SILBuilder.h"
22
22
#include " swift/SIL/SILInstruction.h"
23
23
#include " swift/SIL/SILVisitor.h"
24
24
#include " swift/SILOptimizer/Analysis/PostOrderAnalysis.h"
25
25
#include " swift/SILOptimizer/PassManager/Passes.h"
26
26
#include " swift/SILOptimizer/PassManager/Transforms.h"
27
+ #include " swift/SILOptimizer/Utils/Local.h"
27
28
#include " llvm/ADT/SmallPtrSet.h"
28
29
#include " llvm/ADT/SmallVector.h"
29
30
#include " llvm/ADT/Statistic.h"
@@ -138,7 +139,7 @@ namespace {
138
139
// / the worklist before we delete them.
139
140
struct SemanticARCOptVisitor
140
141
: SILInstructionVisitor<SemanticARCOptVisitor, bool > {
141
- SmallSetVector <SILValue, 32 > worklist;
142
+ SmallBlotSetVector <SILValue, 32 > worklist;
142
143
SILFunction &F;
143
144
Optional<DeadEndBlocks> TheDeadEndBlocks;
144
145
@@ -175,7 +176,7 @@ struct SemanticARCOptVisitor
175
176
// Remove all SILValues of the instruction from the worklist and then erase
176
177
// the instruction.
177
178
for (SILValue result : i->getResults ()) {
178
- worklist.remove (result);
179
+ worklist.erase (result);
179
180
}
180
181
i->eraseFromParent ();
181
182
}
@@ -205,7 +206,11 @@ bool SemanticARCOptVisitor::processWorklist() {
205
206
bool madeChange = false ;
206
207
207
208
while (!worklist.empty ()) {
208
- SILValue next = worklist.pop_back_val ();
209
+ // Pop the last element off the list. If we were returned None, we blotted
210
+ // this element, so skip it.
211
+ SILValue next = worklist.pop_back_val ().getValueOr (SILValue ());
212
+ if (!next)
213
+ continue ;
209
214
210
215
// First check if this is an instruction that is trivially dead. This can
211
216
// occur if we eliminate rr traffic resulting in dead projections and the
@@ -224,7 +229,7 @@ bool SemanticARCOptVisitor::processWorklist() {
224
229
worklist.insert (operand);
225
230
}
226
231
for (SILValue result : i->getResults ()) {
227
- worklist.remove (result);
232
+ worklist.erase (result);
228
233
}
229
234
++NumEliminatedInsts;
230
235
});
0 commit comments