Files
swift-mirror/test/Profiler/instrprof_basic.swift
Vedant Kumar c3f4d99e57 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.
2018-04-20 15:15:52 -07:00

64 lines
2.2 KiB
Swift

// RUN: %target-swift-frontend -parse-as-library -enable-sil-ownership -emit-silgen -profile-generate %s | %FileCheck %s
// CHECK: sil hidden @[[F_EMPTY:.*empty.*]] :
// CHECK: %[[NAME:.*]] = string_literal utf8 "{{.*}}instrprof_basic.swift:[[F_EMPTY]]"
// CHECK: %[[HASH:.*]] = integer_literal $Builtin.Int64,
// CHECK: %[[NCOUNTS:.*]] = integer_literal $Builtin.Int32, 1
// CHECK: %[[INDEX:.*]] = integer_literal $Builtin.Int32, 0
// CHECK: builtin "int_instrprof_increment"(%[[NAME]] : {{.*}}, %[[HASH]] : {{.*}}, %[[NCOUNTS]] : {{.*}}, %[[INDEX]] : {{.*}})
func empty() {
// CHECK-NOT: builtin "int_instrprof_increment"
}
// CHECK: sil hidden @[[F_BASIC:.*basic.*]] :
// CHECK: %[[NAME:.*]] = string_literal utf8 "{{.*}}instrprof_basic.swift:[[F_BASIC]]"
// CHECK: %[[HASH:.*]] = integer_literal $Builtin.Int64,
// CHECK: %[[NCOUNTS:.*]] = integer_literal $Builtin.Int32, 6
// CHECK: %[[INDEX:.*]] = integer_literal $Builtin.Int32, 0
// CHECK: builtin "int_instrprof_increment"(%[[NAME]] : {{.*}}, %[[HASH]] : {{.*}}, %[[NCOUNTS]] : {{.*}}, %[[INDEX]] : {{.*}})
func basic(a : Int32) {
// CHECK: builtin "int_instrprof_increment"
if a == 0 {
}
// CHECK: builtin "int_instrprof_increment"
if a != 0 {
} else {
}
// CHECK: builtin "int_instrprof_increment"
while a == 0 {
}
// CHECK: builtin "int_instrprof_increment"
for i in 0 ..< a {
}
// CHECK: builtin "int_instrprof_increment"
for i in 1...a {
}
// CHECK-NOT: builtin "int_instrprof_increment"
}
// CHECK: sil hidden @[[F_THROWING_NOP:.*throwing_nop.*]] :
func throwing_nop() throws {}
// CHECK: sil hidden @[[F_EXCEPTIONS:.*exceptions.*]] :
// CHECK: %[[NAME:.*]] = string_literal utf8 "{{.*}}instrprof_basic.swift:[[F_EXCEPTIONS]]"
// CHECK: %[[HASH:.*]] = integer_literal $Builtin.Int64,
// CHECK: %[[NCOUNTS:.*]] = integer_literal $Builtin.Int32, 3
// CHECK: %[[INDEX:.*]] = integer_literal $Builtin.Int32, 0
// CHECK: builtin "int_instrprof_increment"(%[[NAME]] : {{.*}}, %[[HASH]] : {{.*}}, %[[NCOUNTS]] : {{.*}}, %[[INDEX]] : {{.*}})
func exceptions() {
do {
try throwing_nop()
// CHECK: builtin "int_instrprof_increment"
} catch {
// CHECK: builtin "int_instrprof_increment"
return
}
// CHECK-NOT: builtin "int_instrprof_increment"
}