mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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
25 lines
948 B
Swift
25 lines
948 B
Swift
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -suppress-warnings -profile-generate -profile-coverage-mapping -emit-sorted-sil -emit-sil -module-name coverage_deinit %s | %FileCheck %s
|
|
// RUN: %target-swift-frontend -profile-generate -profile-coverage-mapping -emit-ir %s
|
|
|
|
func foo() {}
|
|
|
|
public class Foo {
|
|
// CHECK-LABEL: sil @$s15coverage_deinit3FooCfd
|
|
// CHECK: increment_profiler_counter 0
|
|
// CHECK: function_ref @$sSb6randomSbyFZ
|
|
// CHECK: cond_br
|
|
// CHECK: increment_profiler_counter 1
|
|
// CHECK-NEXT: // function_ref coverage_deinit.foo() -> ()
|
|
deinit {
|
|
if .random() {
|
|
foo()
|
|
}
|
|
}
|
|
}
|
|
|
|
// CHECK-LABEL: sil_coverage_map "{{.*}}coverage_deinit.swift" "$s15coverage_deinit3FooCfd"
|
|
// CHECK-NEXT: [[@LINE-8]]:10 -> [[@LINE-4]]:4 : 0
|
|
// CHECK-NEXT: [[@LINE-8]]:8 -> [[@LINE-8]]:17 : 0
|
|
// CHECK-NEXT: [[@LINE-9]]:18 -> [[@LINE-7]]:6 : 1
|
|
// CHECK-NEXT: [[@LINE-8]]:6 -> [[@LINE-7]]:4 : 0
|