75 lines · plain
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 %s2; Check profile remapping works for searching inline instance, searching3; indirect call promotion candidate and prevent recursive inline.4 5@x.addr = common global i32 zeroinitializer, align 166@y.addr = common global i32 zeroinitializer, align 167 8define i32 @_ZN3foo3barERKN1M1XINS_6detail3quxEEE() #0 !dbg !9 {9entry:10 %t0 = load i32, ptr @x.addr, align 411 %t1 = load i32, ptr @y.addr, align 412 %add = add nsw i32 %t0, %t113 ret i32 %add14}15 16define i32 @_ZN1M1XE() #0 !dbg !10 {17entry:18 %t0 = load i32, ptr @x.addr, align 419 %t1 = load i32, ptr @y.addr, align 420 %sub = sub nsw i32 %t0, %t121 ret i32 %sub22}23 24define void @test(ptr) #0 !dbg !4 {25 %t2 = alloca ptr26 store ptr %0, ptr %t227 %t3 = load ptr, ptr %t228; Check call i32 %t3 has been indirect call promoted and call i32 @_ZN1M1XE29; has been inlined.30; CHECK-LABEL: @test(31; CHECK: icmp eq ptr %t3, @_ZN3foo3barERKN1M1XINS_6detail3quxEEE32; CHECK-NOT: call i32 @_ZN1M1XE33 %t4 = call i32 %t3(), !dbg !734 %t5 = call i32 @_ZN1M1XE(), !dbg !835 ret void36}37 38define void @_ZN1M1X1YE(ptr) #0 !dbg !11 {39 %t2 = alloca ptr40 store ptr %0, ptr %t241 %t3 = load ptr, ptr %t242; Check call i32 %t3 has got its profile but is not indirect call promoted43; 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, @_ZN1M1X1YE47 %t4 = call i32 %t3(), !dbg !1248 ret void49}50 51; CHECK: ![[PROFID]] = !{!"VP", i32 0, i64 300052 53attributes #0 = { "use-sample-profile" }54 55!llvm.dbg.cu = !{!0}56!llvm.module.flags = !{!13, !14}57!llvm.ident = !{!15}58 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: ".")61!2 = !{}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 "}74 75