Files
swift-mirror/test/Profiler/instrprof_basic.swift
Hamish Knight b12015c343 [SIL] Introduce the increment_profiler_counter instruction
This is a dedicated instruction for incrementing a
profiler counter, which lowers to the
`llvm.instrprof.increment` intrinsic. This
replaces the builtin instruction that was
previously used, and ensures that its arguments
are statically known. This ensures that SIL
optimization passes do not invalidate the
instruction, fixing some code coverage cases in
`-O`.

rdar://39146527
2022-09-07 17:55:13 +01:00

51 lines
1.3 KiB
Swift

// RUN: %target-swift-frontend -parse-as-library -emit-silgen -profile-generate %s | %FileCheck %s
// CHECK: sil hidden [ossa] @[[F_EMPTY:.*empty.*]] :
// CHECK: increment_profiler_counter 0, "{{.*}}instrprof_basic.swift:[[F_EMPTY]]", num_counters 1, hash
func empty() {
// CHECK-NOT: increment_profiler_counter
}
// CHECK: sil hidden [ossa] @[[F_BASIC:.*basic.*]] :
// CHECK: increment_profiler_counter 0, "{{.*}}instrprof_basic.swift:[[F_BASIC]]", num_counters 6, hash
func basic(a : Int32) {
// CHECK: increment_profiler_counter
if a == 0 {
}
// CHECK: increment_profiler_counter
if a != 0 {
} else {
}
// CHECK: increment_profiler_counter
while a == 0 {
}
// CHECK: increment_profiler_counter
for i in 0 ..< a {
}
// CHECK: increment_profiler_counter
for i in 1...a {
}
// CHECK-NOT: increment_profiler_counter
}
// CHECK: sil hidden [ossa] @[[F_THROWING_NOP:.*throwing_nop.*]] :
func throwing_nop() throws {}
// CHECK: sil hidden [ossa] @[[F_EXCEPTIONS:.*exceptions.*]] :
// CHECK: increment_profiler_counter 0, "{{.*}}instrprof_basic.swift:[[F_EXCEPTIONS]]", num_counters 2, hash
func exceptions() {
do {
try throwing_nop()
} catch {
// CHECK: increment_profiler_counter
return
}
// CHECK-NOT: increment_profiler_counter
}