[llvm] r301419 - [sampleprof] Drop test dependency on the string hash func (NFC)

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 26 08:39:53 PDT 2017


Author: vedantk
Date: Wed Apr 26 10:39:53 2017
New Revision: 301419

URL: http://llvm.org/viewvc/llvm-project?rev=301419&view=rev
Log:
[sampleprof] Drop test dependency on the string hash func (NFC)

The SampleProfWriter emits function information in an order determined
by the string hash function. The situation is a bit brittle, because
changing the hash function can break the tests.

Instead of sorting the function samples to get a relaible ordering (that
might be too expensive), make the tests not depend on a particular
ordering of function samples.

Differential Revision: https://reviews.llvm.org/D32516

Modified:
    llvm/trunk/test/tools/llvm-profdata/overflow-sample.test
    llvm/trunk/test/tools/llvm-profdata/sample-profile-basic.test
    llvm/trunk/test/tools/llvm-profdata/weight-sample.test

Modified: llvm/trunk/test/tools/llvm-profdata/overflow-sample.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-profdata/overflow-sample.test?rev=301419&r1=301418&r2=301419&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-profdata/overflow-sample.test (original)
+++ llvm/trunk/test/tools/llvm-profdata/overflow-sample.test Wed Apr 26 10:39:53 2017
@@ -4,40 +4,40 @@ Tests for overflow when merging sampled
 RUN: llvm-profdata merge -sample %p/Inputs/overflow-sample.proftext %p/Inputs/overflow-sample.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=MERGE_OVERFLOW
 RUN: llvm-profdata show -sample %t.out | FileCheck %s --check-prefix=SHOW_OVERFLOW
 MERGE_OVERFLOW: {{.*}}: main: Counter overflow
-SHOW_OVERFLOW: Function: main: 2000, 0, 2 sampled lines
-SHOW_OVERFLOW-NEXT: Samples collected in the function's body {
-SHOW_OVERFLOW-NEXT:   1: 1000, calls: _Z3bari:18446744073709551615
-SHOW_OVERFLOW-NEXT:   2: 1000, calls: _Z3fooi:18446744073709551615
-SHOW_OVERFLOW-NEXT: }
-SHOW_OVERFLOW-NEXT: No inlined callsites in this function
-SHOW_OVERFLOW-NEXT: Function: _Z3fooi: 18446744073709551615, 2000, 1 sampled lines
-SHOW_OVERFLOW-NEXT: Samples collected in the function's body {
-SHOW_OVERFLOW-NEXT:   1: 18446744073709551615
-SHOW_OVERFLOW-NEXT: }
-SHOW_OVERFLOW-NEXT: No inlined callsites in this function
-SHOW_OVERFLOW-NEXT: Function: _Z3bari: 18446744073709551615, 2000, 1 sampled lines
-SHOW_OVERFLOW-NEXT: Samples collected in the function's body {
-SHOW_OVERFLOW-NEXT:   1: 18446744073709551615
-SHOW_OVERFLOW-NEXT: }
-SHOW_OVERFLOW-NEXT: No inlined callsites in this function
+SHOW_OVERFLOW-DAG: Function: main: 2000, 0, 2 sampled lines
+SHOW_OVERFLOW-DAG: Samples collected in the function's body {
+SHOW_OVERFLOW-DAG:   1: 1000, calls: _Z3bari:18446744073709551615
+SHOW_OVERFLOW-DAG:   2: 1000, calls: _Z3fooi:18446744073709551615
+SHOW_OVERFLOW-DAG: }
+SHOW_OVERFLOW-DAG: No inlined callsites in this function
+SHOW_OVERFLOW-DAG: Function: _Z3fooi: 18446744073709551615, 2000, 1 sampled lines
+SHOW_OVERFLOW-DAG: Samples collected in the function's body {
+SHOW_OVERFLOW-DAG:   1: 18446744073709551615
+SHOW_OVERFLOW-DAG: }
+SHOW_OVERFLOW-DAG: No inlined callsites in this function
+SHOW_OVERFLOW-DAG: Function: _Z3bari: 18446744073709551615, 2000, 1 sampled lines
+SHOW_OVERFLOW-DAG: Samples collected in the function's body {
+SHOW_OVERFLOW-DAG:   1: 18446744073709551615
+SHOW_OVERFLOW-DAG: }
+SHOW_OVERFLOW-DAG: No inlined callsites in this function
 
 2- Merge profile having maximum counts by itself and verify no overflow
 RUN: llvm-profdata merge -sample %p/Inputs/overflow-sample.proftext -o %t.out 2>&1 | FileCheck %s -allow-empty -check-prefix=MERGE_NO_OVERFLOW
 RUN: llvm-profdata show -sample %t.out | FileCheck %s --check-prefix=SHOW_NO_OVERFLOW
 MERGE_NO_OVERFLOW-NOT: {{.*}}: main: Counter overflow
