|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: split-file %s %t |
| 3 | + |
| 4 | +// ---------------------------------------- |
| 5 | +// Test the -profile-sample-use= flag using bogus data, to ensure it's actually |
| 6 | +// reaching LLVM in the expected way. |
| 7 | + |
| 8 | +// RUN: %target-swift-frontend %t/program.swift -module-name test -emit-ir \ |
| 9 | +// RUN: -O -profile-sample-use=%t/profile.txt -o %t/has-data.ll |
| 10 | + |
| 11 | +// RUN: %FileCheck %s < %t/has-data.ll |
| 12 | + |
| 13 | +// CHECK: define{{.*}} @"$s4test8anythingyyF"() #[[ATTRID:[0-9]+]] |
| 14 | +// CHECK: attributes #[[ATTRID]] = {{.*}} "use-sample-profile" |
| 15 | + |
| 16 | +// CHECK-LABEL: !llvm.module.flags |
| 17 | +// CHECK: !{!"ProfileFormat", !"SampleProfile"} |
| 18 | +// CHECK: !{!"TotalCount", i64 2001} |
| 19 | + |
| 20 | +// ---------------------------------------- |
| 21 | +// Now, test cases where there there should not be any profile metadata, |
| 22 | +// such as when no data is provided |
| 23 | + |
| 24 | +// RUN: %target-swift-frontend %t/program.swift -module-name test -emit-ir \ |
| 25 | +// RUN: -O -o %t/no-data.ll |
| 26 | + |
| 27 | +// RUN: %FileCheck --check-prefix CHECK-NODATA %s < %t/no-data.ll |
| 28 | + |
| 29 | + |
| 30 | +// CHECK-NODATA: define{{.*}} @"$s4test8anythingyyF"() #[[ATTRID:[0-9]+]] |
| 31 | +// CHECK-NODATA-NOT: attributes #[[ATTRID]] = {{.*}} "use-sample-profile" |
| 32 | + |
| 33 | +// CHECK-NODATA-LABEL: !llvm.module.flags |
| 34 | +// CHECK-NODATA-NOT: Profile |
| 35 | + |
| 36 | + |
| 37 | +//--- program.swift |
| 38 | +public func anything() {} |
| 39 | + |
| 40 | + |
| 41 | +//--- profile.txt |
| 42 | +bar:100:100 |
| 43 | + 1: 2001 |
0 commit comments