xref: /llvm-project/llvm/test/Transforms/PGOProfile/thinlto_cspgo_gen.ll (revision 443e2a10f69caeedb9fa621366b16fe0d4358279)
1; REQUIRES: x86-registered-target
2
3; RUN: opt -passes='thinlto-pre-link<O2>' --cs-profilegen-file=alloc -cspgo-kind=cspgo-instr-gen-pipeline -module-summary %s -o %t1.bc
4; RUN: opt -passes='thinlto-pre-link<O2>' --cs-profilegen-file=alloc -cspgo-kind=cspgo-instr-gen-pipeline -module-summary %S/Inputs/thinlto_cspgo_bar_gen.ll -o %t2.bc
5; RUN: llvm-lto2 run -lto-cspgo-profile-file=alloc -lto-cspgo-gen -save-temps -o %t %t1.bc %t2.bc \
6; RUN:   -r=%t1.bc,foo,pl \
7; RUN:   -r=%t1.bc,bar,l \
8; RUN:   -r=%t1.bc,main,plx \
9; RUN:   -r=%t1.bc,__llvm_profile_filename,plx \
10; RUN:   -r=%t1.bc,__llvm_profile_raw_version,plx \
11; RUN:   -r=%t2.bc,bar,pl \
12; RUN:   -r=%t2.bc,odd,pl \
13; RUN:   -r=%t2.bc,even,pl \
14; RUN:   -r=%t2.bc,__llvm_profile_filename,x \
15; RUN:   -r=%t2.bc,__llvm_profile_raw_version,x
16; RUN: llvm-dis %t.1.4.opt.bc -o - | FileCheck %s --check-prefixes=CSGEN,PREVAILING
17; RUN: llvm-dis %t.2.4.opt.bc -o - | FileCheck %s --check-prefixes=CSGEN,NOPREVAILING
18
19;; Prevailing __llvm_profile_raw_version is kept by LTO.
20; PREVAILING: @__llvm_profile_raw_version = hidden constant i64
21
22;; Non-prevailing __llvm_profile_raw_version is discarded by LTO. Ensure the
23;; declaration is retained.
24; NOPREVAILING: @__llvm_profile_raw_version = external hidden constant i64
25; CSGEN: @__profc_
26; CSGEN: @__profd_
27
28source_filename = "cspgo.c"
29target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
30target triple = "x86_64-unknown-linux-gnu"
31
32define dso_local void @foo() #0 !prof !29 {
33entry:
34  br label %for.body
35
36for.body:
37  %i.06 = phi i32 [ 0, %entry ], [ %add1, %for.body ]
38  tail call void @bar(i32 %i.06)
39  %add = or i32 %i.06, 1
40  tail call void @bar(i32 %add)
41  %add1 = add nuw nsw i32 %i.06, 2
42  %cmp = icmp ult i32 %add1, 200000
43  br i1 %cmp, label %for.body, label %for.end, !prof !30
44
45for.end:
46  ret void
47}
48
49declare dso_local void @bar(i32)
50
51define dso_local i32 @main() !prof !29 {
52entry:
53  tail call void @foo()
54  ret i32 0
55}
56
57attributes #0 = { "target-cpu"="x86-64" }
58
59!llvm.module.flags = !{!0, !1}
60
61!0 = !{i32 1, !"wchar_size", i32 4}
62!1 = !{i32 1, !"ProfileSummary", !2}
63!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
64!3 = !{!"ProfileFormat", !"InstrProf"}
65!4 = !{!"TotalCount", i64 500002}
66!5 = !{!"MaxCount", i64 200000}
67!6 = !{!"MaxInternalCount", i64 100000}
68!7 = !{!"MaxFunctionCount", i64 200000}
69!8 = !{!"NumCounts", i64 6}
70!9 = !{!"NumFunctions", i64 4}
71!10 = !{!"DetailedSummary", !11}
72!11 = !{!12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27}
73!12 = !{i32 10000, i64 200000, i32 1}
74!13 = !{i32 100000, i64 200000, i32 1}
75!14 = !{i32 200000, i64 200000, i32 1}
76!15 = !{i32 300000, i64 200000, i32 1}
77!16 = !{i32 400000, i64 200000, i32 1}
78!17 = !{i32 500000, i64 100000, i32 4}
79!18 = !{i32 600000, i64 100000, i32 4}
80!19 = !{i32 700000, i64 100000, i32 4}
81!20 = !{i32 800000, i64 100000, i32 4}
82!21 = !{i32 900000, i64 100000, i32 4}
83!22 = !{i32 950000, i64 100000, i32 4}
84!23 = !{i32 990000, i64 100000, i32 4}
85!24 = !{i32 999000, i64 100000, i32 4}
86!25 = !{i32 999900, i64 100000, i32 4}
87!26 = !{i32 999990, i64 100000, i32 4}
88!27 = !{i32 999999, i64 1, i32 6}
89!29 = !{!"function_entry_count", i64 1}
90!30 = !{!"branch_weights", i32 100000, i32 1}
91