-SHOW_NO_OVERFLOW: Function: main: 1000, 0, 2 sampled lines
-SHOW_NO_OVERFLOW-NEXT: Samples collected in the function's body {
-SHOW_NO_OVERFLOW-NEXT:   1: 500, calls: _Z3bari:18446744073709551615
-SHOW_NO_OVERFLOW-NEXT:   2: 500, calls: _Z3fooi:18446744073709551615
-SHOW_NO_OVERFLOW-NEXT: }
-SHOW_NO_OVERFLOW-NEXT: No inlined callsites in this function
-SHOW_NO_OVERFLOW-NEXT: Function: _Z3fooi: 18446744073709551615, 1000, 1 sampled lines
-SHOW_NO_OVERFLOW-NEXT: Samples collected in the function's body {
-SHOW_NO_OVERFLOW-NEXT:   1: 18446744073709551615
-SHOW_NO_OVERFLOW-NEXT: }
-SHOW_NO_OVERFLOW-NEXT: No inlined callsites in this function
-SHOW_NO_OVERFLOW-NEXT: Function: _Z3bari: 18446744073709551615, 1000, 1 sampled lines
-SHOW_NO_OVERFLOW-NEXT: Samples collected in the function's body {
-SHOW_NO_OVERFLOW-NEXT:   1: 18446744073709551615
-SHOW_NO_OVERFLOW-NEXT: }
-SHOW_NO_OVERFLOW-NEXT: No inlined callsites in this function
+SHOW_NO_OVERFLOW-DAG: Function: main: 1000, 0, 2 sampled lines
+SHOW_NO_OVERFLOW-DAG: Samples collected in the function's body {
+SHOW_NO_OVERFLOW-DAG:   1: 500, calls: _Z3bari:18446744073709551615
+SHOW_NO_OVERFLOW-DAG:   2: 500, calls: _Z3fooi:18446744073709551615
+SHOW_NO_OVERFLOW-DAG: }
+SHOW_NO_OVERFLOW-DAG: No inlined callsites in this function
+SHOW_NO_OVERFLOW-DAG: Function: _Z3fooi: 18446744073709551615, 1000, 1 sampled lines
+SHOW_NO_OVERFLOW-DAG: Samples collected in the function's body {
+SHOW_NO_OVERFLOW-DAG:   1: 18446744073709551615
+SHOW_NO_OVERFLOW-DAG: }
+SHOW_NO_OVERFLOW-DAG: No inlined callsites in this function
+SHOW_NO_OVERFLOW-DAG: Function: _Z3bari: 18446744073709551615, 1000, 1 sampled lines
+SHOW_NO_OVERFLOW-DAG: Samples collected in the function's body {
+SHOW_NO_OVERFLOW-DAG:   1: 18446744073709551615
+SHOW_NO_OVERFLOW-DAG: }
+SHOW_NO_OVERFLOW-DAG: No inlined callsites in this function

Modified: llvm/trunk/test/tools/llvm-profdata/sample-profile-basic.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-profdata/sample-profile-basic.test?rev=301419&r1=301418&r2=301419&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-profdata/sample-profile-basic.test (original)
+++ llvm/trunk/test/tools/llvm-profdata/sample-profile-basic.test Wed Apr 26 10:39:53 2017
@@ -2,11 +2,11 @@ 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: Function: main: 184019, 0, 7 sampled lines
-SHOW1: 9: 2064, calls: _Z3fooi:631 _Z3bari:1471
-SHOW1: Function: _Z3fooi: 7711, 610, 1 sampled lines
-SHOW1: Function: _Z3bari: 20301, 1437, 1 sampled lines
-SHOW1: 1: 1437
+SHOW1-DAG: Function: main: 184019, 0, 7 sampled lines
+SHOW1-DAG: 9: 2064, calls: _Z3fooi:631 _Z3bari:1471
+SHOW1-DAG: Function: _Z3fooi: 7711, 610, 1 sampled lines
+SHOW1-DAG: Function: _Z3bari: 20301, 1437, 1 sampled lines
+SHOW1-DAG: 1: 1437
 
 2- Show only bar
 RUN: llvm-profdata show --sample --function=_Z3bari %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=SHOW2
@@ -25,9 +25,9 @@ RUN: diff %t-binary %t-text
    counters have doubled.
 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: _Z3fooi:15422:1220
+MERGE1-DAG: main:368038:0
+MERGE1-DAG: 9: 4128 _Z3fooi:1262 _Z3bari:2942
+MERGE1-DAG: _Z3fooi:15422:1220
 
 5- Detect invalid text encoding (e.g. instrumentation profile text format).
 RUN: not llvm-profdata show --sample %p/Inputs/foo3bar3-1.proftext 2>&1 | FileCheck %s --check-prefix=BADTEXT

