| Dehao Chen | f0e27e6 | 2017-08-24 21:37:04 +0000 | [diff] [blame] | 1 | ; For SamplePGO, if -profile-sample-accurate is specified, cold callsite |
| Dehao Chen | b2d1de5 | 2017-08-23 23:19:11 +0000 | [diff] [blame] | 2 | ; heuristics should be honored if the caller has no profile. |
| 3 | |
| 4 | ; RUN: opt < %s -inline -S -inline-cold-callsite-threshold=0 | FileCheck %s |
| Dehao Chen | b2d1de5 | 2017-08-23 23:19:11 +0000 | [diff] [blame] | 5 | |
| 6 | define i32 @callee(i32 %x) { |
| 7 | %x1 = add i32 %x, 1 |
| 8 | %x2 = add i32 %x1, 1 |
| 9 | %x3 = add i32 %x2, 1 |
| 10 | call void @extern() |
| 11 | call void @extern() |
| 12 | ret i32 %x3 |
| 13 | } |
| 14 | |
| 15 | define i32 @caller(i32 %y1) { |
| Dehao Chen | f0e27e6 | 2017-08-24 21:37:04 +0000 | [diff] [blame] | 16 | ; CHECK-LABEL: @caller |
| Dehao Chen | b2d1de5 | 2017-08-23 23:19:11 +0000 | [diff] [blame] | 17 | ; CHECK-NOT: call i32 @callee |
| Dehao Chen | f0e27e6 | 2017-08-24 21:37:04 +0000 | [diff] [blame] | 18 | %y2 = call i32 @callee(i32 %y1) |
| 19 | ret i32 %y2 |
| 20 | } |
| 21 | |
| 22 | define i32 @caller_accurate(i32 %y1) #0 { |
| 23 | ; CHECK-LABEL: @caller_accurate |
| 24 | ; CHECK: call i32 @callee |
| Dehao Chen | b2d1de5 | 2017-08-23 23:19:11 +0000 | [diff] [blame] | 25 | %y2 = call i32 @callee(i32 %y1) |
| 26 | ret i32 %y2 |
| 27 | } |
| 28 | |
| 29 | declare void @extern() |
| 30 | |
| Dehao Chen | f0e27e6 | 2017-08-24 21:37:04 +0000 | [diff] [blame] | 31 | attributes #0 = { "profile-sample-accurate" } |
| 32 | |
| Dehao Chen | b2d1de5 | 2017-08-23 23:19:11 +0000 | [diff] [blame] | 33 | !llvm.module.flags = !{!1} |
| 34 | !1 = !{i32 1, !"ProfileSummary", !2} |
| 35 | !2 = !{!3, !4, !5, !6, !7, !8, !9, !10} |
| 36 | !3 = !{!"ProfileFormat", !"SampleProfile"} |
| 37 | !4 = !{!"TotalCount", i64 10000} |
| 38 | !5 = !{!"MaxCount", i64 1000} |
| 39 | !6 = !{!"MaxInternalCount", i64 1} |
| 40 | !7 = !{!"MaxFunctionCount", i64 1000} |
| 41 | !8 = !{!"NumCounts", i64 3} |
| 42 | !9 = !{!"NumFunctions", i64 3} |
| 43 | !10 = !{!"DetailedSummary", !11} |
| 44 | !11 = !{!12, !13, !14} |
| 45 | !12 = !{i32 10000, i64 100, i32 1} |
| 46 | !13 = !{i32 999000, i64 100, i32 1} |
| 47 | !14 = !{i32 999999, i64 1, i32 2} |