Change the specialization API to allow specialization of individual calls

and specialization using a call tree.

Swift SVN r25573
This commit is contained in:
Nadav Rotem
2015-02-27 00:32:03 +00:00
parent 690cc050f0
commit 285e2e88e1
2 changed files with 16 additions and 6 deletions

View File

@@ -82,7 +82,19 @@ struct GenericSpecializer {
/// Add the call \p AI into the list of calls to inspect. /// Add the call \p AI into the list of calls to inspect.
void addApplyInst(ApplyInst *AI); void addApplyInst(ApplyInst *AI);
void addApplyInst(const std::vector<SILFunction *> &BotUpFuncList) { bool specialize() {
bool Changed = false;
for (auto &P : ApplyInstMap) {
Changed |= specializeApplyInstGroup(P.first, P.second);
}
return Changed;
}
/// Collect and specialize calls in a specific order specified by
/// \p BotUpFuncList.
bool specialize(const std::vector<SILFunction *> &BotUpFuncList) {
for (auto &F : *M) for (auto &F : *M)
collectApplyInst(F); collectApplyInst(F);
@@ -91,10 +103,7 @@ struct GenericSpecializer {
// of the list. // of the list.
Worklist.insert(Worklist.begin(), BotUpFuncList.begin(), Worklist.insert(Worklist.begin(), BotUpFuncList.begin(),
BotUpFuncList.end()); BotUpFuncList.end());
}
/// The driver for the generic specialization procedure.
bool specialize() {
bool Changed = false; bool Changed = false;
// Try to specialize generic calls. // Try to specialize generic calls.
while (Worklist.size()) { while (Worklist.size()) {

View File

@@ -41,10 +41,11 @@ public:
// functions in reverse order. // functions in reverse order.
auto &CG = CGA->getCallGraph(); auto &CG = CGA->getCallGraph();
auto GS = GenericSpecializer(getModule()); auto GS = GenericSpecializer(getModule());
GS.addApplyInst(CG.getBottomUpFunctionOrder());
// Try to specialize generic calls. // Try to specialize generic calls.
if (GS.specialize()) { bool Changed = GS.specialize(CG.getBottomUpFunctionOrder());
if (Changed) {
// Schedule another iteration of the transformation pipe. // Schedule another iteration of the transformation pipe.
PM->scheduleAnotherIteration(); PM->scheduleAnotherIteration();