Skip to content

Commit 90f0744

Browse files
committed
Merge pull request #2020 from eeckstein/add_silcombine
Add SILCombine+SimplifyCFG passes between the ClosureSpecializer (and…
2 parents 0969f27 + dd124ae commit 90f0744

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

lib/SILOptimizer/PassManager/Passes.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,11 @@ void swift::runSILOptimizationPasses(SILModule &Module) {
330330
// Speculate virtual call targets.
331331
PM.addSpeculativeDevirtualization();
332332

333+
// There should be at least one SILCombine+SimplifyCFG between the
334+
// ClosureSpecializer, etc. and the last inliner. Cleaning up after these
335+
// passes can expose more inlining opportunities.
336+
AddSimplifyCFGSILCombine(PM);
337+
333338
// We do this late since it is a pass like the inline caches that we only want
334339
// to run once very late. Make sure to run at least one round of the ARC
335340
// optimizer after this.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %target-swift-frontend -parse-as-library -O -module-name=test %s -emit-sil | FileCheck %s
2+
3+
func closure(a: Int, b: Int) -> Bool {
4+
return a < b
5+
}
6+
7+
// Check that closure() is inlined into call_closure after call_closure is
8+
// specialized for it.
9+
10+
// CHECK-LABEL: sil shared [noinline] @_TTSf1n_n_cl27_TF4test7closureFTSi1bSi_Sb___TF4test12call_closureFTSiSiFTSiSi_Sb_Sb
11+
// CHECK-NOT: apply
12+
// CHECK: builtin "cmp_slt_Int64"
13+
// CHECK-NOT: apply
14+
// CHECK: return
15+
@inline(never)
16+
func call_closure(a: Int, _ b: Int, _ f: (Int , Int) -> Bool) -> Bool {
17+
return f(a, b)
18+
}
19+
20+
public func testit() -> Bool {
21+
return call_closure(0, 1, closure)
22+
}
23+

test/SILOptimizer/devirt_single_module_in_multiple_files.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swiftc_driver -module-name devirt_single_module_in_multiple_files -O %s %S/Inputs/BaseProblem.swift %S/Inputs/Problems.swift -parse-as-library -emit-sil 2>&1 | FileCheck %s
1+
// RUN: %target-swiftc_driver -module-name devirt_single_module_in_multiple_files -O %s %S/Inputs/BaseProblem.swift %S/Inputs/Problems.swift -parse-as-library -Xllvm -sil-disable-pass="Performance Inliner" -emit-sil 2>&1 | FileCheck %s
22

33
public func test() {
44
let e = Evaluator()

0 commit comments

Comments
 (0)