Do not specialize dead apply/partial_apply.

Do not specialize an apply/partial_apply that we've already added to the
set of dead instructions. Doing so can result in creating a new
instruction which we will leave around, and which will have a type
mismatch in its parameter list.

Fixes rdar://problem/25447450.
This commit is contained in:
Mark Lacey
2016-03-30 21:13:39 -07:00
parent e72cf0e89f
commit 84473f242a
2 changed files with 29 additions and 12 deletions

View File

@@ -67,6 +67,19 @@ bool GenericSpecializer::specializeAppliesInFunction(SILFunction &F) {
if (!Callee || !Callee->isDefinition())
continue;
// Do not attempt to specialize known dead instructions. Doing
// so would be a waste of time (since they are unused), and can
// also lead to verification errors on the newly created
// apply. This can happen in the case of a partial application
// of a reabstraction thunk where we have done an RAUW on the
// reabstracted function (which is an argument of the partial
// apply). In this case we add the partial apply of the
// reabstraction thunk to the set of dead applies, but its
// arguments types do not match the expected types of the
// argument that has been RAUWed into it.
if (DeadApplies.count(Apply.getInstruction()))
continue;
// We have a call that can potentially be specialized, so
// attempt to do so.