Skip to content

Commit 756c7f9

Browse files
committed
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
1 parent fdb5206 commit 756c7f9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/SILOptimizer/Transforms/PerformanceInliner.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,9 @@ bool SILPerformanceInliner::inlineCallsIntoFunction(SILFunction *Caller) {
915915
return false;
916916

917917
// Second step: do the actual inlining.
918-
for (auto AI : AppliesToInline) {
918+
// We inline in reverse order, because for very large blocks with many applies
919+
// to inline, splitting the block at every apply would be quadratic.
920+
for (auto AI : llvm::reverse(AppliesToInline)) {
919921
SILFunction *Callee = AI.getReferencedFunctionOrNull();
920922
assert(Callee && "apply_inst does not have a direct callee anymore");
921923

0 commit comments

Comments
 (0)