1 ;; Test we merge non-inlined profile only once with '-sample-profile-merge-inlinee'
2 ; RUN: opt < %s -passes='function(callsite-splitting),sample-profile' -sample-profile-file=%S/Inputs/inline-mergeprof.prof -sample-profile-merge-inlinee=true -S | FileCheck %s
4 %struct.bitmap = type { i32, ptr }
7 define void @main(i1 %c, ptr %a_elt, ptr %b_elt) #0 !dbg !6 {
12 %tobool1 = icmp eq ptr %a_elt, null
13 br i1 %tobool1, label %CallSiteBB, label %NextCond
16 %cmp = icmp ne ptr %b_elt, null
17 br i1 %cmp, label %CallSiteBB, label %End
20 %p = phi i1 [0, %Top], [%c, %NextCond]
21 ;; The call site is replicated by callsite-splitting pass and they end up share the same sample profile
22 ; CHECK: call void @_Z3sumii(ptr null, ptr null, ptr %b_elt, i1 false)
23 ; CHECK: call void @_Z3sumii(ptr nonnull %a_elt, ptr nonnull %a_elt, ptr nonnull %b_elt, i1 %c)
24 call void @_Z3sumii(ptr %a_elt, ptr %a_elt, ptr %b_elt, i1 %p), !dbg !8
31 define void @_Z3sumii(ptr %dst_elt, ptr %a_elt, ptr %b_elt, i1 %c) #0 !dbg !12 {
33 %tobool = icmp ne ptr %a_elt, null
34 %tobool1 = icmp ne ptr %b_elt, null
35 %or.cond = and i1 %tobool, %tobool1, !dbg !13
36 br i1 %or.cond, label %Cond, label %Big
39 %cmp = icmp eq ptr %dst_elt, %a_elt, !dbg !14
40 br i1 %cmp, label %Small, label %Big, !dbg !15
52 attributes #0 = { "use-sample-profile" }
55 !llvm.module.flags = !{!3, !4}
58 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.5 ", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
59 !1 = !DIFile(filename: "calls.cc", directory: ".")
61 !3 = !{i32 2, !"Dwarf Version", i32 4}
62 !4 = !{i32 1, !"Debug Info Version", i32 3}
63 !5 = !{!"clang version 3.5 "}
64 !6 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 7, type: !7, scopeLine: 7, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
65 !7 = !DISubroutineType(types: !2)
66 !8 = !DILocation(line: 10, scope: !9)
67 !9 = !DILexicalBlockFile(scope: !10, file: !1, discriminator: 2)
68 !10 = distinct !DILexicalBlock(scope: !6, file: !1, line: 10)
69 !11 = !DILocation(line: 12, scope: !6)
70 !12 = distinct !DISubprogram(name: "sum", scope: !1, file: !1, line: 3, type: !7, scopeLine: 3, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
71 !13 = !DILocation(line: 4, scope: !12)
72 !14 = !DILocation(line: 5, scope: !12)
73 !15 = !DILocation(line: 6, scope: !12)
76 ;; Check the profile of funciton sum is only merged once though the original callsite is replicted.
78 ; CHECK-NEXT: {!"function_entry_count", i64 46}
79 ; CHECK: !{!"branch_weights", i32 11, i32 37}
80 ; CHECK: !{!"branch_weights", i32 11, i32 1}