SILOptimizer: fix a compile time problem in the inliner

When inlining many functions in a very large basic block, the splitting of the block at the call sites is quadratic, when traversing in forward order.
Traversing backwards, fixes the problem.

rdar://problem/56268570
This commit is contained in:
Erik Eckstein
2020-04-07 14:44:58 +02:00
parent fdb52061cc
commit 756c7f9c49

View File

@@ -915,7 +915,9 @@ bool SILPerformanceInliner::inlineCallsIntoFunction(SILFunction *Caller) {
return false;
// Second step: do the actual inlining.
for (auto AI : AppliesToInline) {
// We inline in reverse order, because for very large blocks with many applies
// to inline, splitting the block at every apply would be quadratic.
for (auto AI : llvm::reverse(AppliesToInline)) {
SILFunction *Callee = AI.getReferencedFunctionOrNull();
assert(Callee && "apply_inst does not have a direct callee anymore");