summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/llvm-profdata
diff options
context:
space:
mode:
authorWenlei He <aktoon@gmail.com>2019-08-20 20:52:00 +0000
committerWenlei He <aktoon@gmail.com>2019-08-20 20:52:00 +0000
commit5adace352d5ef63fe344dc95a375bd33040ea987 (patch)
tree8247dcac8fda3ef360d345a46e1a15aa4c35d286 /llvm/test/tools/llvm-profdata
parent48e81e8e10ed869f986a256127327713d362eec8 (diff)
downloadbcm5719-llvm-5adace352d5ef63fe344dc95a375bd33040ea987.tar.gz
bcm5719-llvm-5adace352d5ef63fe344dc95a375bd33040ea987.zip
[AutoFDO] Make call targets order deterministic for sample profile
Summary: StringMap is used for storing call target to frequency map for AutoFDO. However the iterating order of StringMap is non-deterministic, which leads to non-determinism in AutoFDO profile output. Now new API getSortedCallTargets and SortCallTargets are added for deterministic ordering and output. Roundtrip test for text profile and binary profile is added. Reviewers: wmi, davidxl, danielcdh Subscribers: hiraditya, mgrang, llvm-commits, twoh Tags: #llvm Differential Revision: https://reviews.llvm.org/D66191 llvm-svn: 369440
Diffstat (limited to 'llvm/test/tools/llvm-profdata')
-rw-r--r--llvm/test/tools/llvm-profdata/Inputs/sample-profile.proftext8
-rw-r--r--llvm/test/tools/llvm-profdata/roundtrip.test3
-rw-r--r--llvm/test/tools/llvm-profdata/sample-profile-basic.test4
3 files changed, 9 insertions, 6 deletions
diff --git a/llvm/test/tools/llvm-profdata/Inputs/sample-profile.proftext b/llvm/test/tools/llvm-profdata/Inputs/sample-profile.proftext
index e34128faabc..f9f87dfd661 100644
--- a/llvm/test/tools/llvm-profdata/Inputs/sample-profile.proftext
+++ b/llvm/test/tools/llvm-profdata/Inputs/sample-profile.proftext
@@ -1,7 +1,3 @@
-_Z3bari:20301:1437
- 1: 1437
-_Z3fooi:7711:610
- 1: 610
main:184019:0
4: 534
4.2: 534
@@ -14,3 +10,7 @@ main:184019:0
1: 1000
10: inline2:2000
1: 2000
+_Z3bari:20301:1437
+ 1: 1437
+_Z3fooi:7711:610
+ 1: 610
diff --git a/llvm/test/tools/llvm-profdata/roundtrip.test b/llvm/test/tools/llvm-profdata/roundtrip.test
index eda2720f454..00abc40b87e 100644
--- a/llvm/test/tools/llvm-profdata/roundtrip.test
+++ b/llvm/test/tools/llvm-profdata/roundtrip.test
@@ -4,3 +4,6 @@ RUN: diff %t.0.proftext %S/Inputs/IR_profile.proftext
RUN: llvm-profdata merge -o %t.1.profdata %t.0.proftext
RUN: llvm-profdata show -o %t.1.proftext -all-functions -text %t.1.profdata
RUN: diff %t.1.proftext %S/Inputs/IR_profile.proftext
+RUN: llvm-profdata merge --sample --binary -output=%t.2.profdata %S/Inputs/sample-profile.proftext
+RUN: llvm-profdata merge --sample --text -output=%t.2.proftext %t.2.profdata
+RUN: diff %t.2.proftext %S/Inputs/sample-profile.proftext \ No newline at end of file
diff --git a/llvm/test/tools/llvm-profdata/sample-profile-basic.test b/llvm/test/tools/llvm-profdata/sample-profile-basic.test
index 3ba42c20f2e..0b0d37aac36 100644
--- a/llvm/test/tools/llvm-profdata/sample-profile-basic.test
+++ b/llvm/test/tools/llvm-profdata/sample-profile-basic.test
@@ -3,7 +3,7 @@ Basic tests for sample profiles.
1- Show all functions
RUN: llvm-profdata show --sample %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=SHOW1
SHOW1-DAG: Function: main: 184019, 0, 7 sampled lines
-SHOW1-DAG: 9: 2064, calls: _Z3fooi:631 _Z3bari:1471
+SHOW1-DAG: 9: 2064, calls: _Z3bari:1471 _Z3fooi:631
SHOW1-DAG: Function: _Z3fooi: 7711, 610, 1 sampled lines
SHOW1-DAG: Function: _Z3bari: 20301, 1437, 1 sampled lines
SHOW1-DAG: 1: 1437
@@ -26,7 +26,7 @@ RUN: diff %t-binary %t-text
RUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext -o %t-binprof
RUN: llvm-profdata merge --sample --text %p/Inputs/sample-profile.proftext %t-binprof -o - | FileCheck %s --check-prefix=MERGE1
MERGE1: main:368038:0
-MERGE1: 9: 4128 _Z3fooi:1262 _Z3bari:2942
+MERGE1: 9: 4128 _Z3bari:2942 _Z3fooi:1262
MERGE1: _Z3bari:40602:2874
MERGE1: _Z3fooi:15422:1220
OpenPOWER on IntegriCloud