1 ; RUN: llc < %s -x86-discriminate-memops -prefetch-hints-file=%S/insert-prefetch.afdo | FileCheck %s
2 ; RUN: llc < %s -x86-discriminate-memops -prefetch-hints-file=%S/insert-prefetch-other.afdo | FileCheck %s -check-prefix=OTHERS
4 ; original source, compiled with -O3 -gmlt -fdebug-info-for-profiling:
5 ; int sum(int* arr, int pos1, int pos2) {
6 ; return arr[pos1] + arr[pos2];
9 ; NOTE: debug line numbers were adjusted such that the function would start
10 ; at line 15 (an arbitrary number). The sample profile file format uses
11 ; offsets from the start of the symbol instead of file-relative line numbers.
12 ; The .afdo file reflects that - the instructions are offset '1'.
14 ; ModuleID = 'test.cc'
15 source_filename = "test.cc"
16 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
17 target triple = "x86_64-unknown-linux-gnu"
19 define i32 @sum(i32* %arr, i32 %pos1, i32 %pos2) !dbg !35 !prof !37 {
21 %idxprom = sext i32 %pos1 to i64, !dbg !38
22 %arrayidx = getelementptr inbounds i32, i32* %arr, i64 %idxprom, !dbg !38
23 %0 = load i32, i32* %arrayidx, align 4, !dbg !38, !tbaa !39
24 %idxprom1 = sext i32 %pos2 to i64, !dbg !43
25 %arrayidx2 = getelementptr inbounds i32, i32* %arr, i64 %idxprom1, !dbg !43
26 %1 = load i32, i32* %arrayidx2, align 4, !dbg !43, !tbaa !39
27 %add = add nsw i32 %1, %0, !dbg !44
28 ret i32 %add, !dbg !45
31 attributes #0 = { "target-cpu"="x86-64" }
34 !llvm.module.flags = !{!3, !4, !5, !6}
37 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2, debugInfoForProfiling: true)
38 !1 = !DIFile(filename: "test.cc", directory: "/tmp")
40 !3 = !{i32 2, !"Dwarf Version", i32 4}
41 !4 = !{i32 2, !"Debug Info Version", i32 3}
42 !5 = !{i32 1, !"wchar_size", i32 4}
43 !6 = !{i32 1, !"ProfileSummary", !7}
44 !7 = !{!8, !9, !10, !11, !12, !13, !14, !15}
45 !8 = !{!"ProfileFormat", !"SampleProfile"}
46 !9 = !{!"TotalCount", i64 0}
47 !10 = !{!"MaxCount", i64 0}
48 !11 = !{!"MaxInternalCount", i64 0}
49 !12 = !{!"MaxFunctionCount", i64 0}
50 !13 = !{!"NumCounts", i64 2}
51 !14 = !{!"NumFunctions", i64 1}
52 !15 = !{!"DetailedSummary", !16}
53 !16 = !{!17, !18, !19, !20, !21, !22, !22, !23, !23, !24, !25, !26, !27, !28, !29, !30, !31, !32}
54 !17 = !{i32 10000, i64 0, i32 0}
55 !18 = !{i32 100000, i64 0, i32 0}
56 !19 = !{i32 200000, i64 0, i32 0}
57 !20 = !{i32 300000, i64 0, i32 0}
58 !21 = !{i32 400000, i64 0, i32 0}
59 !22 = !{i32 500000, i64 0, i32 0}
60 !23 = !{i32 600000, i64 0, i32 0}
61 !24 = !{i32 700000, i64 0, i32 0}
62 !25 = !{i32 800000, i64 0, i32 0}
63 !26 = !{i32 900000, i64 0, i32 0}
64 !27 = !{i32 950000, i64 0, i32 0}
65 !28 = !{i32 990000, i64 0, i32 0}
66 !29 = !{i32 999000, i64 0, i32 0}
67 !30 = !{i32 999900, i64 0, i32 0}
68 !31 = !{i32 999990, i64 0, i32 0}
69 !32 = !{i32 999999, i64 0, i32 0}
70 !33 = !{!"clang version 7.0.0 (trunk 322593) (llvm/trunk 322526)"}
71 !35 = distinct !DISubprogram(name: "sum", linkageName: "sum", scope: !1, file: !1, line: 15, type: !36, isLocal: false, isDefinition: true, scopeLine: 15, flags: DIFlagPrototyped, isOptimized: true, unit: !0)
72 !36 = !DISubroutineType(types: !2)
73 !37 = !{!"function_entry_count", i64 -1}
74 !38 = !DILocation(line: 16, column: 10, scope: !35)
75 !39 = !{!40, !40, i64 0}
76 !40 = !{!"int", !41, i64 0}
77 !41 = !{!"omnipotent char", !42, i64 0}
78 !42 = !{!"Simple C++ TBAA"}
79 !43 = !DILocation(line: 16, column: 22, scope: !35)
80 !44 = !DILocation(line: 16, column: 20, scope: !35)
81 !45 = !DILocation(line: 16, column: 3, scope: !35)
85 ;CHECK: prefetchnta 42(%rdi,%rax,4)
86 ;CHECK-NEXT: prefetchnta (%rdi,%rax,4)
87 ;CHECK-NEXT: movl (%rdi,%rax,4), %eax
88 ;CHECK-NEXT: .loc 1 16 20 discriminator 2 # test.cc:16:20
89 ;CHECK-NEXT: prefetchnta -1(%rdi,%rcx,4)
90 ;CHECK-NEXT: addl (%rdi,%rcx,4), %eax
91 ;CHECK-NEXT: .loc 1 16 3 # test.cc:16:3
95 ;OTHERS: prefetcht2 42(%rdi,%rax,4)
96 ;OTHERS-NEXT: prefetcht0 (%rdi,%rax,4)
97 ;OTHERS-NEXT: movl (%rdi,%rax,4), %eax
98 ;OTHERS-NEXT: .loc 1 16 20 discriminator 2 # test.cc:16:20
99 ;OTHERS-NEXT: prefetcht1 -1(%rdi,%rcx,4)
100 ;OTHERS-NEXT: addl (%rdi,%rcx,4), %eax
101 ;OTHERS-NEXT: .loc 1 16 3 # test.cc:16:3