1 ; RUN: llc < %s -x86-discriminate-memops -prefetch-hints-file=%S/insert-prefetch-inline.afdo | FileCheck %s
3 ; Verify we can insert prefetch instructions in code belonging to inlined
8 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
9 target triple = "x86_64-unknown-linux-gnu"
11 ; Function Attrs: norecurse nounwind readonly uwtable
12 define dso_local i32 @sum(ptr nocapture readonly %arr, i32 %pos1, i32 %pos2) local_unnamed_addr #0 !dbg !7 {
14 %idxprom = sext i32 %pos1 to i64, !dbg !10
15 %arrayidx = getelementptr inbounds i32, ptr %arr, i64 %idxprom, !dbg !10
16 %0 = load i32, ptr %arrayidx, align 4, !dbg !10, !tbaa !11
17 %idxprom1 = sext i32 %pos2 to i64, !dbg !15
18 %arrayidx2 = getelementptr inbounds i32, ptr %arr, i64 %idxprom1, !dbg !15
19 %1 = load i32, ptr %arrayidx2, align 4, !dbg !15, !tbaa !11
20 %add = add nsw i32 %1, %0, !dbg !16
21 ret i32 %add, !dbg !17
24 ; "caller" inlines "sum". The associated .afdo file references instructions
25 ; in "caller" that came from "sum"'s inlining.
27 ; Function Attrs: norecurse nounwind readonly uwtable
28 define dso_local i32 @caller(ptr nocapture readonly %arr) local_unnamed_addr #0 !dbg !18 {
30 %0 = load i32, ptr %arr, align 4, !dbg !19, !tbaa !11
31 %arrayidx2.i = getelementptr inbounds i32, ptr %arr, i64 2, !dbg !21
32 %1 = load i32, ptr %arrayidx2.i, align 4, !dbg !21, !tbaa !11
33 %add.i = add nsw i32 %1, %0, !dbg !22
34 ret i32 %add.i, !dbg !23
37 attributes #0 = { "target-cpu"="x86-64" }
40 !llvm.module.flags = !{!3, !4, !5}
43 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 7.0.0 (trunk 324940) (llvm/trunk 324941)", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2, debugInfoForProfiling: true)
44 !1 = !DIFile(filename: "test.cc", directory: "/tmp")
46 !3 = !{i32 2, !"Dwarf Version", i32 4}
47 !4 = !{i32 2, !"Debug Info Version", i32 3}
48 !5 = !{i32 1, !"wchar_size", i32 4}
49 !6 = !{!"clang version 7.0.0 (trunk 324940) (llvm/trunk 324941)"}
50 !7 = distinct !DISubprogram(name: "sum", linkageName: "sum", scope: !8, file: !8, line: 3, type: !9, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0)
51 !8 = !DIFile(filename: "./test.h", directory: "/tmp")
52 !9 = !DISubroutineType(types: !2)
53 !10 = !DILocation(line: 6, column: 10, scope: !7)
54 !11 = !{!12, !12, i64 0}
55 !12 = !{!"int", !13, i64 0}
56 !13 = !{!"omnipotent char", !14, i64 0}
57 !14 = !{!"Simple C++ TBAA"}
58 !15 = !DILocation(line: 6, column: 22, scope: !7)
59 !16 = !DILocation(line: 6, column: 20, scope: !7)
60 !17 = !DILocation(line: 6, column: 3, scope: !7)
61 !18 = distinct !DISubprogram(name: "caller", linkageName: "caller", scope: !1, file: !1, line: 4, type: !9, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, unit: !0)
62 !19 = !DILocation(line: 6, column: 10, scope: !7, inlinedAt: !20)
63 !20 = distinct !DILocation(line: 6, column: 10, scope: !18)
64 !21 = !DILocation(line: 6, column: 22, scope: !7, inlinedAt: !20)
65 !22 = !DILocation(line: 6, column: 20, scope: !7, inlinedAt: !20)
66 !23 = !DILocation(line: 6, column: 3, scope: !18)
68 ; CHECK-LABEL: caller:
69 ; CHECK-LABEL: # %bb.0:
70 ; CHECK-NEXT: .loc 1 6 22 prologue_end
71 ; CHECK-NEXT: prefetchnta 23464(%rdi)
72 ; CHECK-NEXT: movl 8(%rdi), %eax
73 ; CHECK-NEXT: .loc 1 6 20 is_stmt 0 discriminator 2
74 ; CHECK-NEXT: prefetchnta 8764(%rdi)
75 ; CHECK-NEXT: prefetchnta 64(%rdi)
76 ; CHECK-NEXT: addl (%rdi), %eax