mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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.
This commit is contained in:
@@ -1,20 +0,0 @@
|
|||||||
// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -profile-generate -profile-coverage-mapping -emit-sil -o - | %FileCheck %s --check-prefix=SIL
|
|
||||||
// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -profile-generate -profile-coverage-mapping -emit-ir -o - | %FileCheck %s --check-prefix=IR
|
|
||||||
|
|
||||||
// IR-NOT: __llvm_coverage_names
|
|
||||||
// IR-NOT: __profn
|
|
||||||
|
|
||||||
// SIL-DAG: sil hidden @$S8coverage2f1yyF
|
|
||||||
// SIL-DAG: string_literal utf8 "{{.*}}coverage.swift:{{.*}}$S8coverage2f1yyF"
|
|
||||||
internal func f1() {}
|
|
||||||
|
|
||||||
// SIL-DAG: sil private @$S8coverage2f233_[[F2HASH:[_a-zA-Z0-9]+]]
|
|
||||||
// SIL-DAG: string_literal utf8 "{{.*}}coverage.swift:$S8coverage2f233_[[F2HASH]]"
|
|
||||||
private func f2() {}
|
|
||||||
|
|
||||||
// SIL-DAG: sil @$S8coverage2f3yyF
|
|
||||||
// SIL-DAG: string_literal utf8 "$S8coverage2f3yyF"
|
|
||||||
public func f3() {
|
|
||||||
f1();
|
|
||||||
f2();
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,44 @@
|
|||||||
// 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
|
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -profile-generate -profile-coverage-mapping -emit-sil -module-name coverage_closures %s | %FileCheck %s
|
||||||
|
|
||||||
|
func bar(arr: [(Int32) -> Int32]) {
|
||||||
|
// CHECK-LABEL: sil_coverage_map {{.*}}// closure #2 (Swift.Int32) -> Swift.Int32 in coverage_closures.bar
|
||||||
|
// CHECK-NEXT: [[@LINE+1]]:13 -> [[@LINE+1]]:42 : 0
|
||||||
|
for a in [{ (b : Int32) -> Int32 in b }] {
|
||||||
|
a(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func foo() {
|
||||||
|
// CHECK-LABEL: sil_coverage_map {{.*}}// closure #1 (Swift.Int32, Swift.Int32) -> Swift.Bool in coverage_closures.foo()
|
||||||
|
// CHECK-NEXT: [[@LINE+1]]:12 -> [[@LINE+1]]:59 : 0
|
||||||
|
let c1 = { (i1 : Int32, i2 : Int32) -> Bool in i1 < i2 }
|
||||||
|
|
||||||
|
// CHECK-LABEL: sil_coverage_map {{.*}}// f1 #1 ((Swift.Int32, Swift.Int32) -> Swift.Bool) -> Swift.Bool in coverage_closures.foo()
|
||||||
|
// CHECK-NEXT: [[@LINE+1]]:55 -> {{.*}}:4 : 0
|
||||||
|
func f1(_ closure : (Int32, Int32) -> Bool) -> Bool {
|
||||||
|
// CHECK-LABEL: sil_coverage_map {{.*}}// implicit closure #1 : @autoclosure () throws -> Swift.Bool in f1
|
||||||
|
// CHECK-NEXT: [[@LINE+1]]:29 -> [[@LINE+1]]:42 : 0
|
||||||
|
return closure(0, 1) && closure(1, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
f1(c1)
|
||||||
|
|
||||||
|
// CHECK-LABEL: sil_coverage_map {{.*}}// closure #2 (Swift.Int32, Swift.Int32) -> Swift.Bool in coverage_closures.foo()
|
||||||
|
// CHECK-NEXT: [[@LINE+1]]:6 -> [[@LINE+1]]:27 : 0
|
||||||
|
f1 { i1, i2 in i1 > i2 }
|
||||||
|
|
||||||
|
// CHECK-LABEL: sil_coverage_map {{.*}}// closure #3 (Swift.Int32, Swift.Int32) -> Swift.Bool in coverage_closures.foo()
|
||||||
|
// CHECK-NEXT: [[@LINE+3]]:6 -> [[@LINE+3]]:48 : 0
|
||||||
|
// CHECK-LABEL: sil_coverage_map {{.*}}// implicit closure #1 : @autoclosure () throws -> {{.*}} in coverage_closures.foo
|
||||||
|
// CHECK-NEXT: [[@LINE+1]]:36 -> [[@LINE+1]]:46 : 0
|
||||||
|
f1 { left, right in left == 0 || right == 1 }
|
||||||
|
}
|
||||||
|
|
||||||
|
// SR-2615: Implicit constructor decl has no body, and shouldn't be mapped
|
||||||
|
struct C1 {
|
||||||
|
// CHECK-NOT: sil_coverage_map{{.*}}errors
|
||||||
|
private var errors = [String]()
|
||||||
|
}
|
||||||
|
|
||||||
// rdar://39200851: Closure in init method covered twice
|
// rdar://39200851: Closure in init method covered twice
|
||||||
|
|
||||||
@@ -12,60 +52,3 @@ class C2 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CHECK-LABEL: sil_coverage_map {{.*}}// coverage_closures.bar
|
|
||||||
// CHECK-NEXT: [[@LINE+9]]:35 -> [[@LINE+13]]:2 : 0
|
|
||||||
// CHECK-NEXT: [[@LINE+9]]:44 -> [[@LINE+11]]:4 : 1
|
|
||||||
// CHECK-NEXT: [[@LINE+10]]:4 -> [[@LINE+11]]:2 : 0
|
|
||||||
// CHECK-NEXT: }
|
|
||||||
|
|
||||||
// CHECK-LABEL: sil_coverage_map {{.*}}// closure #2 (Swift.Int32) -> Swift.Int32 in coverage_closures.bar
|
|
||||||
// CHECK-NEXT: [[@LINE+4]]:13 -> [[@LINE+4]]:42 : 0
|
|
||||||
// CHECK-NEXT: }
|
|
||||||
|
|
||||||
func bar(arr: [(Int32) -> Int32]) {
|
|
||||||
for a in [{ (b : Int32) -> Int32 in b }] {
|
|
||||||
a(0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// CHECK-LABEL: sil_coverage_map {{.*}}// coverage_closures.foo
|
|
||||||
func foo() {
|
|
||||||
let c1 = { (i1 : Int32, i2 : Int32) -> Bool in i1 < i2 }
|
|
||||||
|
|
||||||
// CHECK-LABEL: sil_coverage_map {{.*}}// f1 #1 ((Swift.Int32, Swift.Int32) -> Swift.Bool) -> Swift.Bool in coverage_closures.foo()
|
|
||||||
// CHECK-NEXT: [[@LINE+5]]:55 -> [[@LINE+7]]:4 : 0
|
|
||||||
// CHECK-NEXT: }
|
|
||||||
|
|
||||||
// CHECK-LABEL: sil_coverage_map {{.*}}// implicit closure #1 : @autoclosure () throws -> Swift.Bool in f1
|
|
||||||
// CHECK-NEXT: [[@LINE+2]]:29 -> [[@LINE+2]]:42 : 0
|
|
||||||
func f1(_ closure : (Int32, Int32) -> Bool) -> Bool {
|
|
||||||
return closure(0, 1) && closure(1, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
f1(c1)
|
|
||||||
|
|
||||||
// CHECK-LABEL: sil_coverage_map {{.*}}// closure #2 (Swift.Int32, Swift.Int32) -> Swift.Bool in coverage_closures.foo()
|
|
||||||
// CHECK-NEXT: [[@LINE+1]]:6 -> [[@LINE+1]]:27 : 0
|
|
||||||
f1 { i1, i2 in i1 > i2 }
|
|
||||||
|
|
||||||
// CHECK-LABEL: sil_coverage_map {{.*}}// closure #3 (Swift.Int32, Swift.Int32) -> Swift.Bool in coverage_closures.foo()
|
|
||||||
// CHECK-NEXT: [[@LINE+5]]:6 -> [[@LINE+5]]:48 : 0
|
|
||||||
// CHECK-NEXT: }
|
|
||||||
|
|
||||||
// CHECK-LABEL: sil_coverage_map {{.*}}// implicit closure #1 : @autoclosure () throws -> {{.*}} in coverage_closures.foo
|
|
||||||
// CHECK-NEXT: [[@LINE+1]]:36 -> [[@LINE+1]]:46 : 0
|
|
||||||
f1 { left, right in left == 0 || right == 1 }
|
|
||||||
}
|
|
||||||
// CHECK-LABEL: sil_coverage_map {{.*}}// closure #1 (Swift.Int32, Swift.Int32) -> Swift.Bool in coverage_closures.foo()
|
|
||||||
// CHECK-NEXT: [[@LINE-27]]:12 -> [[@LINE-27]]:59 : 0
|
|
||||||
|
|
||||||
// SR-2615: Implicit constructor decl has no body, and shouldn't be mapped
|
|
||||||
struct C1 {
|
|
||||||
// CHECK-NOT: sil_coverage_map{{.*}}errors
|
|
||||||
private var errors = [String]()
|
|
||||||
}
|
|
||||||
|
|
||||||
bar(arr: [{ x in x }])
|
|
||||||
foo()
|
|
||||||
let _ = C2()
|
|
||||||
20
test/Profiler/coverage_irgen.swift
Normal file
20
test/Profiler/coverage_irgen.swift
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
// 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
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// IR-NOT: __llvm_coverage_names
|
||||||
|
// IR-NOT: __profn
|
||||||
|
|
||||||
|
// SIL: sil hidden @$S5irgen2f1yyF
|
||||||
|
// SIL: string_literal utf8 "{{.*}}coverage_irgen.swift:{{.*}}$S5irgen2f1yyF"
|
||||||
|
internal func f1() {}
|
||||||
|
|
||||||
|
// SIL: sil private @$S5irgen2f2[[F2HASH:[_a-zA-Z0-9]+]]
|
||||||
|
// SIL: string_literal utf8 "{{.*}}coverage_irgen.swift:$S5irgen2f2[[F2HASH]]"
|
||||||
|
private func f2() {}
|
||||||
|
|
||||||
|
// SIL: sil @$S5irgen2f3yyF
|
||||||
|
// SIL: string_literal utf8 "$S5irgen2f3yyF"
|
||||||
|
public func f3() {
|
||||||
|
f1()
|
||||||
|
f2()
|
||||||
|
}
|
||||||
27
test/Profiler/coverage_primary_file.swift
Normal file
27
test/Profiler/coverage_primary_file.swift
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
// 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
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// ALL: sil_coverage_map {{.*}} // closure #1 () -> Swift.Int in coverage_primary_file.Box.x.getter : Swift.Int
|
||||||
|
// ALL: sil_coverage_map {{.*}} // coverage_primary_file.Box.init(y: Swift.Int) -> coverage_primary_file.Box
|
||||||
|
// ALL: sil_coverage_map {{.*}} // coverage_primary_file.Box.init(z: Swift.String) -> coverage_primary_file.Box
|
||||||
|
// ALL: sil_coverage_map {{.*}} // coverage_primary_file.main() -> ()
|
||||||
|
// ALL: sil_coverage_map {{.*}} // __ntd_Box
|
||||||
|
|
||||||
|
// PRIMARY-NOT: sil_coverage_map
|
||||||
|
// PRIMARY: sil_coverage_map {{.*}} // coverage_primary_file.Box.init(y: Swift.Int) -> coverage_primary_file.Box
|
||||||
|
// PRIMARY: sil_coverage_map {{.*}} // coverage_primary_file.Box.init(z: Swift.String) -> coverage_primary_file.Box
|
||||||
|
// PRIMARY: sil_coverage_map {{.*}} // coverage_primary_file.main() -> ()
|
||||||
|
// PRIMARY-NOT: sil_coverage_map
|
||||||
|
|
||||||
|
extension Box {
|
||||||
|
init(y: Int) { self.init() }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Box {
|
||||||
|
init(z: String) { self.init() }
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var b = Box()
|
||||||
|
let _ = b.x
|
||||||
|
}
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -profile-generate -profile-coverage-mapping -emit-sorted-sil -emit-sil -module-name coverage_decls %s %S/Inputs/coverage_imports.swift | %FileCheck %s -check-prefix=ALL
|
|
||||||
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -profile-generate -profile-coverage-mapping -emit-sorted-sil -emit-sil -module-name coverage_decls -primary-file %s %S/Inputs/coverage_imports.swift | %FileCheck %s -check-prefix=PRIMARY
|
|
||||||
|
|
||||||
// ALL: sil_coverage_map {{.*}} // closure #1 () -> Swift.Int in coverage_decls.Box.x.getter : Swift.Int
|
|
||||||
// ALL: sil_coverage_map {{.*}} // coverage_decls.Box.init(y: Swift.Int) -> coverage_decls.Box
|
|
||||||
// ALL: sil_coverage_map {{.*}} // coverage_decls.Box.init(z: Swift.String) -> coverage_decls.Box
|
|
||||||
// ALL: sil_coverage_map {{.*}} // coverage_decls.main() -> ()
|
|
||||||
// ALL: sil_coverage_map {{.*}} // __ntd_Box
|
|
||||||
|
|
||||||
// PRIMARY-NOT: sil_coverage_map
|
|
||||||
// PRIMARY: sil_coverage_map {{.*}} // coverage_decls.Box.init(y: Swift.Int) -> coverage_decls.Box
|
|
||||||
// PRIMARY: sil_coverage_map {{.*}} // coverage_decls.Box.init(z: Swift.String) -> coverage_decls.Box
|
|
||||||
// PRIMARY: sil_coverage_map {{.*}} // coverage_decls.main() -> ()
|
|
||||||
// PRIMARY-NOT: sil_coverage_map
|
|
||||||
|
|
||||||
extension Box {
|
|
||||||
init(y: Int) { self.init() }
|
|
||||||
}
|
|
||||||
|
|
||||||
extension Box {
|
|
||||||
init(z: String) { self.init() }
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
var b = Box()
|
|
||||||
let _ = b.x
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user