1 ; Note that this needs new pass manager for now. Passing `-sample-profile-top-down-load` to legacy pass manager is a no-op.
3 ; Test we aren't doing specialization for inlining with default source order
4 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -sample-profile-top-down-load=false -S | FileCheck -check-prefix=DEFAULT %s
6 ; Test we specialize based on call path with context-sensitive profile while inlining with '-sample-profile-top-down-load'
7 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -sample-profile-merge-inlinee -sample-profile-top-down-load=true -S | FileCheck -check-prefix=TOPDOWN %s
10 @.str = private unnamed_addr constant [11 x i8] c"sum is %d\0A\00", align 1
12 define i32 @_Z3sumii(i32 %x, i32 %y) #0 !dbg !6 {
14 %x.addr = alloca i32, align 4
15 %y.addr = alloca i32, align 4
16 store i32 %x, i32* %x.addr, align 4
17 store i32 %y, i32* %y.addr, align 4
18 %tmp = load i32, i32* %x.addr, align 4, !dbg !8
19 %tmp1 = load i32, i32* %y.addr, align 4, !dbg !8
20 %add = add nsw i32 %tmp, %tmp1, !dbg !8
21 %tmp2 = load i32, i32* %x.addr, align 4, !dbg !8
22 %tmp3 = load i32, i32* %y.addr, align 4, !dbg !8
23 %call = call i32 @_Z3subii(i32 %tmp2, i32 %tmp3), !dbg !8
27 define i32 @_Z3subii(i32 %x, i32 %y) #0 !dbg !9 {
29 %x.addr = alloca i32, align 4
30 %y.addr = alloca i32, align 4
31 store i32 %x, i32* %x.addr, align 4
32 store i32 %y, i32* %y.addr, align 4
33 %tmp = load i32, i32* %x.addr, align 4, !dbg !10
34 %tmp1 = load i32, i32* %y.addr, align 4, !dbg !10
35 %add = sub nsw i32 %tmp, %tmp1, !dbg !10
36 ret i32 %add, !dbg !11
39 define i32 @main() #0 !dbg !12 {
41 %retval = alloca i32, align 4
42 %s = alloca i32, align 4
43 %i = alloca i32, align 4
44 store i32 0, i32* %retval
45 store i32 0, i32* %i, align 4, !dbg !13
46 br label %while.cond, !dbg !14
48 while.cond: ; preds = %if.end, %entry
49 %tmp = load i32, i32* %i, align 4, !dbg !15
50 %inc = add nsw i32 %tmp, 1, !dbg !15
51 store i32 %inc, i32* %i, align 4, !dbg !15
52 %cmp = icmp slt i32 %tmp, 400000000, !dbg !15
53 br i1 %cmp, label %while.body, label %while.end, !dbg !15
55 while.body: ; preds = %while.cond
56 %tmp1 = load i32, i32* %i, align 4, !dbg !17
57 %cmp1 = icmp ne i32 %tmp1, 100, !dbg !17
58 br i1 %cmp1, label %if.then, label %if.else, !dbg !17
60 if.then: ; preds = %while.body
61 %tmp2 = load i32, i32* %i, align 4, !dbg !19
62 %tmp3 = load i32, i32* %s, align 4, !dbg !19
63 %call = call i32 @_Z3sumii(i32 %tmp2, i32 %tmp3), !dbg !19
64 store i32 %call, i32* %s, align 4, !dbg !19
65 br label %if.end, !dbg !19
67 if.else: ; preds = %while.body
68 store i32 30, i32* %s, align 4, !dbg !21
71 if.end: ; preds = %if.else, %if.then
72 br label %while.cond, !dbg !23
74 while.end: ; preds = %while.cond
75 %tmp4 = load i32, i32* %s, align 4, !dbg !25
76 %call2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), i32 %tmp4), !dbg !25
80 declare i32 @printf(i8*, ...)
82 attributes #0 = { "use-sample-profile" }
85 !llvm.module.flags = !{!3, !4}
88 !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)
89 !1 = !DIFile(filename: "calls.cc", directory: ".")
91 !3 = !{i32 2, !"Dwarf Version", i32 4}
92 !4 = !{i32 1, !"Debug Info Version", i32 3}
93 !5 = !{!"clang version 3.5 "}
94 !6 = distinct !DISubprogram(name: "sum", scope: !1, file: !1, line: 3, type: !7, scopeLine: 3, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
95 !7 = !DISubroutineType(types: !2)
96 !8 = !DILocation(line: 4, scope: !6)
97 !9 = distinct !DISubprogram(name: "sub", scope: !1, file: !1, line: 20, type: !7, scopeLine: 20, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
98 !10 = !DILocation(line: 20, scope: !9)
99 !11 = !DILocation(line: 21, scope: !9)
100 !12 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 7, type: !7, scopeLine: 7, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
101 !13 = !DILocation(line: 8, scope: !12)
102 !14 = !DILocation(line: 9, scope: !12)
103 !15 = !DILocation(line: 9, scope: !16)
104 !16 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 2)
105 !17 = !DILocation(line: 10, scope: !18)
106 !18 = distinct !DILexicalBlock(scope: !12, file: !1, line: 10)
107 !19 = !DILocation(line: 10, scope: !20)
108 !20 = !DILexicalBlockFile(scope: !18, file: !1, discriminator: 2)
109 !21 = !DILocation(line: 10, scope: !22)
110 !22 = !DILexicalBlockFile(scope: !18, file: !1, discriminator: 4)
111 !23 = !DILocation(line: 10, scope: !24)
112 !24 = !DILexicalBlockFile(scope: !18, file: !1, discriminator: 6)
113 !25 = !DILocation(line: 11, scope: !12)
114 !26 = !DILocation(line: 12, scope: !12)
118 ; DEFAULT-NOT: call i32 @_Z3subii
120 ; DEFAULT-NOT: call i32 @_Z3subii
123 ; TOPDOWN-NOT: call i32 @_Z3subii
125 ; TOPDOWN: call i32 @_Z3subii