diff options
Diffstat (limited to 'llvm/test/CodeGen')
| -rw-r--r-- | llvm/test/CodeGen/X86/discriminate-mem-ops.ll | 55 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/insert-prefetch-inline.afdo | 4 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/insert-prefetch-inline.ll | 76 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/insert-prefetch-no-MachineMemOperand.ll | 46 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/insert-prefetch-nomemop.afdo | 2 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/insert-prefetch-other.afdo | 3 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/insert-prefetch.afdo | 3 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/insert-prefetch.ll | 101 |
8 files changed, 290 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/discriminate-mem-ops.ll b/llvm/test/CodeGen/X86/discriminate-mem-ops.ll new file mode 100644 index 00000000000..b77a91fafd2 --- /dev/null +++ b/llvm/test/CodeGen/X86/discriminate-mem-ops.ll @@ -0,0 +1,55 @@ +; RUN: llc < %s | FileCheck %s +; +; original source, compiled with -O3 -gmlt -fdebug-info-for-profiling: +; int sum(int* arr, int pos1, int pos2) { +; return arr[pos1] + arr[pos2]; +; } +; +; ModuleID = 'test.cc' +source_filename = "test.cc" +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; Function Attrs: norecurse nounwind readonly uwtable +define i32 @sum(i32* %arr, i32 %pos1, i32 %pos2) !dbg !7 { +entry: + %idxprom = sext i32 %pos1 to i64, !dbg !9 + %arrayidx = getelementptr inbounds i32, i32* %arr, i64 %idxprom, !dbg !9 + %0 = load i32, i32* %arrayidx, align 4, !dbg !9, !tbaa !10 + %idxprom1 = sext i32 %pos2 to i64, !dbg !14 + %arrayidx2 = getelementptr inbounds i32, i32* %arr, i64 %idxprom1, !dbg !14 + %1 = load i32, i32* %arrayidx2, align 4, !dbg !14, !tbaa !10 + %add = add nsw i32 %1, %0, !dbg !15 + ret i32 %add, !dbg !16 +} + +attributes #0 = { "target-cpu"="x86-64" } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2, debugInfoForProfiling: true) +!1 = !DIFile(filename: "test.cc", directory: "/tmp") +!2 = !{} +!3 = !{i32 2, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{!"clang version 7.0.0 (trunk 322155) (llvm/trunk 322159)"} +!7 = distinct !DISubprogram(name: "sum", linkageName: "sum", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0) +!8 = !DISubroutineType(types: !2) +!9 = !DILocation(line: 2, column: 10, scope: !7) +!10 = !{!11, !11, i64 0} +!11 = !{!"int", !12, i64 0} +!12 = !{!"omnipotent char", !13, i64 0} +!13 = !{!"Simple C++ TBAA"} +!14 = !DILocation(line: 2, column: 22, scope: !7) +!15 = !DILocation(line: 2, column: 20, scope: !7) +!16 = !DILocation(line: 2, column: 3, scope: !7) + +;CHECK-LABEL: sum: +;CHECK: # %bb.0: +;CHECK: movl (%rdi,%rax,4), %eax +;CHECK-NEXT: .loc 1 2 20 discriminator 2 # test.cc:2:20 +;CHECK-NEXT: addl (%rdi,%rcx,4), %eax +;CHECK-NEXT: .loc 1 2 3 # test.cc:2:3 diff --git a/llvm/test/CodeGen/X86/insert-prefetch-inline.afdo b/llvm/test/CodeGen/X86/insert-prefetch-inline.afdo new file mode 100644 index 00000000000..83b30f6e210 --- /dev/null +++ b/llvm/test/CodeGen/X86/insert-prefetch-inline.afdo @@ -0,0 +1,4 @@ +caller:0:0 + 2:sum:0 + 3: 0 __prefetch_nta_0:23456 + 3.1: 0 __prefetch_nta_0:8764 __prefetch_nta_1:64
\ No newline at end of file diff --git a/llvm/test/CodeGen/X86/insert-prefetch-inline.ll b/llvm/test/CodeGen/X86/insert-prefetch-inline.ll new file mode 100644 index 00000000000..5f8373f9480 --- /dev/null +++ b/llvm/test/CodeGen/X86/insert-prefetch-inline.ll @@ -0,0 +1,76 @@ +; RUN: llc < %s -prefetch-hints-file=%S/insert-prefetch-inline.afdo | FileCheck %s +; +; Verify we can insert prefetch instructions in code belonging to inlined +; functions. +; +; ModuleID = 'test.cc' + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; Function Attrs: norecurse nounwind readonly uwtable +define dso_local i32 @sum(i32* nocapture readonly %arr, i32 %pos1, i32 %pos2) local_unnamed_addr #0 !dbg !7 { +entry: + %idxprom = sext i32 %pos1 to i64, !dbg !10 + %arrayidx = getelementptr inbounds i32, i32* %arr, i64 %idxprom, !dbg !10 + %0 = load i32, i32* %arrayidx, align 4, !dbg !10, !tbaa !11 + %idxprom1 = sext i32 %pos2 to i64, !dbg !15 + %arrayidx2 = getelementptr inbounds i32, i32* %arr, i64 %idxprom1, !dbg !15 + %1 = load i32, i32* %arrayidx2, align 4, !dbg !15, !tbaa !11 + %add = add nsw i32 %1, %0, !dbg !16 + ret i32 %add, !dbg !17 +} + +; "caller" inlines "sum". The associated .afdo file references instructions +; in "caller" that came from "sum"'s inlining. +; +; Function Attrs: norecurse nounwind readonly uwtable +define dso_local i32 @caller(i32* nocapture readonly %arr) local_unnamed_addr #0 !dbg !18 { +entry: + %0 = load i32, i32* %arr, align 4, !dbg !19, !tbaa !11 + %arrayidx2.i = getelementptr inbounds i32, i32* %arr, i64 2, !dbg !21 + %1 = load i32, i32* %arrayidx2.i, align 4, !dbg !21, !tbaa !11 + %add.i = add nsw i32 %1, %0, !dbg !22 + ret i32 %add.i, !dbg !23 +} + +attributes #0 = { "target-cpu"="x86-64" } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5} +!llvm.ident = !{!6} + +!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) +!1 = !DIFile(filename: "test.cc", directory: "/tmp") +!2 = !{} +!3 = !{i32 2, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{!"clang version 7.0.0 (trunk 324940) (llvm/trunk 324941)"} +!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) +!8 = !DIFile(filename: "./test.h", directory: "/tmp") +!9 = !DISubroutineType(types: !2) +!10 = !DILocation(line: 6, column: 10, scope: !7) +!11 = !{!12, !12, i64 0} +!12 = !{!"int", !13, i64 0} +!13 = !{!"omnipotent char", !14, i64 0} +!14 = !{!"Simple C++ TBAA"} +!15 = !DILocation(line: 6, column: 22, scope: !7) +!16 = !DILocation(line: 6, column: 20, scope: !7) +!17 = !DILocation(line: 6, column: 3, scope: !7) +!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) +!19 = !DILocation(line: 6, column: 10, scope: !7, inlinedAt: !20) +!20 = distinct !DILocation(line: 6, column: 10, scope: !18) +!21 = !DILocation(line: 6, column: 22, scope: !7, inlinedAt: !20) +!22 = !DILocation(line: 6, column: 20, scope: !7, inlinedAt: !20) +!23 = !DILocation(line: 6, column: 3, scope: !18) + +; CHECK-LABEL: caller: +; CHECK-LABEL: # %bb.0: +; CHECK-NEXT: .loc 1 6 22 prologue_end +; CHECK-NEXT: prefetchnta 23464(%rdi) +; CHECK-NEXT: movl 8(%rdi), %eax +; CHECK-NEXT: .loc 1 6 20 is_stmt 0 discriminator 2 +; CHECK-NEXT: prefetchnta 8764(%rdi) +; CHECK-NEXT: prefetchnta 64(%rdi) +; CHECK-NEXT: addl (%rdi), %eax diff --git a/llvm/test/CodeGen/X86/insert-prefetch-no-MachineMemOperand.ll b/llvm/test/CodeGen/X86/insert-prefetch-no-MachineMemOperand.ll new file mode 100644 index 00000000000..9d7757270d7 --- /dev/null +++ b/llvm/test/CodeGen/X86/insert-prefetch-no-MachineMemOperand.ll @@ -0,0 +1,46 @@ +; RUN: llc < %s -prefetch-hints-file=%S/insert-prefetch-nomemop.afdo | FileCheck %s +; ModuleID = 'prefetch.cc' +source_filename = "prefetch.cc" +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +; Function Attrs: norecurse nounwind uwtable +define dso_local i32 @main() local_unnamed_addr #0 !dbg !7 { +entry: + tail call void @llvm.prefetch(i8* inttoptr (i64 291 to i8*), i32 0, i32 0, i32 1), !dbg !9 + tail call void @llvm.x86.avx512.gatherpf.dpd.512(i8 97, <8 x i32> undef, i8* null, i32 1, i32 2), !dbg !10 + ret i32 291, !dbg !11 +} + +; Function Attrs: inaccessiblemem_or_argmemonly nounwind +declare void @llvm.prefetch(i8* nocapture readonly, i32, i32, i32) #1 + +; Function Attrs: argmemonly nounwind +declare void @llvm.x86.avx512.gatherpf.dpd.512(i8, <8 x i32>, i8*, i32, i32) #2 + +attributes #0 = {"target-cpu"="x86-64" "target-features"="+avx512pf,+sse4.2,+ssse3"} +attributes #1 = { inaccessiblemem_or_argmemonly nounwind } +attributes #2 = { argmemonly nounwind } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2, debugInfoForProfiling: true) +!1 = !DIFile(filename: "prefetch.cc", directory: "/tmp") +!2 = !{} +!3 = !{i32 2, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{!"clang version 7.0.0 (trunk 327078) (llvm/trunk 327086)"} +!7 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 8, type: !8, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0) +!8 = !DISubroutineType(types: !2) +!9 = !DILocation(line: 12, column: 3, scope: !7) +!10 = !DILocation(line: 14, column: 3, scope: !7) +!11 = !DILocation(line: 15, column: 3, scope: !7) + +;CHECK-LABEL: main: +;CHECK: # %bb.0: +;CHECK: prefetchnta 291 +;CHECK: prefetchnta 42(%rax,%ymm0) +;CHECK-NEXT: vgatherpf1dpd (%rax,%ymm0) {%k1} diff --git a/llvm/test/CodeGen/X86/insert-prefetch-nomemop.afdo b/llvm/test/CodeGen/X86/insert-prefetch-nomemop.afdo new file mode 100644 index 00000000000..6385a498b8f --- /dev/null +++ b/llvm/test/CodeGen/X86/insert-prefetch-nomemop.afdo @@ -0,0 +1,2 @@ +main:0:0 + 6: 0 __prefetch_nta_0:42
\ No newline at end of file diff --git a/llvm/test/CodeGen/X86/insert-prefetch-other.afdo b/llvm/test/CodeGen/X86/insert-prefetch-other.afdo new file mode 100644 index 00000000000..783da34f7f8 --- /dev/null +++ b/llvm/test/CodeGen/X86/insert-prefetch-other.afdo @@ -0,0 +1,3 @@ +sum:0:0 + 1: 0 __prefetch_t0_1:0 __prefetch_t2_0:42 + 1.1: 0 __prefetch_t1_0:18446744073709551615 diff --git a/llvm/test/CodeGen/X86/insert-prefetch.afdo b/llvm/test/CodeGen/X86/insert-prefetch.afdo new file mode 100644 index 00000000000..96487e85eaa --- /dev/null +++ b/llvm/test/CodeGen/X86/insert-prefetch.afdo @@ -0,0 +1,3 @@ +sum:0:0 + 1: 0 __prefetch_nta_1:0 __prefetch_nta_0:42 + 1.1: 0 __prefetch_nta_0:18446744073709551615 diff --git a/llvm/test/CodeGen/X86/insert-prefetch.ll b/llvm/test/CodeGen/X86/insert-prefetch.ll new file mode 100644 index 00000000000..9e77772df77 --- /dev/null +++ b/llvm/test/CodeGen/X86/insert-prefetch.ll @@ -0,0 +1,101 @@ +; RUN: llc < %s -prefetch-hints-file=%S/insert-prefetch.afdo | FileCheck %s +; RUN: llc < %s -prefetch-hints-file=%S/insert-prefetch-other.afdo | FileCheck %s -check-prefix=OTHERS +; +; original source, compiled with -O3 -gmlt -fdebug-info-for-profiling: +; int sum(int* arr, int pos1, int pos2) { +; return arr[pos1] + arr[pos2]; +; } +; +; NOTE: debug line numbers were adjusted such that the function would start +; at line 15 (an arbitrary number). The sample profile file format uses +; offsets from the start of the symbol instead of file-relative line numbers. +; The .afdo file reflects that - the instructions are offset '1'. +; +; ModuleID = 'test.cc' +source_filename = "test.cc" +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define i32 @sum(i32* %arr, i32 %pos1, i32 %pos2) !dbg !35 !prof !37 { +entry: + %idxprom = sext i32 %pos1 to i64, !dbg !38 + %arrayidx = getelementptr inbounds i32, i32* %arr, i64 %idxprom, !dbg !38 + %0 = load i32, i32* %arrayidx, align 4, !dbg !38, !tbaa !39 + %idxprom1 = sext i32 %pos2 to i64, !dbg !43 + %arrayidx2 = getelementptr inbounds i32, i32* %arr, i64 %idxprom1, !dbg !43 + %1 = load i32, i32* %arrayidx2, align 4, !dbg !43, !tbaa !39 + %add = add nsw i32 %1, %0, !dbg !44 + ret i32 %add, !dbg !45 +} + +attributes #0 = { "target-cpu"="x86-64" } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5, !6} +!llvm.ident = !{!33} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2, debugInfoForProfiling: true) +!1 = !DIFile(filename: "test.cc", directory: "/tmp") +!2 = !{} +!3 = !{i32 2, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{i32 1, !"ProfileSummary", !7} +!7 = !{!8, !9, !10, !11, !12, !13, !14, !15} +!8 = !{!"ProfileFormat", !"SampleProfile"} +!9 = !{!"TotalCount", i64 0} +!10 = !{!"MaxCount", i64 0} +!11 = !{!"MaxInternalCount", i64 0} +!12 = !{!"MaxFunctionCount", i64 0} +!13 = !{!"NumCounts", i64 2} +!14 = !{!"NumFunctions", i64 1} +!15 = !{!"DetailedSummary", !16} +!16 = !{!17, !18, !19, !20, !21, !22, !22, !23, !23, !24, !25, !26, !27, !28, !29, !30, !31, !32} +!17 = !{i32 10000, i64 0, i32 0} +!18 = !{i32 100000, i64 0, i32 0} +!19 = !{i32 200000, i64 0, i32 0} +!20 = !{i32 300000, i64 0, i32 0} +!21 = !{i32 400000, i64 0, i32 0} +!22 = !{i32 500000, i64 0, i32 0} +!23 = !{i32 600000, i64 0, i32 0} +!24 = !{i32 700000, i64 0, i32 0} +!25 = !{i32 800000, i64 0, i32 0} +!26 = !{i32 900000, i64 0, i32 0} +!27 = !{i32 950000, i64 0, i32 0} +!28 = !{i32 990000, i64 0, i32 0} +!29 = !{i32 999000, i64 0, i32 0} +!30 = !{i32 999900, i64 0, i32 0} +!31 = !{i32 999990, i64 0, i32 0} +!32 = !{i32 999999, i64 0, i32 0} +!33 = !{!"clang version 7.0.0 (trunk 322593) (llvm/trunk 322526)"} +!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) +!36 = !DISubroutineType(types: !2) +!37 = !{!"function_entry_count", i64 -1} +!38 = !DILocation(line: 16, column: 10, scope: !35) +!39 = !{!40, !40, i64 0} +!40 = !{!"int", !41, i64 0} +!41 = !{!"omnipotent char", !42, i64 0} +!42 = !{!"Simple C++ TBAA"} +!43 = !DILocation(line: 16, column: 22, scope: !35) +!44 = !DILocation(line: 16, column: 20, scope: !35) +!45 = !DILocation(line: 16, column: 3, scope: !35) + +;CHECK-LABEL: sum: +;CHECK: # %bb.0: +;CHECK: prefetchnta 42(%rdi,%rax,4) +;CHECK-NEXT: prefetchnta (%rdi,%rax,4) +;CHECK-NEXT: movl (%rdi,%rax,4), %eax +;CHECK-NEXT: .loc 1 16 20 discriminator 2 # test.cc:16:20 +;CHECK-NEXT: prefetchnta -1(%rdi,%rcx,4) +;CHECK-NEXT: addl (%rdi,%rcx,4), %eax +;CHECK-NEXT: .loc 1 16 3 # test.cc:16:3 + +;OTHERS-LABEL: sum: +;OTHERS: # %bb.0: +;OTHERS: prefetcht2 42(%rdi,%rax,4) +;OTHERS-NEXT: prefetcht0 (%rdi,%rax,4) +;OTHERS-NEXT: movl (%rdi,%rax,4), %eax +;OTHERS-NEXT: .loc 1 16 20 discriminator 2 # test.cc:16:20 +;OTHERS-NEXT: prefetcht1 -1(%rdi,%rcx,4) +;OTHERS-NEXT: addl (%rdi,%rcx,4), %eax +;OTHERS-NEXT: .loc 1 16 3 # test.cc:16:3 |

