summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/PGOProfile/Inputs/remap.map8
-rw-r--r--llvm/test/Transforms/PGOProfile/Inputs/remap.proftext8
-rw-r--r--llvm/test/Transforms/PGOProfile/remap.ll28
-rw-r--r--llvm/test/Transforms/SampleProfile/Inputs/remap.map8
-rw-r--r--llvm/test/Transforms/SampleProfile/Inputs/remap.prof10
-rw-r--r--llvm/test/Transforms/SampleProfile/remap.ll60
6 files changed, 122 insertions, 0 deletions
diff --git a/llvm/test/Transforms/PGOProfile/Inputs/remap.map b/llvm/test/Transforms/PGOProfile/Inputs/remap.map
new file mode 100644
index 00000000000..df3d82d38bd
--- /dev/null
+++ b/llvm/test/Transforms/PGOProfile/Inputs/remap.map
@@ -0,0 +1,8 @@
+# foo:: and foo::detail:: are equivalent
+name 3foo N3foo6detailE
+
+# foo::qux and foo::quux are equivalent
+type N3foo3quxE N3foo4quuxE
+
+# N::X and M::X are equivalent
+name N1N1XE N1M1XE
diff --git a/llvm/test/Transforms/PGOProfile/Inputs/remap.proftext b/llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
new file mode 100644
index 00000000000..40054d78f5a
--- /dev/null
+++ b/llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
@@ -0,0 +1,8 @@
+# :ir is the flag to indicate this is IR level profile.
+:ir
+_ZN3foo3barERKN1N1XINS_4quuxEEE
+25571299074
+2
+3
+2
+
diff --git a/llvm/test/Transforms/PGOProfile/remap.ll b/llvm/test/Transforms/PGOProfile/remap.ll
new file mode 100644
index 00000000000..2fdca9e33d1
--- /dev/null
+++ b/llvm/test/Transforms/PGOProfile/remap.ll
@@ -0,0 +1,28 @@
+; RUN: llvm-profdata merge %S/Inputs/remap.proftext -o %t.profdata
+; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -pgo-test-profile-remapping-file=%S/Inputs/remap.map -S | FileCheck %s --check-prefix=USE
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @_ZN3foo3barERKN1M1XINS_6detail3quxEEE(i32 %i) {
+; USE-LABEL: @_ZN3foo3barERKN1M1XINS_6detail3quxEEE
+; USE-SAME: !prof ![[FUNC_ENTRY_COUNT:[0-9]+]]
+entry:
+ %cmp = icmp sgt i32 %i, 0
+ br i1 %cmp, label %if.then, label %if.end
+; USE: br i1 %cmp, label %if.then, label %if.end
+; USE-SAME: !prof ![[BW_ENTRY:[0-9]+]]
+
+if.then:
+ %add = add nsw i32 %i, 2
+ br label %if.end
+
+if.end:
+ %retv = phi i32 [ %add, %if.then ], [ %i, %entry ]
+ ret i32 %retv
+}
+
+; USE-DAG: {{![0-9]+}} = !{i32 1, !"ProfileSummary", {{![0-9]+}}}
+; USE-DAG: {{![0-9]+}} = !{!"DetailedSummary", {{![0-9]+}}}
+; USE-DAG: ![[FUNC_ENTRY_COUNT]] = !{!"function_entry_count", i64 3}
+; USE-DAG: ![[BW_ENTRY]] = !{!"branch_weights", i32 2, i32 1}
diff --git a/llvm/test/Transforms/SampleProfile/Inputs/remap.map b/llvm/test/Transforms/SampleProfile/Inputs/remap.map
new file mode 100644
index 00000000000..df3d82d38bd
--- /dev/null
+++ b/llvm/test/Transforms/SampleProfile/Inputs/remap.map
@@ -0,0 +1,8 @@
+# foo:: and foo::detail:: are equivalent
+name 3foo N3foo6detailE
+
+# foo::qux and foo::quux are equivalent
+type N3foo3quxE N3foo4quuxE
+
+# N::X and M::X are equivalent
+name N1N1XE N1M1XE
diff --git a/llvm/test/Transforms/SampleProfile/Inputs/remap.prof b/llvm/test/Transforms/SampleProfile/Inputs/remap.prof
new file mode 100644
index 00000000000..8244a51a165
--- /dev/null
+++ b/llvm/test/Transforms/SampleProfile/Inputs/remap.prof
@@ -0,0 +1,10 @@
+_ZN3foo3barERKN1N1XINS_4quuxEEE:15680:2500
+ 1: 2500
+ 4: 1000
+ 5: 1000
+ 6: 800
+ 7: 500
+ 9: 10226
+ 10: 2243
+ 16: 0
+ 18: 0
diff --git a/llvm/test/Transforms/SampleProfile/remap.ll b/llvm/test/Transforms/SampleProfile/remap.ll
new file mode 100644
index 00000000000..206962a3bef
--- /dev/null
+++ b/llvm/test/Transforms/SampleProfile/remap.ll
@@ -0,0 +1,60 @@
+; RUN: opt %s -passes=sample-profile -sample-profile-file=%S/Inputs/remap.prof -sample-profile-remapping-file=%S/Inputs/remap.map | opt -analyze -branch-prob | FileCheck %s
+
+; Reduced from branch.ll
+
+declare i1 @foo()
+
+define void @_ZN3foo3barERKN1M1XINS_6detail3quxEEE() !dbg !2 {
+; CHECK: Printing analysis 'Branch Probability Analysis' for function '_ZN3foo3barERKN1M1XINS_6detail3quxEEE':
+
+entry:
+ %cmp = call i1 @foo(), !dbg !6
+ br i1 %cmp, label %if.then, label %if.end
+; CHECK: edge entry -> if.then probability is 0x4ccf6b16 / 0x80000000 = 60.01%
+; CHECK: edge entry -> if.end probability is 0x333094ea / 0x80000000 = 39.99%
+
+if.then:
+ br label %return
+
+if.end:
+ %cmp1 = call i1 @foo(), !dbg !7
+ br i1 %cmp1, label %if.then.2, label %if.else
+; CHECK: edge if.end -> if.then.2 probability is 0x6652c748 / 0x80000000 = 79.94%
+; CHECK: edge if.end -> if.else probability is 0x19ad38b8 / 0x80000000 = 20.06%
+
+if.then.2:
+ call i1 @foo(), !dbg !8
+ br label %for.cond
+
+for.cond:
+ %cmp5 = call i1 @foo()
+ br i1 %cmp5, label %for.body, label %for.end, !prof !9
+; CHECK: edge for.cond -> for.body probability is 0x73333333 / 0x80000000 = 90.00%
+; CHECK: edge for.cond -> for.end probability is 0x0ccccccd / 0x80000000 = 10.00%
+
+for.body:
+ br label %for.cond
+
+for.end:
+ br label %return
+
+if.else:
+ br label %return
+
+return:
+ ret void
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!4, !5}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "foo++", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, enums: !{}, retainedTypes: !{})
+!1 = !DIFile(filename: "test.cc", directory: "/foo/bar")
+!2 = distinct !DISubprogram(name: "_ZN3foo3barERKN1M1XINS_6detail3quxEEE", scope: !1, file: !1, line: 4, type: !3, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !{})
+!3 = !DISubroutineType(types: !{})
+!4 = !{i32 2, !"Dwarf Version", i32 4}
+!5 = !{i32 2, !"Debug Info Version", i32 3}
+!6 = !DILocation(line: 5, column: 8, scope: !2)
+!7 = !DILocation(line: 8, column: 6, scope: !2)
+!8 = !DILocation(line: 10, column: 11, scope: !2)
+!9 = !{!"branch_weights", i32 90, i32 10}
OpenPOWER on IntegriCloud