mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Change the specialization API to allow specialization of individual calls
and specialization using a call tree. Swift SVN r25573
This commit is contained in:
@@ -82,7 +82,19 @@ struct GenericSpecializer {
|
||||
/// Add the call \p AI into the list of calls to inspect.
|
||||
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)
|
||||
collectApplyInst(F);
|
||||
|
||||
@@ -91,10 +103,7 @@ struct GenericSpecializer {
|
||||
// of the list.
|
||||
Worklist.insert(Worklist.begin(), BotUpFuncList.begin(),
|
||||
BotUpFuncList.end());
|
||||
}
|
||||
|
||||
/// The driver for the generic specialization procedure.
|
||||
bool specialize() {
|
||||
bool Changed = false;
|
||||
// Try to specialize generic calls.
|
||||
while (Worklist.size()) {
|
||||
|
||||
@@ -41,10 +41,11 @@ public:
|
||||
// functions in reverse order.
|
||||
auto &CG = CGA->getCallGraph();
|
||||
auto GS = GenericSpecializer(getModule());
|
||||
GS.addApplyInst(CG.getBottomUpFunctionOrder());
|
||||
|
||||
// Try to specialize generic calls.
|
||||
if (GS.specialize()) {
|
||||
bool Changed = GS.specialize(CG.getBottomUpFunctionOrder());
|
||||
|
||||
if (Changed) {
|
||||
// Schedule another iteration of the transformation pipe.
|
||||
PM->scheduleAnotherIteration();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user