| 1 |
; Original C++ test case |
| 2 |
; |
| 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 profile |
| 22 |
; and function hoo doesn't show up. Then the profile symbol list in the input |
| 23 |
; profile will contain goo but not hoo. Verify the entry count of goo is |
| 24 |
; 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 |
|
| 30 |
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
| 31 |
target triple = "x86_64-unknown-linux-gnu" |
| 32 |
|
| 33 |
@.str = private unnamed_addr constant [11 x i8] c"sum is %d\0A\00", align 1 |
| 34 |
|
| 35 |
; Function Attrs: noinline norecurse nounwind readnone uwtable |
| 36 |
define dso_local i32 @_Z3goov() local_unnamed_addr #0 !dbg !7 { |
| 37 |
entry: |
| 38 |
ret i32 3, !dbg !9 |
| 39 |
} |
| 40 |
|
| 41 |
; Function Attrs: noinline norecurse nounwind readnone uwtable |
| 42 |
define dso_local i32 @_Z3hoov() local_unnamed_addr #0 !dbg !10 { |
| 43 |
entry: |
| 44 |
ret i32 4, !dbg !11 |
| 45 |
} |
| 46 |
|
| 47 |
; Function Attrs: norecurse nounwind readnone uwtable |
| 48 |
define dso_local i32 @_Z3sumii(i32 %x, i32 %y) local_unnamed_addr #1 !dbg !12 { |
| 49 |
entry: |
| 50 |
%add = add nsw i32 %y, %x, !dbg !13 |
| 51 |
ret i32 %add, !dbg !14 |
| 52 |
} |
| 53 |
|
| 54 |
; Function Attrs: nofree norecurse nounwind uwtable |
| 55 |
define dso_local i32 @main() local_unnamed_addr #2 !dbg !15 { |
| 56 |
entry: |
| 57 |
br label %while.body, !dbg !16 |
| 58 |
|
| 59 |
while.body: ; preds = %while.body, %entry |
| 60 |
%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 !18 |
| 63 |
%add.i = add nsw i32 %inc12, %s.011, !dbg !20 |
| 64 |
%spec.select = select i1 %cmp1, i32 30, i32 %add.i, !dbg !23 |
| 65 |
%inc = add nuw nsw i32 %inc12, 1, !dbg !24 |
| 66 |
%cmp1.1 = icmp eq i32 %inc, 100, !dbg !18 |
| 67 |
%add.i.1 = add nsw i32 %inc, %spec.select, !dbg !20 |
| 68 |
%spec.select.1 = select i1 %cmp1.1, i32 30, i32 %add.i.1, !dbg !23 |
| 69 |
%inc.1 = add nuw nsw i32 %inc12, 2, !dbg !24 |
| 70 |
%cmp1.2 = icmp eq i32 %inc.1, 100, !dbg !18 |
| 71 |
%add.i.2 = add nsw i32 %inc.1, %spec.select.1, !dbg !20 |
| 72 |
%spec.select.2 = select i1 %cmp1.2, i32 30, i32 %add.i.2, !dbg !23 |
| 73 |
%inc.2 = add nuw nsw i32 %inc12, 3, !dbg !24 |
| 74 |
%cmp1.3 = icmp eq i32 %inc.2, 100, !dbg !18 |
| 75 |
%add.i.3 = add nsw i32 %inc.2, %spec.select.2, !dbg !20 |
| 76 |
%spec.select.3 = select i1 %cmp1.3, i32 30, i32 %add.i.3, !dbg !23 |
| 77 |
%inc.3 = add nuw nsw i32 %inc12, 4, !dbg !24 |
| 78 |
%cmp1.4 = icmp eq i32 %inc.3, 100, !dbg !18 |
| 79 |
%add.i.4 = add nsw i32 %inc.3, %spec.select.3, !dbg !20 |
| 80 |
%spec.select.4 = select i1 %cmp1.4, i32 30, i32 %add.i.4, !dbg !23 |
| 81 |
%inc.4 = add nuw nsw i32 %inc12, 5, !dbg !24 |
| 82 |
%exitcond.4 = icmp eq i32 %inc.4, 400000001, !dbg !26 |
| 83 |
br i1 %exitcond.4, label %while.end, label %while.body, !dbg !27, !llvm.loop !28 |
| 84 |
|
| 85 |
while.end: ; preds = %while.body |
| 86 |
%call2 = tail call i32 (ptr, ...) @printf(ptr @.str, i32 %spec.select.4), !dbg !31 |
| 87 |
ret i32 0, !dbg !32 |
| 88 |
} |
| 89 |
|
| 90 |
; Function Attrs: nofree nounwind |
| 91 |
declare dso_local i32 @printf(ptr nocapture readonly, ...) local_unnamed_addr #3 |
| 92 |
|
| 93 |
attributes #0 = { noinline norecurse nounwind readnone uwtable "use-sample-profile" } |
| 94 |
attributes #1 = { norecurse nounwind readnone uwtable "use-sample-profile" } |
| 95 |
attributes #2 = { nofree norecurse nounwind uwtable "use-sample-profile" } |
| 96 |
attributes #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) |