mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +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
27 lines
1.5 KiB
Swift
27 lines
1.5 KiB
Swift
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -profile-generate -profile-coverage-mapping -emit-sil -module-name coverage_force_emission %s | %FileCheck %s -check-prefix=COVERAGE
|
|
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -profile-generate -emit-sil -module-name coverage_force_emission %s | %FileCheck %s -check-prefix=PGO
|
|
// RUN: %target-swift-frontend -profile-generate -profile-coverage-mapping -emit-ir %s
|
|
|
|
final class VarInit {
|
|
// COVERAGE: sil_coverage_map {{.*}} "$s23coverage_force_emission7VarInitC04lazydE033_7D375D72BA8B0C53C9AD7E4DBC7FF493LLSSvgSSyXEfU_"
|
|
// PGO-LABEL: coverage_force_emission.VarInit.(lazyVarInit in _7D375D72BA8B0C53C9AD7E4DBC7FF493).getter : Swift.String
|
|
// PGO: increment_profiler_counter
|
|
private lazy var lazyVarInit: String = {
|
|
return "Hello"
|
|
}()
|
|
|
|
// CHECK: sil_coverage_map {{.*}} "$s23coverage_force_emission7VarInitC05basicdE033_7D375D72BA8B0C53C9AD7E4DBC7FF493LLSSvpfiSSyXEfU_"
|
|
// PGO-LABEL: closure #1 () -> Swift.String in variable initialization expression of coverage_force_emission.VarInit.(basicVarInit in _7D375D72BA8B0C53C9AD7E4DBC7FF493) : Swift.String
|
|
// PGO: increment_profiler_counter
|
|
private var basicVarInit: String = {
|
|
return "Hello"
|
|
}()
|
|
|
|
// CHECK: sil_coverage_map {{.*}} "$s23coverage_force_emission7VarInitC06simpleD033_7D375D72BA8B0C53C9AD7E4DBC7FF493LLSSvg"
|
|
// PGO-LABEL: coverage_force_emission.VarInit.(simpleVar in _7D375D72BA8B0C53C9AD7E4DBC7FF493).getter : Swift.String
|
|
// PGO: increment_profiler_counter
|
|
private var simpleVar: String {
|
|
return "Hello"
|
|
}
|
|
}
|