Files
swift-mirror/test/SILOptimizer/pass_profiling.sil
Erik Eckstein c9c4e10e0d SILOptimizer: add an option to profile and measure the runtime of optimization passes.
When enabling the option `-sil-opt-profile-repeat=<n>`, the optimizer runs passes n times and reports the total runtime at the end of the pass pipeline.
This is useful to profile a specific optimization pass with `sil-opt`.
For example, to profile the stack promotion pass:
```
  sil-opt -stack-promotion -sil-opt-profile-repeat=10000 -o /dev/null test.sil
```
2022-07-27 17:50:03 +02:00

28 lines
509 B
Plaintext

// RUN: %target-sil-opt -stack-promotion -sil-opt-profile-repeat=10 %s -o /dev/null 2>&1 | %FileCheck %s
// REQUIRES: swift_in_compiler
// CHECK: {{.*}} ms: total runtime of all passes
sil_stage canonical
import Builtin
import Swift
import SwiftShims
class XX {
@_hasStorage var x: Int32
init()
}
sil @simple_promote : $@convention(thin) () -> Int32 {
bb0:
%o1 = alloc_ref $XX
%l1 = ref_element_addr %o1 : $XX, #XX.x
%l2 = load %l1 : $*Int32
strong_release %o1 : $XX
return %l2 : $Int32
}