1cee313d2SEric Christopher; REQUIRES: x86-registered-target
2cee313d2SEric Christopher
3cee313d2SEric Christopher; RUN: opt -module-summary %s -o %t1.bc
4cee313d2SEric Christopher; RUN: opt -module-summary %S/Inputs/thinlto_cspgo_bar_use.ll -o %t2.bc
5cee313d2SEric Christopher; RUN: llvm-profdata merge %S/Inputs/thinlto_cs.proftext -o %t3.profdata
650da55a5SRong Xu; RUN: llvm-lto2 run -lto-cspgo-profile-file=%t3.profdata -pgo-instrument-entry=false -save-temps -o %t %t1.bc %t2.bc \
7cee313d2SEric Christopher; RUN:   -r=%t1.bc,foo,pl \
8cee313d2SEric Christopher; RUN:   -r=%t1.bc,bar,l \
9cee313d2SEric Christopher; RUN:   -r=%t1.bc,main,plx \
10cee313d2SEric Christopher; RUN:   -r=%t2.bc,bar,pl \
11*ed9df5bdSFlorian Hahn; RUN:   -r=%t2.bc,clobber,pl \
12cee313d2SEric Christopher; RUN:   -r=%t2.bc,odd,pl \
13cee313d2SEric Christopher; RUN:   -r=%t2.bc,even,pl
14cee313d2SEric Christopher; RUN: llvm-dis %t.1.4.opt.bc -o - | FileCheck %s --check-prefix=CSUSE
15cee313d2SEric Christopher
16cee313d2SEric Christopher; CSUSE: {{![0-9]+}} = !{i32 1, !"ProfileSummary", {{![0-9]+}}}
17cee313d2SEric Christopher; CSUSE: {{![0-9]+}} = !{i32 1, !"CSProfileSummary", {{![0-9]+}}}
185c31b8b9SArthur Eubanks; CSUSE-DAG: {{![0-9]+}} = !{!"branch_weights", i32 100000, i32 0}
195c31b8b9SArthur Eubanks; CSUSE-DAG: {{![0-9]+}} = !{!"branch_weights", i32 0, i32 100000}
20cee313d2SEric Christopher
21cee313d2SEric Christophersource_filename = "cspgo.c"
227b1d7937SAmy Huangtarget datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
23cee313d2SEric Christophertarget triple = "x86_64-unknown-linux-gnu"
24cee313d2SEric Christopher
25cee313d2SEric Christopherdefine dso_local void @foo() #0 !prof !29 {
26cee313d2SEric Christopherentry:
27cee313d2SEric Christopher  br label %for.body
28cee313d2SEric Christopher
29cee313d2SEric Christopherfor.body:
30cee313d2SEric Christopher  %i.06 = phi i32 [ 0, %entry ], [ %add1, %for.body ]
31cee313d2SEric Christopher  tail call void @bar(i32 %i.06)
32cee313d2SEric Christopher  %add = or i32 %i.06, 1
33cee313d2SEric Christopher  tail call void @bar(i32 %add)
34cee313d2SEric Christopher  %add1 = add nuw nsw i32 %i.06, 2
35cee313d2SEric Christopher  %cmp = icmp ult i32 %add1, 200000
36cee313d2SEric Christopher  br i1 %cmp, label %for.body, label %for.end, !prof !30
37cee313d2SEric Christopher
38cee313d2SEric Christopherfor.end:
39cee313d2SEric Christopher  ret void
40cee313d2SEric Christopher}
41cee313d2SEric Christopher
42cee313d2SEric Christopherdeclare dso_local void @bar(i32)
43cee313d2SEric Christopher
44cee313d2SEric Christopherdefine dso_local i32 @main() !prof !29 {
45cee313d2SEric Christopherentry:
46cee313d2SEric Christopher  tail call void @foo()
47cee313d2SEric Christopher  ret i32 0
48cee313d2SEric Christopher}
49cee313d2SEric Christopher
50cee313d2SEric Christopherattributes #0 = { "target-cpu"="x86-64" }
51cee313d2SEric Christopher
52cee313d2SEric Christopher!llvm.module.flags = !{!0, !1}
53cee313d2SEric Christopher
54cee313d2SEric Christopher!0 = !{i32 1, !"wchar_size", i32 4}
55cee313d2SEric Christopher!1 = !{i32 1, !"ProfileSummary", !2}
56cee313d2SEric Christopher!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
57cee313d2SEric Christopher!3 = !{!"ProfileFormat", !"InstrProf"}
58cee313d2SEric Christopher!4 = !{!"TotalCount", i64 500002}
59cee313d2SEric Christopher!5 = !{!"MaxCount", i64 200000}
60cee313d2SEric Christopher!6 = !{!"MaxInternalCount", i64 100000}
61cee313d2SEric Christopher!7 = !{!"MaxFunctionCount", i64 200000}
62cee313d2SEric Christopher!8 = !{!"NumCounts", i64 6}
63cee313d2SEric Christopher!9 = !{!"NumFunctions", i64 4}
64cee313d2SEric Christopher!10 = !{!"DetailedSummary", !11}
65cee313d2SEric Christopher!11 = !{!12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27}
66cee313d2SEric Christopher!12 = !{i32 10000, i64 200000, i32 1}
67cee313d2SEric Christopher!13 = !{i32 100000, i64 200000, i32 1}
68cee313d2SEric Christopher!14 = !{i32 200000, i64 200000, i32 1}
69cee313d2SEric Christopher!15 = !{i32 300000, i64 200000, i32 1}
70cee313d2SEric Christopher!16 = !{i32 400000, i64 200000, i32 1}
71cee313d2SEric Christopher!17 = !{i32 500000, i64 100000, i32 4}
72cee313d2SEric Christopher!18 = !{i32 600000, i64 100000, i32 4}
73cee313d2SEric Christopher!19 = !{i32 700000, i64 100000, i32 4}
74cee313d2SEric Christopher!20 = !{i32 800000, i64 100000, i32 4}
75cee313d2SEric Christopher!21 = !{i32 900000, i64 100000, i32 4}
76cee313d2SEric Christopher!22 = !{i32 950000, i64 100000, i32 4}
77cee313d2SEric Christopher!23 = !{i32 990000, i64 100000, i32 4}
78cee313d2SEric Christopher!24 = !{i32 999000, i64 100000, i32 4}
79cee313d2SEric Christopher!25 = !{i32 999900, i64 100000, i32 4}
80cee313d2SEric Christopher!26 = !{i32 999990, i64 100000, i32 4}
81cee313d2SEric Christopher!27 = !{i32 999999, i64 1, i32 6}
82cee313d2SEric Christopher!29 = !{!"function_entry_count", i64 1}
835c31b8b9SArthur Eubanks!30 = !{!"branch_weights", i32 100000, i32 1}
84