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:
Justin Bogner
2015-02-13 08:42:15 +00:00
parent 186f03346a
commit d44090d29e
13 changed files with 614 additions and 3 deletions

View 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()