Modified: llvm/trunk/test/tools/llvm-profdata/weight-sample.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-profdata/weight-sample.test?rev=301419&r1=301418&r2=301419&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-profdata/weight-sample.test (original)
+++ llvm/trunk/test/tools/llvm-profdata/weight-sample.test Wed Apr 26 10:39:53 2017
@@ -3,41 +3,41 @@ Tests for weighted merge of sample profi
 1- Merge the foo and bar profiles with unity weight and verify the combined output
 RUN: llvm-profdata merge -sample -text -weighted-input=1,%p/Inputs/weight-sample-bar.proftext -weighted-input=1,%p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s -check-prefix=1X_1X_WEIGHT
 RUN: llvm-profdata merge -sample -text -weighted-input=1,%p/Inputs/weight-sample-bar.proftext %p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s -check-prefix=1X_1X_WEIGHT
-1X_1X_WEIGHT: foo:1763288:35327
-1X_1X_WEIGHT-NEXT:  7: 35327
-1X_1X_WEIGHT-NEXT:  8: 35327
-1X_1X_WEIGHT-NEXT:  9: 6930
-1X_1X_WEIGHT-NEXT:  10: 29341
-1X_1X_WEIGHT-NEXT:  11: 11906
-1X_1X_WEIGHT-NEXT:  13: 18185 foo:19531
-1X_1X_WEIGHT-NEXT:  15: 36458
-1X_1X_WEIGHT-NEXT: bar:1772037:35370
-1X_1X_WEIGHT-NEXT:  17: 35370
-1X_1X_WEIGHT-NEXT:  18: 35370
-1X_1X_WEIGHT-NEXT:  19: 7005
-1X_1X_WEIGHT-NEXT:  20: 29407
-1X_1X_WEIGHT-NEXT:  21: 12170
-1X_1X_WEIGHT-NEXT:  23: 18150 bar:19829
-1X_1X_WEIGHT-NEXT:  25: 36666
+1X_1X_WEIGHT-DAG: foo:1763288:35327
+1X_1X_WEIGHT-DAG:  7: 35327
+1X_1X_WEIGHT-DAG:  8: 35327
+1X_1X_WEIGHT-DAG:  9: 6930
+1X_1X_WEIGHT-DAG:  10: 29341
+1X_1X_WEIGHT-DAG:  11: 11906
+1X_1X_WEIGHT-DAG:  13: 18185 foo:19531
+1X_1X_WEIGHT-DAG:  15: 36458
+1X_1X_WEIGHT-DAG: bar:1772037:35370
+1X_1X_WEIGHT-DAG:  17: 35370
+1X_1X_WEIGHT-DAG:  18: 35370
+1X_1X_WEIGHT-DAG:  19: 7005
+1X_1X_WEIGHT-DAG:  20: 29407
+1X_1X_WEIGHT-DAG:  21: 12170
+1X_1X_WEIGHT-DAG:  23: 18150 bar:19829
+1X_1X_WEIGHT-DAG:  25: 36666
 
 2- Merge the foo and bar profiles with weight 3x and 5x respectively and verify the combined output
 RUN: llvm-profdata merge -sample -text -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=5,%p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s -check-prefix=3X_5X_WEIGHT
-3X_5X_WEIGHT: foo:8816440:176635
-3X_5X_WEIGHT-NEXT:  7: 176635
-3X_5X_WEIGHT-NEXT:  8: 176635
-3X_5X_WEIGHT-NEXT:  9: 34650
-3X_5X_WEIGHT-NEXT:  10: 146705
-3X_5X_WEIGHT-NEXT:  11: 59530
-3X_5X_WEIGHT-NEXT:  13: 90925 foo:97655
-3X_5X_WEIGHT-NEXT:  15: 182290
-3X_5X_WEIGHT-NEXT: bar:5316111:106110
-3X_5X_WEIGHT-NEXT:  17: 106110
-3X_5X_WEIGHT-NEXT:  18: 106110
-3X_5X_WEIGHT-NEXT:  19: 21015
-3X_5X_WEIGHT-NEXT:  20: 88221
-3X_5X_WEIGHT-NEXT:  21: 36510
-3X_5X_WEIGHT-NEXT:  23: 54450 bar:59487
-3X_5X_WEIGHT-NEXT:  25: 109998
+3X_5X_WEIGHT-DAG: foo:8816440:176635
+3X_5X_WEIGHT-DAG:  7: 176635
+3X_5X_WEIGHT-DAG:  8: 176635
+3X_5X_WEIGHT-DAG:  9: 34650
+3X_5X_WEIGHT-DAG:  10: 146705
+3X_5X_WEIGHT-DAG:  11: 59530
+3X_5X_WEIGHT-DAG:  13: 90925 foo:97655
+3X_5X_WEIGHT-DAG:  15: 182290
+3X_5X_WEIGHT-DAG: bar:5316111:106110
+3X_5X_WEIGHT-DAG:  17: 106110
+3X_5X_WEIGHT-DAG:  18: 106110
+3X_5X_WEIGHT-DAG:  19: 21015
+3X_5X_WEIGHT-DAG:  20: 88221
+3X_5X_WEIGHT-DAG:  21: 36510
+3X_5X_WEIGHT-DAG:  23: 54450 bar:59487
+3X_5X_WEIGHT-DAG:  25: 109998
 
 3- Bad merge: invalid weight
 RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=0,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT




More information about the llvm-commits mailing list