1; Test to check thin link importing stats
2
3; -stats requires asserts
4; REQUIRES: asserts
5
6; REQUIRES: x86-registered-target
7
8; RUN: opt -module-summary %s -o %t.bc
9; RUN: opt -module-summary %p/Inputs/import_stats.ll -o %t2.bc
10
11; Test thin link stats with both new and old LTO
12; RUN: llvm-lto -thinlto-action=run -stats %t.bc %t2.bc \
13; RUN:		2>&1 | FileCheck %s --check-prefix=THINLINKSTATS
14; RUN: llvm-lto2 run -stats -o %t3 %t.bc %t2.bc \
15; RUN:          -r %t.bc,hot_function,plx \
16; RUN:          -r %t.bc,hot, \
17; RUN:          -r %t.bc,critical, \
18; RUN:          -r %t.bc,none, \
19; RUN:          -r %t2.bc,hot,plx \
20; RUN:          -r %t2.bc,critical,plx \
21; RUN:          -r %t2.bc,none,plx \
22; RUN:          -r %t2.bc,globalvar,plx \
23; RUN:          2>&1 | FileCheck %s --check-prefix=THINLINKSTATS
24
25; THINLINKSTATS-DAG: 1 function-import   - Number of global variables thin link decided to import
26; THINLINKSTATS-DAG: 1 function-import  - Number of critical functions thin link decided to import
27; THINLINKSTATS-DAG: 3 function-import  - Number of functions thin link decided to import
28; THINLINKSTATS-DAG: 1 function-import  - Number of hot functions thin link decided to import
29
30; ModuleID = 'import_stats.ll'
31target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
32target triple = "x86_64-unknown-linux-gnu"
33
34; This function has a high profile count, so entry block is hot.
35define void @hot_function(i1 %a) !prof !20 {
36entry:
37  call void @hot()
38  call void @critical()
39  br i1 %a, label %None1, label %None2, !prof !42
40None1:          ; half goes here
41  call void @none()
42  br label %exit
43None2:          ; half goes here
44  br label %exit
45exit:
46  ret void
47}
48
49declare void @hot()
50declare void @none()
51declare void @critical()
52
53!42 = !{!"branch_weights", i32 1, i32 1}
54
55!llvm.module.flags = !{!1}
56!20 = !{!"function_entry_count", i64 100, i64 696010031887058302}
57
58!1 = !{i32 1, !"ProfileSummary", !2}
59!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
60!3 = !{!"ProfileFormat", !"InstrProf"}
61!4 = !{!"TotalCount", i64 300}
62!5 = !{!"MaxCount", i64 100}
63!6 = !{!"MaxInternalCount", i64 100}
64!7 = !{!"MaxFunctionCount", i64 100}
65!8 = !{!"NumCounts", i64 4}
66!9 = !{!"NumFunctions", i64 1}
67!10 = !{!"DetailedSummary", !11}
68!11 = !{!12, !13, !14}
69!12 = !{i32 10000, i64 100, i32 1}
70!13 = !{i32 999000, i64 100, i32 1}
71!14 = !{i32 999999, i64 1, i32 4}
72