Update SIL devirtualization to handle begin_apply instructions.

In order to make this reasonable, I needed to shift responsibilities
around a little; the devirtualization operation is now responsible for
replacing uses of the original apply.  I wanted to remove the
phase-separation completely, but there was optimization-remark code
relying on the old apply site not having been deleted yet.

The begin_apply aspects of this aren't testable independently of
replacing materializeForSet because coroutines are currently never
called indirectly.
This commit is contained in:
John McCall
2018-08-18 04:02:49 -04:00
parent 6a2a2b8324
commit 94b748a14c
8 changed files with 264 additions and 193 deletions

View File

@@ -69,14 +69,14 @@ bool Devirtualizer::devirtualizeAppliesInFunction(SILFunction &F,
}
}
for (auto Apply : Applies) {
auto NewInstPair = tryDevirtualizeApply(Apply, CHA, &ORE);
if (!NewInstPair.second)
auto NewInst = tryDevirtualizeApply(Apply, CHA, &ORE);
if (!NewInst)
continue;
Changed = true;
replaceDeadApply(Apply, NewInstPair.first);
NewApplies.push_back(NewInstPair.second);
deleteDevirtualizedApply(Apply);
NewApplies.push_back(NewInst);
}
// For each new apply, attempt to link in function bodies if we do