1 ; RUN: opt %s -passes=sample-profile -sample-profile-file=%S/Inputs/remap-2.prof -sample-profile-remapping-file=%S/Inputs/remap.map -S | FileCheck %s
2 ; Check profile remapping works for searching inline instance, searching
3 ; indirect call promotion candidate and prevent recursive inline.
5 @x.addr = common global i32 zeroinitializer, align 16
6 @y.addr = common global i32 zeroinitializer, align 16
8 define i32 @_ZN3foo3barERKN1M1XINS_6detail3quxEEE() #0 !dbg !9 {
10 %t0 = load i32, ptr @x.addr, align 4
11 %t1 = load i32, ptr @y.addr, align 4
12 %add = add nsw i32 %t0, %t1
16 define i32 @_ZN1M1XE() #0 !dbg !10 {
18 %t0 = load i32, ptr @x.addr, align 4
19 %t1 = load i32, ptr @y.addr, align 4
20 %sub = sub nsw i32 %t0, %t1
24 define void @test(ptr) #0 !dbg !4 {
27 %t3 = load ptr, ptr %t2
28 ; Check call i32 %t3 has been indirect call promoted and call i32 @_ZN1M1XE
31 ; CHECK: icmp eq ptr %t3, @_ZN3foo3barERKN1M1XINS_6detail3quxEEE
32 ; CHECK-NOT: call i32 @_ZN1M1XE
33 %t4 = call i32 %t3(), !dbg !7
34 %t5 = call i32 @_ZN1M1XE(), !dbg !8
38 define void @_ZN1M1X1YE(ptr) #0 !dbg !11 {
41 %t3 = load ptr, ptr %t2
42 ; Check call i32 %t3 has got its profile but is not indirect call promoted
43 ; because the promotion candidate is a recursive call to the current function.
44 ; CHECK-LABEL: @_ZN1M1X1YE(
45 ; CHECK: call i32 %t3(), {{.*}} !prof ![[PROFID:[0-9]+]]
46 ; CHECK-NOT: icmp eq ptr %t3, @_ZN1M1X1YE
47 %t4 = call i32 %t3(), !dbg !12
51 ; CHECK: ![[PROFID]] = !{!"VP", i32 0, i64 3000
53 attributes #0 = { "use-sample-profile" }
56 !llvm.module.flags = !{!13, !14}
59 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
60 !1 = !DIFile(filename: "calls.cc", directory: ".")
62 !4 = distinct !DISubprogram(name: "test", line: 3, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 3, file: !1, scope: !5, type: !6, retainedNodes: !2)
63 !5 = !DIFile(filename: "calls.cc", directory: ".")
64 !6 = !DISubroutineType(types: !2)
65 !7 = !DILocation(line: 8, scope: !4)
66 !8 = !DILocation(line: 9, scope: !4)
67 !9 = distinct !DISubprogram(name: "_ZN3foo3barERKN1M1XINS_6detail3quxEEE", line: 15, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 3, file: !1, scope: !5, type: !6, retainedNodes: !2)
68 !10 = distinct !DISubprogram(name: "_ZN1M1XE", line: 20, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 3, file: !1, scope: !5, type: !6, retainedNodes: !2)
69 !11 = distinct !DISubprogram(name: "_ZN1M1X1YE", line: 25, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 3, file: !1, scope: !5, type: !6, retainedNodes: !2)
70 !12 = !DILocation(line: 30, scope: !11)
71 !13 = !{i32 2, !"Dwarf Version", i32 4}
72 !14 = !{i32 1, !"Debug Info Version", i32 3}
73 !15 = !{!"clang version 3.5 "}