Files
swift-mirror/test/Profiler/coverage_irgen.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

21 lines
778 B
Swift

// RUN: %target-swift-frontend %s -profile-generate -profile-coverage-mapping -emit-sil -o - -module-name=irgen | %FileCheck %s --check-prefix=SIL
// RUN: %target-swift-frontend %s -profile-generate -profile-coverage-mapping -emit-ir -o - -module-name=irgen | %FileCheck %s --check-prefix=IR
// IR-NOT: __llvm_coverage_names
// IR-NOT: __profn
// SIL: sil hidden @$s5irgen2f1yyF
// SIL: increment_profiler_counter 0, "{{.*}}coverage_irgen.swift:{{.*}}$s5irgen2f1yyF"
internal func f1() {}
// SIL: sil private @$s5irgen2f2[[F2HASH:[_a-zA-Z0-9]+]]
// SIL: increment_profiler_counter 0, "{{.*}}coverage_irgen.swift:$s5irgen2f2[[F2HASH]]"
private func f2() {}
// SIL: sil @$s5irgen2f3yyF
// SIL: increment_profiler_counter 0, "$s5irgen2f3yyF"
public func f3() {
f1()
f2()
}