135 lines · plain
1; Original C++ test case2;3; #include <stdio.h>4;5; __attribute__((noinline)) int goo() { return 3 };6; __attribute__((noinline)) int hoo() { return 4 };7;8; int sum(int x, int y) {9; return x + y;10; }11;12; int main() {13; int s, i = 0;14; while (i++ < 20000 * 20000)15; if (i != 100) s = sum(i, s); else s = 30;16; printf("sum is %d\n", s);17; return goo() + hoo() != 7;18; }19;20; Both goo and hoo don't show up in the input profile.21; Suppose function goo shows up in the binary generating the input profile22; and function hoo doesn't show up. Then the profile symbol list in the input23; profile will contain goo but not hoo. Verify the entry count of goo is24; 0 and the entry count of hoo is -1.25; CHECK: define {{.*}} i32 @_Z3goov() {{.*}} !prof ![[IDX1:[0-9]*]]26; CHECK: define {{.*}} i32 @_Z3hoov() {{.*}} !prof ![[IDX2:[0-9]*]]27; CHECK: ![[IDX1]] = !{!"function_entry_count", i64 0}28; CHECK: ![[IDX2]] = !{!"function_entry_count", i64 -1}29 30target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"31target triple = "x86_64-unknown-linux-gnu"32 33@.str = private unnamed_addr constant [11 x i8] c"sum is %d\0A\00", align 134 35; Function Attrs: noinline norecurse nounwind readnone uwtable36define dso_local i32 @_Z3goov() local_unnamed_addr #0 !dbg !7 {37entry:38 ret i32 3, !dbg !939}40 41; Function Attrs: noinline norecurse nounwind readnone uwtable42define dso_local i32 @_Z3hoov() local_unnamed_addr #0 !dbg !10 {43entry:44 ret i32 4, !dbg !1145}46 47; Function Attrs: norecurse nounwind readnone uwtable48define dso_local i32 @_Z3sumii(i32 %x, i32 %y) local_unnamed_addr #1 !dbg !12 {49entry:50 %add = add nsw i32 %y, %x, !dbg !1351 ret i32 %add, !dbg !1452}53 54; Function Attrs: nofree norecurse nounwind uwtable55define dso_local i32 @main() local_unnamed_addr #2 !dbg !15 {56entry:57 br label %while.body, !dbg !1658 59while.body: ; preds = %while.body, %entry60 %inc12 = phi i32 [ 1, %entry ], [ %inc.4, %while.body ]61 %s.011 = phi i32 [ undef, %entry ], [ %spec.select.4, %while.body ]62 %cmp1 = icmp eq i32 %inc12, 100, !dbg !1863 %add.i = add nsw i32 %inc12, %s.011, !dbg !2064 %spec.select = select i1 %cmp1, i32 30, i32 %add.i, !dbg !2365 %inc = add nuw nsw i32 %inc12, 1, !dbg !2466 %cmp1.1 = icmp eq i32 %inc, 100, !dbg !1867 %add.i.1 = add nsw i32 %inc, %spec.select, !dbg !2068 %spec.select.1 = select i1 %cmp1.1, i32 30, i32 %add.i.1, !dbg !2369 %inc.1 = add nuw nsw i32 %inc12, 2, !dbg !2470 %cmp1.2 = icmp eq i32 %inc.1, 100, !dbg !1871 %add.i.2 = add nsw i32 %inc.1, %spec.select.1, !dbg !2072 %spec.select.2 = select i1 %cmp1.2, i32 30, i32 %add.i.2, !dbg !2373 %inc.2 = add nuw nsw i32 %inc12, 3, !dbg !2474 %cmp1.3 = icmp eq i32 %inc.2, 100, !dbg !1875 %add.i.3 = add nsw i32 %inc.2, %spec.select.2, !dbg !2076 %spec.select.3 = select i1 %cmp1.3, i32 30, i32 %add.i.3, !dbg !2377 %inc.3 = add nuw nsw i32 %inc12, 4, !dbg !2478 %cmp1.4 = icmp eq i32 %inc.3, 100, !dbg !1879 %add.i.4 = add nsw i32 %inc.3, %spec.select.3, !dbg !2080 %spec.select.4 = select i1 %cmp1.4, i32 30, i32 %add.i.4, !dbg !2381 %inc.4 = add nuw nsw i32 %inc12, 5, !dbg !2482 %exitcond.4 = icmp eq i32 %inc.4, 400000001, !dbg !2683 br i1 %exitcond.4, label %while.end, label %while.body, !dbg !27, !llvm.loop !2884 85while.end: ; preds = %while.body86 %call2 = tail call i32 (ptr, ...) @printf(ptr @.str, i32 %spec.select.4), !dbg !3187 ret i32 0, !dbg !3288}89 90; Function Attrs: nofree nounwind91declare dso_local i32 @printf(ptr nocapture readonly, ...) local_unnamed_addr #392 93attributes #0 = { noinline norecurse nounwind readnone uwtable "use-sample-profile" }94attributes #1 = { norecurse nounwind readnone uwtable "use-sample-profile" }95attributes #2 = { nofree norecurse nounwind uwtable "use-sample-profile" }96attributes #3 = { nofree nounwind "use-sample-profile" }97 98!llvm.dbg.cu = !{!0}99!llvm.module.flags = !{!3, !4, !5}100!llvm.ident = !{!6}101 102!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0 (trunk 369144)", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2, debugInfoForProfiling: true, nameTableKind: None)103!1 = !DIFile(filename: "1.cc", directory: "/usr/local/google/home/wmi/workarea/llvm-r369144/src")104!2 = !{}105!3 = !{i32 2, !"Dwarf Version", i32 4}106!4 = !{i32 2, !"Debug Info Version", i32 3}107!5 = !{i32 1, !"wchar_size", i32 4}108!6 = !{!"clang version 10.0.0 (trunk 369144)"}109!7 = distinct !DISubprogram(name: "goo", linkageName: "_Z3goov", scope: !1, file: !1, line: 3, type: !8, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)110!8 = !DISubroutineType(types: !2)111!9 = !DILocation(line: 3, column: 39, scope: !7)112!10 = distinct !DISubprogram(name: "hoo", linkageName: "_Z3hoov", scope: !1, file: !1, line: 4, type: !8, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)113!11 = !DILocation(line: 4, column: 39, scope: !10)114!12 = distinct !DISubprogram(name: "sum", linkageName: "_Z3sumii", scope: !1, file: !1, line: 6, type: !8, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)115!13 = !DILocation(line: 7, column: 12, scope: !12)116!14 = !DILocation(line: 7, column: 3, scope: !12)117!15 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 10, type: !8, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)118!16 = !DILocation(line: 12, column: 3, scope: !17)119!17 = !DILexicalBlockFile(scope: !15, file: !1, discriminator: 2)120!18 = !DILocation(line: 13, column: 11, scope: !19)121!19 = !DILexicalBlockFile(scope: !15, file: !1, discriminator: 21)122!20 = !DILocation(line: 7, column: 12, scope: !21, inlinedAt: !22)123!21 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 21)124!22 = distinct !DILocation(line: 13, column: 23, scope: !17)125!23 = !DILocation(line: 13, column: 9, scope: !19)126!24 = !DILocation(line: 12, column: 11, scope: !25)127!25 = !DILexicalBlockFile(scope: !15, file: !1, discriminator: 1282)128!26 = !DILocation(line: 12, column: 14, scope: !25)129!27 = !DILocation(line: 12, column: 3, scope: !25)130!28 = distinct !{!28, !29, !30}131!29 = !DILocation(line: 12, column: 3, scope: !15)132!30 = !DILocation(line: 13, column: 43, scope: !15)133!31 = !DILocation(line: 14, column: 3, scope: !15)134!32 = !DILocation(line: 15, column: 3, scope: !15)135