Skip to content

Commit 39194a8

Browse files
committed
[Coverage] Test lowering of ill-formed SIL profiling intrinsics
This adds a test case to exercise a path in IRGen which discards ill-formed profiling intrinsics. rdar://40133800 & r://39146527
1 parent e7b55a1 commit 39194a8

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil %s -profile-generate -profile-coverage-mapping -emit-ir -o - -module-name=irgen | %FileCheck %s
2+
3+
// CHECK-NOT: @__llvm_coverage_mapping
4+
5+
sil_stage canonical
6+
7+
import Builtin
8+
import Swift
9+
import SwiftShims
10+
11+
// main
12+
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
13+
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
14+
%2 = string_literal utf8 "<stdin>:__tlcd_line:1:1" // user: %6
15+
%3 = integer_literal $Builtin.Int64, 0 // user: %6
16+
%4 = integer_literal $Builtin.Int32, 2 // user: %6
17+
%5 = integer_literal $Builtin.Int32, 0 // user: %6
18+
19+
// Pass an invalid SIL value to the int_instrprof_increment intrinsic
20+
// to force IRGen to drop it.
21+
%6 = builtin "int_instrprof_increment"(%3 : $Builtin.Int64, %3 : $Builtin.Int64, %4 : $Builtin.Int32, %5 : $Builtin.Int32) : $()
22+
23+
return %0 : $Int32 // id: %33
24+
} // end sil function 'main'
25+
26+
sil_coverage_map "<stdin>" "__tlcd_line:1:1" "<stdin>:__tlcd_line:1:1" 0 { // __tlcd_line:1:1
27+
1:19 -> 1:20 : 1
28+
1:23 -> 1:24 : (0 - 1)
29+
1:1 -> 1:24 : 0
30+
}

0 commit comments

Comments
 (0)