Skip to content

Commit c3f4d99

Browse files
authored
Group the the code coverage, profiling, and pgo tests together (#16070)
* Group tests for profiling instrumentation together, NFC This will make it easier to test changes to the code coverage logic. There are a handful of tests which relate to profiling which I have not moved. These include tests for the driver and for the SIL optimizer. It makes more sense to keep those tests where they are. * Rename a test file, NFC This file tests code coverage of primary files, so I've changed the name of the file to reflect that. * Simplify the check lines in a test, NFC This file tests code coverage of closures. It had several check lines which obscured the meaning of the test, and its check lines were in a strange order. Remove the extra checks and disable -emit-sorted-sil.
1 parent c973e63 commit c3f4d99

35 files changed

+68
-85
lines changed

test/IRGen/coverage.swift

-20
This file was deleted.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,23 @@
1-
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -profile-generate -profile-coverage-mapping -emit-sorted-sil -emit-sil -module-name coverage_closures %s | %FileCheck %s
2-
3-
// rdar://39200851: Closure in init method covered twice
4-
5-
class C2 {
6-
init() {
7-
// CHECK-LABEL: sil_coverage_map {{.*}}// closure #1 () -> () in coverage_closures.C2.init()
8-
// CHECK-NEXT: [[@LINE+2]]:13 -> [[@LINE+4]]:6 : 0
9-
// CHECK-NEXT: }
10-
let _ = { () in
11-
print("hello")
12-
}
13-
}
14-
}
15-
16-
// CHECK-LABEL: sil_coverage_map {{.*}}// coverage_closures.bar
17-
// CHECK-NEXT: [[@LINE+9]]:35 -> [[@LINE+13]]:2 : 0
18-
// CHECK-NEXT: [[@LINE+9]]:44 -> [[@LINE+11]]:4 : 1
19-
// CHECK-NEXT: [[@LINE+10]]:4 -> [[@LINE+11]]:2 : 0
20-
// CHECK-NEXT: }
21-
22-
// CHECK-LABEL: sil_coverage_map {{.*}}// closure #2 (Swift.Int32) -> Swift.Int32 in coverage_closures.bar
23-
// CHECK-NEXT: [[@LINE+4]]:13 -> [[@LINE+4]]:42 : 0
24-
// CHECK-NEXT: }
1+
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -profile-generate -profile-coverage-mapping -emit-sil -module-name coverage_closures %s | %FileCheck %s
252

263
func bar(arr: [(Int32) -> Int32]) {
4+
// CHECK-LABEL: sil_coverage_map {{.*}}// closure #2 (Swift.Int32) -> Swift.Int32 in coverage_closures.bar
5+
// CHECK-NEXT: [[@LINE+1]]:13 -> [[@LINE+1]]:42 : 0
276
for a in [{ (b : Int32) -> Int32 in b }] {
287
a(0)
298
}
309
}
3110

32-
// CHECK-LABEL: sil_coverage_map {{.*}}// coverage_closures.foo
3311
func foo() {
12+
// CHECK-LABEL: sil_coverage_map {{.*}}// closure #1 (Swift.Int32, Swift.Int32) -> Swift.Bool in coverage_closures.foo()
13+
// CHECK-NEXT: [[@LINE+1]]:12 -> [[@LINE+1]]:59 : 0
3414
let c1 = { (i1 : Int32, i2 : Int32) -> Bool in i1 < i2 }
3515

3616
// CHECK-LABEL: sil_coverage_map {{.*}}// f1 #1 ((Swift.Int32, Swift.Int32) -> Swift.Bool) -> Swift.Bool in coverage_closures.foo()
37-
// CHECK-NEXT: [[@LINE+5]]:55 -> [[@LINE+7]]:4 : 0
38-
// CHECK-NEXT: }
39-
40-
// CHECK-LABEL: sil_coverage_map {{.*}}// implicit closure #1 : @autoclosure () throws -> Swift.Bool in f1
41-
// CHECK-NEXT: [[@LINE+2]]:29 -> [[@LINE+2]]:42 : 0
17+
// CHECK-NEXT: [[@LINE+1]]:55 -> {{.*}}:4 : 0
4218
func f1(_ closure : (Int32, Int32) -> Bool) -> Bool {
19+
// CHECK-LABEL: sil_coverage_map {{.*}}// implicit closure #1 : @autoclosure () throws -> Swift.Bool in f1
20+
// CHECK-NEXT: [[@LINE+1]]:29 -> [[@LINE+1]]:42 : 0
4321
return closure(0, 1) && closure(1, 0)
4422
}
4523

@@ -50,22 +28,27 @@ func foo() {
5028
f1 { i1, i2 in i1 > i2 }
5129

5230
// CHECK-LABEL: sil_coverage_map {{.*}}// closure #3 (Swift.Int32, Swift.Int32) -> Swift.Bool in coverage_closures.foo()
53-
// CHECK-NEXT: [[@LINE+5]]:6 -> [[@LINE+5]]:48 : 0
54-
// CHECK-NEXT: }
55-
31+
// CHECK-NEXT: [[@LINE+3]]:6 -> [[@LINE+3]]:48 : 0
5632
// CHECK-LABEL: sil_coverage_map {{.*}}// implicit closure #1 : @autoclosure () throws -> {{.*}} in coverage_closures.foo
5733
// CHECK-NEXT: [[@LINE+1]]:36 -> [[@LINE+1]]:46 : 0
5834
f1 { left, right in left == 0 || right == 1 }
5935
}
60-
// CHECK-LABEL: sil_coverage_map {{.*}}// closure #1 (Swift.Int32, Swift.Int32) -> Swift.Bool in coverage_closures.foo()
61-
// CHECK-NEXT: [[@LINE-27]]:12 -> [[@LINE-27]]:59 : 0
6236

6337
// SR-2615: Implicit constructor decl has no body, and shouldn't be mapped
6438
struct C1 {
6539
// CHECK-NOT: sil_coverage_map{{.*}}errors
6640
private var errors = [String]()
6741
}
6842

69-
bar(arr: [{ x in x }])
70-
foo()
71-
let _ = C2()
43+
// rdar://39200851: Closure in init method covered twice
44+
45+
class C2 {
46+
init() {
47+
// CHECK-LABEL: sil_coverage_map {{.*}}// closure #1 () -> () in coverage_closures.C2.init()
48+
// CHECK-NEXT: [[@LINE+2]]:13 -> [[@LINE+4]]:6 : 0
49+
// CHECK-NEXT: }
50+
let _ = { () in
51+
print("hello")
52+
}
53+
}
54+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/Profiler/coverage_irgen.swift

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -profile-generate -profile-coverage-mapping -emit-sil -o - -module-name=irgen | %FileCheck %s --check-prefix=SIL
2+
// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -profile-generate -profile-coverage-mapping -emit-ir -o - -module-name=irgen | %FileCheck %s --check-prefix=IR
3+
4+
// IR-NOT: __llvm_coverage_names
5+
// IR-NOT: __profn
6+
7+
// SIL: sil hidden @$S5irgen2f1yyF
8+
// SIL: string_literal utf8 "{{.*}}coverage_irgen.swift:{{.*}}$S5irgen2f1yyF"
9+
internal func f1() {}
10+
11+
// SIL: sil private @$S5irgen2f2[[F2HASH:[_a-zA-Z0-9]+]]
12+
// SIL: string_literal utf8 "{{.*}}coverage_irgen.swift:$S5irgen2f2[[F2HASH]]"
13+
private func f2() {}
14+
15+
// SIL: sil @$S5irgen2f3yyF
16+
// SIL: string_literal utf8 "$S5irgen2f3yyF"
17+
public func f3() {
18+
f1()
19+
f2()
20+
}
File renamed without changes.
File renamed without changes.
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -profile-generate -profile-coverage-mapping -emit-sorted-sil -emit-sil -module-name coverage_primary_file %s %S/Inputs/coverage_imports.swift | %FileCheck %s -check-prefix=ALL
2+
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -profile-generate -profile-coverage-mapping -emit-sorted-sil -emit-sil -module-name coverage_primary_file -primary-file %s %S/Inputs/coverage_imports.swift | %FileCheck %s -check-prefix=PRIMARY
3+
4+
// ALL: sil_coverage_map {{.*}} // closure #1 () -> Swift.Int in coverage_primary_file.Box.x.getter : Swift.Int
5+
// ALL: sil_coverage_map {{.*}} // coverage_primary_file.Box.init(y: Swift.Int) -> coverage_primary_file.Box
6+
// ALL: sil_coverage_map {{.*}} // coverage_primary_file.Box.init(z: Swift.String) -> coverage_primary_file.Box
7+
// ALL: sil_coverage_map {{.*}} // coverage_primary_file.main() -> ()
8+
// ALL: sil_coverage_map {{.*}} // __ntd_Box
9+
10+
// PRIMARY-NOT: sil_coverage_map
11+
// PRIMARY: sil_coverage_map {{.*}} // coverage_primary_file.Box.init(y: Swift.Int) -> coverage_primary_file.Box
12+
// PRIMARY: sil_coverage_map {{.*}} // coverage_primary_file.Box.init(z: Swift.String) -> coverage_primary_file.Box
13+
// PRIMARY: sil_coverage_map {{.*}} // coverage_primary_file.main() -> ()
14+
// PRIMARY-NOT: sil_coverage_map
15+
16+
extension Box {
17+
init(y: Int) { self.init() }
18+
}
19+
20+
extension Box {
21+
init(z: String) { self.init() }
22+
}
23+
24+
func main() {
25+
var b = Box()
26+
let _ = b.x
27+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/SILGen/coverage_decls.swift

-27
This file was deleted.

0 commit comments

Comments
 (0)