Files
swift-mirror/test/Profiler/coverage_deinit.swift
Hamish Knight c3b055a9a8 [Profiler] Improve if statement coverage
Fix counters for regions following `else if`s, fix
the counters for `else if` conditions, and fix
handling of `break` statements. Also while here,
clean up the handling of branch exit regions such
that we don't generate multiple overlapping
regions for each branch, but a single region at
the end of the entire `if` statement that accounts
for all exiting control flow.

rdar://104078910
rdar://104079242
2023-12-04 11:09:01 +00:00

25 lines
915 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: }