Skip to content

Commit 8de89c3

Browse files
committed
Add a scale-test validation test for quadratic behavior during inlining.
Adds a stat to SILInstruction's transferNodesFromList to record the number of times an instruction is transfered to another block. This is the only way I can think of to detect quadratic behavior of passes that split basic blocks.
1 parent 702981f commit 8de89c3

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

include/swift/Basic/Statistic.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
#include <thread>
2222
#include <tuple>
2323

24-
#define SWIFT_FUNC_STAT \
24+
#define SWIFT_FUNC_STAT SWIFT_FUNC_STAT_NAMED(DEBUG_TYPE)
25+
26+
#define SWIFT_FUNC_STAT_NAMED(DEBUG_TYPE) \
2527
do { \
2628
static llvm::Statistic FStat = \
2729
{DEBUG_TYPE, __func__, __func__, {0}, {false}}; \

lib/SIL/SILInstruction.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ transferNodesFromList(llvm::ilist_traits<SILInstruction> &L2,
8686
if (ThisParent == L2.getContainingBlock()) return;
8787

8888
// Update the parent fields in the instructions.
89-
for (; first != last; ++first)
89+
for (; first != last; ++first) {
90+
SWIFT_FUNC_STAT_NAMED("sil");
9091
first->ParentBB = ThisParent;
92+
}
9193
}
9294

9395
//===----------------------------------------------------------------------===//
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %scale-test -Onone --begin 0 --end 10 --step 1 --select transferNodesFromList %s
2+
// REQUIRES: OS=macosx
3+
// REQUIRES: asserts
4+
5+
// Test that mandatory inlining is linear on a long series of integer
6+
// initialization calls.
7+
8+
let _: [Int] = [
9+
%for i in range(0, N):
10+
1,
11+
%end
12+
1
13+
]

0 commit comments

Comments
 (0)