xref: /aosp_15_r20/external/llvm/test/Transforms/SampleProfile/cov-zero-samples.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -instcombine -sample-profile -sample-profile-file=%S/Inputs/cov-zero-samples.prof -sample-profile-check-record-coverage=100 -pass-remarks=sample-profile -o /dev/null 2>&1 | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -passes="function(instcombine),sample-profile" -sample-profile-file=%S/Inputs/cov-zero-samples.prof -sample-profile-check-record-coverage=100 -pass-remarks=sample-profile -o /dev/null 2>&1 | FileCheck %s
3*9880d681SAndroid Build Coastguard Worker;
4*9880d681SAndroid Build Coastguard Worker; CHECK: remark: cov-zero-samples.cc:9:29: Applied 404065 samples from profile (offset: 2.1)
5*9880d681SAndroid Build Coastguard Worker; CHECK: remark: cov-zero-samples.cc:10:9: Applied 443089 samples from profile (offset: 3)
6*9880d681SAndroid Build Coastguard Worker; CHECK: remark: cov-zero-samples.cc:10:36: Applied 0 samples from profile (offset: 3.1)
7*9880d681SAndroid Build Coastguard Worker; CHECK: remark: cov-zero-samples.cc:11:12: Applied 404066 samples from profile (offset: 4)
8*9880d681SAndroid Build Coastguard Worker; CHECK: remark: cov-zero-samples.cc:13:25: Applied 0 samples from profile (offset: 6)
9*9880d681SAndroid Build Coastguard Worker; CHECK: remark: cov-zero-samples.cc:14:3: Applied 0 samples from profile (offset: 7)
10*9880d681SAndroid Build Coastguard Worker; CHECK: remark: cov-zero-samples.cc:10:9: most popular destination for conditional branches at cov-zero-samples.cc:9:3
11*9880d681SAndroid Build Coastguard Worker; CHECK: remark: cov-zero-samples.cc:11:12: most popular destination for conditional branches at cov-zero-samples.cc:10:9
12*9880d681SAndroid Build Coastguard Worker;
13*9880d681SAndroid Build Coastguard Worker; Coverage for this profile should be 100%
14*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: warning: cov-zero-samples.cc:1:
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Worker@N = global i64 8000000000, align 8
17*9880d681SAndroid Build Coastguard Worker@.str = private unnamed_addr constant [11 x i8] c"sum is %d\0A\00", align 1
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind uwtable
20*9880d681SAndroid Build Coastguard Workerdefine i32 @_Z12never_calledi(i32 %i) !dbg !4 {
21*9880d681SAndroid Build Coastguard Workerentry:
22*9880d681SAndroid Build Coastguard Worker  ret i32 0, !dbg !32
23*9880d681SAndroid Build Coastguard Worker}
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind readnone
26*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.declare(metadata, metadata, metadata)
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Worker; Function Attrs: norecurse uwtable
29*9880d681SAndroid Build Coastguard Workerdefine i32 @main() !dbg !8 {
30*9880d681SAndroid Build Coastguard Workerentry:
31*9880d681SAndroid Build Coastguard Worker  %retval = alloca i32, align 4
32*9880d681SAndroid Build Coastguard Worker  %sum = alloca i32, align 4
33*9880d681SAndroid Build Coastguard Worker  %i = alloca i64, align 8
34*9880d681SAndroid Build Coastguard Worker  store i32 0, i32* %retval, align 4
35*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.declare(metadata i32* %sum, metadata !33, metadata !19), !dbg !34
36*9880d681SAndroid Build Coastguard Worker  store i32 0, i32* %sum, align 4, !dbg !34
37*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.declare(metadata i64* %i, metadata !35, metadata !19), !dbg !37
38*9880d681SAndroid Build Coastguard Worker  store i64 0, i64* %i, align 8, !dbg !37
39*9880d681SAndroid Build Coastguard Worker  br label %for.cond, !dbg !38
40*9880d681SAndroid Build Coastguard Worker
41*9880d681SAndroid Build Coastguard Workerfor.cond:                                         ; preds = %for.inc, %entry
42*9880d681SAndroid Build Coastguard Worker  %0 = load i64, i64* %i, align 8, !dbg !39
43*9880d681SAndroid Build Coastguard Worker  %1 = load volatile i64, i64* @N, align 8, !dbg !42
44*9880d681SAndroid Build Coastguard Worker  %cmp = icmp slt i64 %0, %1, !dbg !43
45*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %for.body, label %for.end, !dbg !44
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Workerfor.body:                                         ; preds = %for.cond
48*9880d681SAndroid Build Coastguard Worker  %2 = load i64, i64* %i, align 8, !dbg !45
49*9880d681SAndroid Build Coastguard Worker  %3 = load volatile i64, i64* @N, align 8, !dbg !48
50*9880d681SAndroid Build Coastguard Worker  %cmp1 = icmp sgt i64 %2, %3, !dbg !49
51*9880d681SAndroid Build Coastguard Worker  br i1 %cmp1, label %if.then, label %if.end, !dbg !50
52*9880d681SAndroid Build Coastguard Worker
53*9880d681SAndroid Build Coastguard Workerif.then:                                          ; preds = %for.body
54*9880d681SAndroid Build Coastguard Worker  %4 = load i64, i64* %i, align 8, !dbg !51
55*9880d681SAndroid Build Coastguard Worker  %conv = trunc i64 %4 to i32, !dbg !51
56*9880d681SAndroid Build Coastguard Worker  %call = call i32 @_Z12never_calledi(i32 %conv), !dbg !53
57*9880d681SAndroid Build Coastguard Worker  %5 = load i32, i32* %sum, align 4, !dbg !54
58*9880d681SAndroid Build Coastguard Worker  %add = add nsw i32 %5, %call, !dbg !54
59*9880d681SAndroid Build Coastguard Worker  store i32 %add, i32* %sum, align 4, !dbg !54
60*9880d681SAndroid Build Coastguard Worker  br label %if.end, !dbg !55
61*9880d681SAndroid Build Coastguard Worker
62*9880d681SAndroid Build Coastguard Workerif.end:                                           ; preds = %if.then, %for.body
63*9880d681SAndroid Build Coastguard Worker  %6 = load i64, i64* %i, align 8, !dbg !56
64*9880d681SAndroid Build Coastguard Worker  %div = sdiv i64 %6, 239, !dbg !57
65*9880d681SAndroid Build Coastguard Worker  %7 = load i32, i32* %sum, align 4, !dbg !58
66*9880d681SAndroid Build Coastguard Worker  %conv2 = sext i32 %7 to i64, !dbg !58
67*9880d681SAndroid Build Coastguard Worker  %mul = mul nsw i64 %conv2, %div, !dbg !58
68*9880d681SAndroid Build Coastguard Worker  %conv3 = trunc i64 %mul to i32, !dbg !58
69*9880d681SAndroid Build Coastguard Worker  store i32 %conv3, i32* %sum, align 4, !dbg !58
70*9880d681SAndroid Build Coastguard Worker  br label %for.inc, !dbg !59
71*9880d681SAndroid Build Coastguard Worker
72*9880d681SAndroid Build Coastguard Workerfor.inc:                                          ; preds = %if.end
73*9880d681SAndroid Build Coastguard Worker  %8 = load i64, i64* %i, align 8, !dbg !60
74*9880d681SAndroid Build Coastguard Worker  %inc = add nsw i64 %8, 1, !dbg !60
75*9880d681SAndroid Build Coastguard Worker  store i64 %inc, i64* %i, align 8, !dbg !60
76*9880d681SAndroid Build Coastguard Worker  br label %for.cond, !dbg !62
77*9880d681SAndroid Build Coastguard Worker
78*9880d681SAndroid Build Coastguard Workerfor.end:                                          ; preds = %for.cond
79*9880d681SAndroid Build Coastguard Worker  %9 = load i32, i32* %sum, align 4, !dbg !63
80*9880d681SAndroid Build Coastguard Worker  %call4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), i32 %9), !dbg !64
81*9880d681SAndroid Build Coastguard Worker  ret i32 0, !dbg !65
82*9880d681SAndroid Build Coastguard Worker}
83*9880d681SAndroid Build Coastguard Worker
84*9880d681SAndroid Build Coastguard Workerdeclare i32 @printf(i8*, ...)
85*9880d681SAndroid Build Coastguard Worker
86*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!0}
87*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!15, !16}
88*9880d681SAndroid Build Coastguard Worker!llvm.ident = !{!17}
89*9880d681SAndroid Build Coastguard Worker
90*9880d681SAndroid Build Coastguard Worker!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 253667) (llvm/trunk 253670)", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, enums: !2, globals: !11)
91*9880d681SAndroid Build Coastguard Worker!1 = !DIFile(filename: "cov-zero-samples.cc", directory: ".")
92*9880d681SAndroid Build Coastguard Worker!2 = !{}
93*9880d681SAndroid Build Coastguard Worker!4 = distinct !DISubprogram(name: "never_called", linkageName: "_Z12never_calledi", scope: !1, file: !1, line: 5, type: !5, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
94*9880d681SAndroid Build Coastguard Worker!5 = !DISubroutineType(types: !6)
95*9880d681SAndroid Build Coastguard Worker!6 = !{!7, !7}
96*9880d681SAndroid Build Coastguard Worker!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
97*9880d681SAndroid Build Coastguard Worker!8 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 7, type: !9, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
98*9880d681SAndroid Build Coastguard Worker!9 = !DISubroutineType(types: !10)
99*9880d681SAndroid Build Coastguard Worker!10 = !{!7}
100*9880d681SAndroid Build Coastguard Worker!11 = !{!12}
101*9880d681SAndroid Build Coastguard Worker!12 = !DIGlobalVariable(name: "N", scope: !0, file: !1, line: 3, type: !13, isLocal: false, isDefinition: true, variable: i64* @N)
102*9880d681SAndroid Build Coastguard Worker!13 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !14)
103*9880d681SAndroid Build Coastguard Worker!14 = !DIBasicType(name: "long long int", size: 64, align: 64, encoding: DW_ATE_signed)
104*9880d681SAndroid Build Coastguard Worker!15 = !{i32 2, !"Dwarf Version", i32 4}
105*9880d681SAndroid Build Coastguard Worker!16 = !{i32 2, !"Debug Info Version", i32 3}
106*9880d681SAndroid Build Coastguard Worker!17 = !{!"clang version 3.8.0 (trunk 253667) (llvm/trunk 253670)"}
107*9880d681SAndroid Build Coastguard Worker!19 = !DIExpression()
108*9880d681SAndroid Build Coastguard Worker!31 = !DILexicalBlockFile(scope: !4, file: !1, discriminator: 3)
109*9880d681SAndroid Build Coastguard Worker!32 = !DILocation(line: 5, column: 27, scope: !31)
110*9880d681SAndroid Build Coastguard Worker!33 = !DILocalVariable(name: "sum", scope: !8, file: !1, line: 8, type: !7)
111*9880d681SAndroid Build Coastguard Worker!34 = !DILocation(line: 8, column: 7, scope: !8)
112*9880d681SAndroid Build Coastguard Worker!35 = !DILocalVariable(name: "i", scope: !36, file: !1, line: 9, type: !14)
113*9880d681SAndroid Build Coastguard Worker!36 = distinct !DILexicalBlock(scope: !8, file: !1, line: 9, column: 3)
114*9880d681SAndroid Build Coastguard Worker!37 = !DILocation(line: 9, column: 18, scope: !36)
115*9880d681SAndroid Build Coastguard Worker!38 = !DILocation(line: 9, column: 8, scope: !36)
116*9880d681SAndroid Build Coastguard Worker!39 = !DILocation(line: 9, column: 25, scope: !40)
117*9880d681SAndroid Build Coastguard Worker!40 = !DILexicalBlockFile(scope: !41, file: !1, discriminator: 1)
118*9880d681SAndroid Build Coastguard Worker!41 = distinct !DILexicalBlock(scope: !36, file: !1, line: 9, column: 3)
119*9880d681SAndroid Build Coastguard Worker!42 = !DILocation(line: 9, column: 29, scope: !40)
120*9880d681SAndroid Build Coastguard Worker!43 = !DILocation(line: 9, column: 27, scope: !40)
121*9880d681SAndroid Build Coastguard Worker!44 = !DILocation(line: 9, column: 3, scope: !40)
122*9880d681SAndroid Build Coastguard Worker!45 = !DILocation(line: 10, column: 9, scope: !46)
123*9880d681SAndroid Build Coastguard Worker!46 = distinct !DILexicalBlock(scope: !47, file: !1, line: 10, column: 9)
124*9880d681SAndroid Build Coastguard Worker!47 = distinct !DILexicalBlock(scope: !41, file: !1, line: 9, column: 37)
125*9880d681SAndroid Build Coastguard Worker!48 = !DILocation(line: 10, column: 13, scope: !46)
126*9880d681SAndroid Build Coastguard Worker!49 = !DILocation(line: 10, column: 11, scope: !46)
127*9880d681SAndroid Build Coastguard Worker!50 = !DILocation(line: 10, column: 9, scope: !47)
128*9880d681SAndroid Build Coastguard Worker!51 = !DILocation(line: 10, column: 36, scope: !52)
129*9880d681SAndroid Build Coastguard Worker!52 = !DILexicalBlockFile(scope: !46, file: !1, discriminator: 1)
130*9880d681SAndroid Build Coastguard Worker!53 = !DILocation(line: 10, column: 23, scope: !52)
131*9880d681SAndroid Build Coastguard Worker!54 = !DILocation(line: 10, column: 20, scope: !52)
132*9880d681SAndroid Build Coastguard Worker!55 = !DILocation(line: 10, column: 16, scope: !52)
133*9880d681SAndroid Build Coastguard Worker!56 = !DILocation(line: 11, column: 12, scope: !47)
134*9880d681SAndroid Build Coastguard Worker!57 = !DILocation(line: 11, column: 14, scope: !47)
135*9880d681SAndroid Build Coastguard Worker!58 = !DILocation(line: 11, column: 9, scope: !47)
136*9880d681SAndroid Build Coastguard Worker!59 = !DILocation(line: 12, column: 3, scope: !47)
137*9880d681SAndroid Build Coastguard Worker!60 = !DILocation(line: 9, column: 33, scope: !61)
138*9880d681SAndroid Build Coastguard Worker!61 = !DILexicalBlockFile(scope: !41, file: !1, discriminator: 2)
139*9880d681SAndroid Build Coastguard Worker!62 = !DILocation(line: 9, column: 3, scope: !61)
140*9880d681SAndroid Build Coastguard Worker!63 = !DILocation(line: 13, column: 25, scope: !8)
141*9880d681SAndroid Build Coastguard Worker!64 = !DILocation(line: 13, column: 3, scope: !8)
142*9880d681SAndroid Build Coastguard Worker!65 = !DILocation(line: 14, column: 3, scope: !8)
143