Fix double delete in generic specialization.

We ended up adding the same instruction twice to a SmallVector of
instructions to be deleted. To avoid this, we'll track these
to-be-deleted instructions in a SmallSetVector instead.

We were also failing to add an instruction that we can delete to the set
of instructions to be deleted, so I fixed that as well.

I've added a test case, but it's currently disabled because fixing this
turned up another issue in the same code which I still need to take a
look at.

Fixes rdar://problem/25369617.
This commit is contained in:
Mark Lacey
2016-03-29 22:34:58 -07:00
parent 5b7e030810
commit 99d4485713
5 changed files with 89 additions and 10 deletions

View File

@@ -48,7 +48,7 @@ class GenericSpecializer : public SILFunctionTransform {
} // end anonymous namespace
bool GenericSpecializer::specializeAppliesInFunction(SILFunction &F) {
llvm::SmallVector<SILInstruction *, 8> DeadApplies;
DeadInstructionSet DeadApplies;
for (auto &BB : F) {
for (auto It = BB.begin(), End = BB.end(); It != End;) {