mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
InstrProf: Optionally generate coverage maps when profiling
This adds the -profile-coverage-mapping option to swift, and teaches SILGenProfiling to generate mappings from source ranges to counters. Swift SVN r25266
This commit is contained in:
41
test/SILGen/coverage_while.swift
Normal file
41
test/SILGen/coverage_while.swift
Normal file
@@ -0,0 +1,41 @@
|
||||
// RUN: %target-swift-frontend -profile-generate -profile-coverage-mapping -emit-sorted-sil -emit-sil -module-name coverage_while %s | FileCheck %s
|
||||
|
||||
// CHECK-LABEL: sil_coverage_map {{.*}}// coverage_while.foo
|
||||
func foo() -> Int32 {
|
||||
var x : Int32 = 0
|
||||
// CHECK: [[@LINE+1]]:9 -> [[@LINE+1]]:17 : (0 + 1)
|
||||
while (x < 10) {
|
||||
x++
|
||||
}
|
||||
|
||||
// CHECK: [[@LINE+1]]:9 -> [[@LINE+1]]:18 : (0 + 2)
|
||||
while (--x > 0) {
|
||||
if (x % 2 == 0) { continue }
|
||||
}
|
||||
|
||||
// CHECK: [[@LINE+1]]:9 -> [[@LINE+1]]:18 : ((0 + 4) - 5)
|
||||
while (x < 100) {
|
||||
if (x++ == 10) { break }
|
||||
}
|
||||
|
||||
// CHECK: [[@LINE+1]]:9 -> [[@LINE+1]]:18 : ((0 + 6) - 9)
|
||||
while (x < 100) {
|
||||
x++
|
||||
while (true) { break }
|
||||
if (x % 2 == 0) { continue }
|
||||
// CHECK: [[@LINE-1]]:33 -> [[@LINE+2]]:4 : (6 - 8)
|
||||
if (x > 30) { break }
|
||||
}
|
||||
|
||||
// CHECK: [[@LINE+1]]:9 -> [[@LINE+1]]:18 : ((0 + 10) - 11)
|
||||
while (x < 100) {
|
||||
if (x == 40) { // CHECK: [[@LINE]]:18 -> [[@LINE+2]]:6 : 11
|
||||
return x
|
||||
}
|
||||
++x
|
||||
}
|
||||
// CHECK: [[@LINE-1]]:4 -> [[@LINE+1]]:11 : (0 - 11)
|
||||
return x
|
||||
}
|
||||
|
||||
foo()
|
||||
Reference in New Issue
Block a user