[llvm] 1422fa5 - [llvm-profgen] Unify output format of different unsymbolized profiles
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 24 14:20:22 PDT 2021
Author: wlei
Date: 2021-09-24T14:18:00-07:00
New Revision: 1422fa5fab369b0ec223b58788c68f91a4093076
URL: https://github.com/llvm/llvm-project/commit/1422fa5fab369b0ec223b58788c68f91a4093076
DIFF: https://github.com/llvm/llvm-project/commit/1422fa5fab369b0ec223b58788c68f91a4093076.diff
LOG: [llvm-profgen] Unify output format of different unsymbolized profiles
Differential Revision: https://reviews.llvm.org/D110080
Added:
Modified:
llvm/test/tools/llvm-profgen/cs-interrupt.test
llvm/test/tools/llvm-profgen/inline-cs-noprobe.test
llvm/test/tools/llvm-profgen/inline-cs-pseudoprobe.test
llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test
llvm/test/tools/llvm-profgen/noinline-cs-pseudoprobe.test
llvm/test/tools/llvm-profgen/recursion-compression-pseudoprobe.test
llvm/tools/llvm-profgen/PerfReader.cpp
llvm/tools/llvm-profgen/PerfReader.h
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-profgen/cs-interrupt.test b/llvm/test/tools/llvm-profgen/cs-interrupt.test
index f0fdb95d61bc..95f38376e28d 100644
--- a/llvm/test/tools/llvm-profgen/cs-interrupt.test
+++ b/llvm/test/tools/llvm-profgen/cs-interrupt.test
@@ -15,26 +15,24 @@
; CHECK: 2: 3
; CHECK: 5: 4
-; CHECK-UNWINDER: Binary(noinline-cs-noprobe.perfbin)'s Range Counter:
-; CHECK-UNWINDER: main:1 @ foo
-; CHECK-UNWINDER: (5ff, 62f): 5
-; CHECK-UNWINDER: (634, 637): 4
-; CHECK-UNWINDER: (645, 645): 5
-; CHECK-UNWINDER: main:1 @ foo:3 @ bar
-; CHECK-UNWINDER: (5b0, 5c8): 2
-; CHECK-UNWINDER: (5b0, 5d7): 3
-; CHECK-UNWINDER: (5e5, 5e9): 4
-
-; CHECK-UNWINDER: Binary(noinline-cs-noprobe.perfbin)'s Branch Counter:
-; CHECK-UNWINDER: main:1 @ foo
-; CHECK-UNWINDER: (62f, 5b0): 5
-; CHECK-UNWINDER: (637, 645): 5
-; CHECK-UNWINDER: (645, 5ff): 5
-; CHECK-UNWINDER: main:1 @ foo:3 @ bar
-; CHECK-UNWINDER: (5c8, 5dc): 2
-; CHECK-UNWINDER: (5d7, 5e5): 4
-; CHECK-UNWINDER: (5e9, 634): 4
-
+; CHECK-UNWINDER: [main:1 @ foo]
+; CHECK-UNWINDER-NEXT: 3
+; CHECK-UNWINDER-NEXT: 5ff-62f:5
+; CHECK-UNWINDER-NEXT: 634-637:4
+; CHECK-UNWINDER-NEXT: 645-645:5
+; CHECK-UNWINDER-NEXT: 3
+; CHECK-UNWINDER-NEXT: 62f->5b0:5
+; CHECK-UNWINDER-NEXT: 637->645:5
+; CHECK-UNWINDER-NEXT: 645->5ff:5
+; CHECK-UNWINDER-NEXT: [main:1 @ foo:3 @ bar]
+; CHECK-UNWINDER-NEXT: 3
+; CHECK-UNWINDER-NEXT: 5b0-5c8:2
+; CHECK-UNWINDER-NEXT: 5b0-5d7:3
+; CHECK-UNWINDER-NEXT: 5e5-5e9:4
+; CHECK-UNWINDER-NEXT: 3
+; CHECK-UNWINDER-NEXT: 5c8->5dc:2
+; CHECK-UNWINDER-NEXT: 5d7->5e5:4
+; CHECK-UNWINDER-NEXT: 5e9->634:4
; original code:
diff --git a/llvm/test/tools/llvm-profgen/inline-cs-noprobe.test b/llvm/test/tools/llvm-profgen/inline-cs-noprobe.test
index ae7e6e5f932f..dfdc189f6bea 100644
--- a/llvm/test/tools/llvm-profgen/inline-cs-noprobe.test
+++ b/llvm/test/tools/llvm-profgen/inline-cs-noprobe.test
@@ -1,5 +1,5 @@
; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-cs-noprobe.perfscript --binary=%S/Inputs/inline-cs-noprobe.perfbin --output=%t --skip-symbolization --profile-summary-cold-count=0
-| FileCheck %s --input-file %t --check-prefix=CHECK-UNWINDER
+; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-UNWINDER
; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-cs-noprobe.perfscript --binary=%S/Inputs/inline-cs-noprobe.perfbin --output=%t --profile-summary-cold-count=0
; RUN: FileCheck %s --input-file %t
@@ -11,19 +11,19 @@
; CHECK:[main:1 @ foo:3.1 @ bar]:84:0
; CHECK: 1: 14
-; CHECK-UNWINDER: Binary(inline-cs-noprobe.perfbin)'s Range Counter:
-; CHECK-UNWINDER: main:1 @ foo
-; CHECK-UNWINDER: (670, 6ad): 1
-; CHECK-UNWINDER: (67e, 69b): 1
-; CHECK-UNWINDER: (67e, 6ad): 13
-; CHECK-UNWINDER: (6bd, 6c8): 14
-; CHECK-UNWINDER: main:1 @ foo:3.1 @ bar
-; CHECK-UNWINDER: (6af, 6bb): 14
-
-; CHECK-UNWINDER: Binary(inline-cs-noprobe.perfbin)'s Branch Counter:
-; CHECK-UNWINDER: main:1 @ foo
-; CHECK-UNWINDER: (69b, 670): 1
-; CHECK-UNWINDER: (6c8, 67e): 15
+; CHECK-UNWINDER: [main:1 @ foo]
+; CHECK-UNWINDER: 4
+; CHECK-UNWINDER: 670-6ad:1
+; CHECK-UNWINDER: 67e-69b:1
+; CHECK-UNWINDER: 67e-6ad:13
+; CHECK-UNWINDER: 6bd-6c8:14
+; CHECK-UNWINDER: 2
+; CHECK-UNWINDER: 69b->670:1
+; CHECK-UNWINDER: 6c8->67e:15
+; CHECK-UNWINDER: [main:1 @ foo:3.1 @ bar]
+; CHECK-UNWINDER: 1
+; CHECK-UNWINDER: 6af-6bb:14
+; CHECK-UNWINDER: 0
; original code:
; clang -O3 -g test.c -o a.out
diff --git a/llvm/test/tools/llvm-profgen/inline-cs-pseudoprobe.test b/llvm/test/tools/llvm-profgen/inline-cs-pseudoprobe.test
index 04faab2fda3e..f2c52e716db2 100644
--- a/llvm/test/tools/llvm-profgen/inline-cs-pseudoprobe.test
+++ b/llvm/test/tools/llvm-profgen/inline-cs-pseudoprobe.test
@@ -1,4 +1,4 @@
-; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-cs-pseudoprobe.perfscript --binary=%S/Inputs/inline-cs-pseudoprobe.perfbin --output=%t --skip-symbolization --profile-summary-cold-count=0
+; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-cs-pseudoprobe.perfscript --binary=%S/Inputs/inline-cs-pseudoprobe.perfbin --output=%t --skip-symbolization --profile-summary-cold-count=0 --use-offset=0
; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-UNWINDER
; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-cs-pseudoprobe.perfscript --binary=%S/Inputs/inline-cs-pseudoprobe.perfbin --output=%t --profile-summary-cold-count=0
; RUN: FileCheck %s --input-file %t
@@ -19,17 +19,13 @@
; CHECK-NEXT: 4: 14
; CHECK-NEXT: !CFGChecksum: 72617220756
-
-; CHECK-UNWINDER: Binary(inline-cs-pseudoprobe.perfbin)'s Range Counter:
-; CHECK-UNWINDER-EMPTY:
-; CHECK-UNWINDER-NEXT: (800, 858): 1
-; CHECK-UNWINDER-NEXT: (80e, 82b): 1
-; CHECK-UNWINDER-NEXT: (80e, 858): 13
-
-; CHECK-UNWINDER: Binary(inline-cs-pseudoprobe.perfbin)'s Branch Counter:
-; CHECK-UNWINDER-EMPTY:
-; CHECK-UNWINDER-NEXT: (82b, 800): 1
-; CHECK-UNWINDER-NEXT: (858, 80e): 15
+; CHECK-UNWINDER: 3
+; CHECK-UNWINDER-NEXT: 201800-201858:1
+; CHECK-UNWINDER-NEXT: 20180e-20182b:1
+; CHECK-UNWINDER-NEXT: 20180e-201858:13
+; CHECK-UNWINDER-NEXT: 2
+; CHECK-UNWINDER-NEXT: 20182b->201800:1
+; CHECK-UNWINDER-NEXT: 201858->20180e:15
; clang -O3 -fexperimental-new-pass-manager -fuse-ld=lld -fpseudo-probe-for-profiling
; -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Xclang -mdisable-tail-calls
diff --git a/llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test b/llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test
index 7004ce53cc46..c26cac969b81 100644
--- a/llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test
+++ b/llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test
@@ -27,27 +27,25 @@
; CHECK-AGG: 4: 2
; CHECK-AGG: 5: 6
-; CHECK-AGG-UNWINDER: Binary(noinline-cs-noprobe.perfbin)'s Range Counter:
-; CHECK-AGG-UNWINDER: main:1 @ foo
-; CHECK-AGG-UNWINDER: (5ff, 62f): 6
-; CHECK-AGG-UNWINDER: (634, 637): 6
-; CHECK-AGG-UNWINDER: (645, 645): 6
-; CHECK-AGG-UNWINDER: main:1 @ foo:3 @ bar
-; CHECK-AGG-UNWINDER: (5b0, 5c8): 2
-; CHECK-AGG-UNWINDER: (5b0, 5d7): 4
-; CHECK-AGG-UNWINDER: (5dc, 5e9): 2
-; CHECK-AGG-UNWINDER: (5e5, 5e9): 4
-
-; CHECK-AGG-UNWINDER: Binary(noinline-cs-noprobe.perfbin)'s Branch Counter:
-; CHECK-AGG-UNWINDER: main:1 @ foo
-; CHECK-AGG-UNWINDER: (62f, 5b0): 6
-; CHECK-AGG-UNWINDER: (637, 645): 6
-; CHECK-AGG-UNWINDER: (645, 5ff): 6
-; CHECK-AGG-UNWINDER: main:1 @ foo:3 @ bar
-; CHECK-AGG-UNWINDER: (5c8, 5dc): 4
-; CHECK-AGG-UNWINDER: (5d7, 5e5): 4
-; CHECK-AGG-UNWINDER: (5e9, 634): 6
-
+; CHECK-AGG-UNWINDER: [main:1 @ foo]
+; CHECK-AGG-UNWINDER-NEXT: 3
+; CHECK-AGG-UNWINDER-NEXT: 5ff-62f:6
+; CHECK-AGG-UNWINDER-NEXT: 634-637:6
+; CHECK-AGG-UNWINDER-NEXT: 645-645:6
+; CHECK-AGG-UNWINDER-NEXT: 3
+; CHECK-AGG-UNWINDER-NEXT: 62f->5b0:6
+; CHECK-AGG-UNWINDER-NEXT: 637->645:6
+; CHECK-AGG-UNWINDER-NEXT: 645->5ff:6
+; CHECK-AGG-UNWINDER-NEXT: [main:1 @ foo:3 @ bar]
+; CHECK-AGG-UNWINDER-NEXT: 4
+; CHECK-AGG-UNWINDER-NEXT: 5b0-5c8:2
+; CHECK-AGG-UNWINDER-NEXT: 5b0-5d7:4
+; CHECK-AGG-UNWINDER-NEXT: 5dc-5e9:2
+; CHECK-AGG-UNWINDER-NEXT: 5e5-5e9:4
+; CHECK-AGG-UNWINDER-NEXT: 3
+; CHECK-AGG-UNWINDER-NEXT: 5c8->5dc:4
+; CHECK-AGG-UNWINDER-NEXT: 5d7->5e5:4
+; CHECK-AGG-UNWINDER-NEXT: 5e9->634:6
; CHECK:[main:1 @ foo]:54:0
@@ -60,26 +58,26 @@
; CHECK: 4: 1
; CHECK: 5: 3
-; CHECK-UNWINDER: Binary(noinline-cs-noprobe.perfbin)'s Range Counter:
-; CHECK-UNWINDER: main:1 @ foo
-; CHECK-UNWINDER: (5ff, 62f): 3
-; CHECK-UNWINDER: (634, 637): 3
-; CHECK-UNWINDER: (645, 645): 3
-; CHECK-UNWINDER: main:1 @ foo:3 @ bar
-; CHECK-UNWINDER: (5b0, 5c8): 1
-; CHECK-UNWINDER: (5b0, 5d7): 2
-; CHECK-UNWINDER: (5dc, 5e9): 1
-; CHECK-UNWINDER: (5e5, 5e9): 2
-
-; CHECK-UNWINDER: Binary(noinline-cs-noprobe.perfbin)'s Branch Counter:
-; CHECK-UNWINDER: main:1 @ foo
-; CHECK-UNWINDER: (62f, 5b0): 3
-; CHECK-UNWINDER: (637, 645): 3
-; CHECK-UNWINDER: (645, 5ff): 3
-; CHECK-UNWINDER: main:1 @ foo:3 @ bar
-; CHECK-UNWINDER: (5c8, 5dc): 2
-; CHECK-UNWINDER: (5d7, 5e5): 2
-; CHECK-UNWINDER: (5e9, 634): 3
+
+; CHECK-UNWINDER: [main:1 @ foo]
+; CHECK-UNWINDER-NEXT: 3
+; CHECK-UNWINDER-NEXT: 5ff-62f:3
+; CHECK-UNWINDER-NEXT: 634-637:3
+; CHECK-UNWINDER-NEXT: 645-645:3
+; CHECK-UNWINDER-NEXT: 3
+; CHECK-UNWINDER-NEXT: 62f->5b0:3
+; CHECK-UNWINDER-NEXT: 637->645:3
+; CHECK-UNWINDER-NEXT: 645->5ff:3
+; CHECK-UNWINDER-NEXT: [main:1 @ foo:3 @ bar]
+; CHECK-UNWINDER-NEXT: 4
+; CHECK-UNWINDER-NEXT: 5b0-5c8:1
+; CHECK-UNWINDER-NEXT: 5b0-5d7:2
+; CHECK-UNWINDER-NEXT: 5dc-5e9:1
+; CHECK-UNWINDER-NEXT: 5e5-5e9:2
+; CHECK-UNWINDER-NEXT: 3
+; CHECK-UNWINDER-NEXT: 5c8->5dc:2
+; CHECK-UNWINDER-NEXT: 5d7->5e5:2
+; CHECK-UNWINDER-NEXT: 5e9->634:3
; CHECK-MD5: NameTableSection {{.*}} {fixlenmd5}
diff --git a/llvm/test/tools/llvm-profgen/noinline-cs-pseudoprobe.test b/llvm/test/tools/llvm-profgen/noinline-cs-pseudoprobe.test
index 314cb8808061..7dda33389691 100644
--- a/llvm/test/tools/llvm-profgen/noinline-cs-pseudoprobe.test
+++ b/llvm/test/tools/llvm-profgen/noinline-cs-pseudoprobe.test
@@ -24,20 +24,18 @@
; CHECK-NEXT: 4: 15
; CHECK-NEXT: !CFGChecksum: 72617220756
-
-; CHECK-UNWINDER: Binary(noinline-cs-pseudoprobe.perfbin)'s Range Counter:
-; CHECK-UNWINDER-NEXT: main:2
-; CHECK-UNWINDER-NEXT: (79e, 7bf): 15
-; CHECK-UNWINDER-NEXT: (7c4, 7cf): 15
-; CHECK-UNWINDER-NEXT: main:2 @ foo:8
-; CHECK-UNWINDER-NEXT: (760, 77f): 15
-
-; CHECK-UNWINDER: Binary(noinline-cs-pseudoprobe.perfbin)'s Branch Counter:
-; CHECK-UNWINDER-NEXT: main:2
-; CHECK-UNWINDER-NEXT: (7bf, 760): 15
-; CHECK-UNWINDER-NEXT: (7cf, 79e): 16
-; CHECK-UNWINDER-NEXT: main:2 @ foo:8
-; CHECK-UNWINDER-NEXT: (77f, 7c4): 17
+; CHECK-UNWINDER: [main:2]
+; CHECK-UNWINDER-NEXT: 2
+; CHECK-UNWINDER-NEXT: 79e-7bf:15
+; CHECK-UNWINDER-NEXT: 7c4-7cf:15
+; CHECK-UNWINDER-NEXT: 2
+; CHECK-UNWINDER-NEXT: 7bf->760:15
+; CHECK-UNWINDER-NEXT: 7cf->79e:16
+; CHECK-UNWINDER-NEXT: [main:2 @ foo:8]
+; CHECK-UNWINDER-NEXT: 1
+; CHECK-UNWINDER-NEXT: 760-77f:15
+; CHECK-UNWINDER-NEXT: 1
+; CHECK-UNWINDER-NEXT: 77f->7c4:17
; clang -O3 -fexperimental-new-pass-manager -fuse-ld=lld -fpseudo-probe-for-profiling
diff --git a/llvm/test/tools/llvm-profgen/recursion-compression-pseudoprobe.test b/llvm/test/tools/llvm-profgen/recursion-compression-pseudoprobe.test
index 72acb89bbb0f..959ee3de3b45 100644
--- a/llvm/test/tools/llvm-profgen/recursion-compression-pseudoprobe.test
+++ b/llvm/test/tools/llvm-profgen/recursion-compression-pseudoprobe.test
@@ -123,47 +123,48 @@
; CHECK: 6: 1 fa:1
; CHECK: !CFGChecksum: 563022570642068
-
-
-; CHECK-UNWINDER: Binary(recursion-compression-pseudoprobe.perfbin)'s Range Counter:
-; CHECK-UNWINDER: main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5
-; CHECK-UNWINDER: (7a0, 7a7): 1
-; CHECK-UNWINDER: (7a0, 7ab): 3
-; CHECK-UNWINDER: (7b2, 7b5): 1
-; CHECK-UNWINDER: main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5 @ fb:6
-; CHECK-UNWINDER: (7c0, 7d4): 1
-; CHECK-UNWINDER: main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5 @ fb:6 @ fa:8
-; CHECK-UNWINDER: (7c0, 7cd): 1
-; CHECK-UNWINDER: (7db, 7e0): 1
-; CHECK-UNWINDER: main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5 @ fb:6 @ fa:8 @ fa:7
-; CHECK-UNWINDER: (7a0, 7a7): 1
-; CHECK-UNWINDER: (7b2, 7b5): 1
-; CHECK-UNWINDER: main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5 @ fb:6 @ fa:8 @ fa:7 @ fb:6
-; CHECK-UNWINDER: (7c0, 7cd): 2
-; CHECK-UNWINDER: (7db, 7e0): 1
-; CHECK-UNWINDER: main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5 @ fb:6 @ fa:8 @ fa:7 @ fb:6 @ fa:7
-; CHECK-UNWINDER: (7a0, 7a7): 1
-; CHECK-UNWINDER: (7b2, 7b5): 1
-
-; CHECK-UNWINDER: Binary(recursion-compression-pseudoprobe.perfbin)'s Branch Counter:
-; CHECK-UNWINDER: main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5
-; CHECK-UNWINDER: (7a7, 7b2): 1
-; CHECK-UNWINDER: (7ab, 7a0): 4
-; CHECK-UNWINDER: (7b5, 7c0): 1
-; CHECK-UNWINDER: main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5 @ fb:6
-; CHECK-UNWINDER: (7d4, 7c0): 1
-; CHECK-UNWINDER: main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5 @ fb:6 @ fa:8
-; CHECK-UNWINDER: (7cd, 7db): 1
-; CHECK-UNWINDER: (7e0, 7a0): 1
-; CHECK-UNWINDER: main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5 @ fb:6 @ fa:8 @ fa:7
-; CHECK-UNWINDER: (7a7, 7b2): 1
-; CHECK-UNWINDER: (7b5, 7c0): 1
-; CHECK-UNWINDER: main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5 @ fb:6 @ fa:8 @ fa:7 @ fb:6
-; CHECK-UNWINDER: (7cd, 7db): 2
-; CHECK-UNWINDER: (7e0, 7a0): 1
-; CHECK-UNWINDER: main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5 @ fb:6 @ fa:8 @ fa:7 @ fb:6 @ fa:7
-; CHECK-UNWINDER: (7a7, 7b2): 1
-; CHECK-UNWINDER: (7b5, 7c0): 1
+; CHECK-UNWINDER: [main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5]
+; CHECK-UNWINDER-NEXT: 3
+; CHECK-UNWINDER-NEXT: 7a0-7a7:1
+; CHECK-UNWINDER-NEXT: 7a0-7ab:3
+; CHECK-UNWINDER-NEXT: 7b2-7b5:1
+; CHECK-UNWINDER-NEXT: 3
+; CHECK-UNWINDER-NEXT: 7a7->7b2:1
+; CHECK-UNWINDER-NEXT: 7ab->7a0:4
+; CHECK-UNWINDER-NEXT: 7b5->7c0:1
+; CHECK-UNWINDER-NEXT: [main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5 @ fb:6]
+; CHECK-UNWINDER-NEXT: 1
+; CHECK-UNWINDER-NEXT: 7c0-7d4:1
+; CHECK-UNWINDER-NEXT: 1
+; CHECK-UNWINDER-NEXT: 7d4->7c0:1
+; CHECK-UNWINDER-NEXT: [main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5 @ fb:6 @ fa:8]
+; CHECK-UNWINDER-NEXT: 2
+; CHECK-UNWINDER-NEXT: 7c0-7cd:1
+; CHECK-UNWINDER-NEXT: 7db-7e0:1
+; CHECK-UNWINDER-NEXT: 2
+; CHECK-UNWINDER-NEXT: 7cd->7db:1
+; CHECK-UNWINDER-NEXT: 7e0->7a0:1
+; CHECK-UNWINDER-NEXT: [main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5 @ fb:6 @ fa:8 @ fa:7]
+; CHECK-UNWINDER-NEXT: 2
+; CHECK-UNWINDER-NEXT: 7a0-7a7:1
+; CHECK-UNWINDER-NEXT: 7b2-7b5:1
+; CHECK-UNWINDER-NEXT: 2
+; CHECK-UNWINDER-NEXT: 7a7->7b2:1
+; CHECK-UNWINDER-NEXT: 7b5->7c0:1
+; CHECK-UNWINDER-NEXT: [main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5 @ fb:6 @ fa:8 @ fa:7 @ fb:6]
+; CHECK-UNWINDER-NEXT: 2
+; CHECK-UNWINDER-NEXT: 7c0-7cd:2
+; CHECK-UNWINDER-NEXT: 7db-7e0:1
+; CHECK-UNWINDER-NEXT: 2
+; CHECK-UNWINDER-NEXT: 7cd->7db:2
+; CHECK-UNWINDER-NEXT: 7e0->7a0:1
+; CHECK-UNWINDER-NEXT: [main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5 @ fb:6 @ fa:8 @ fa:7 @ fb:6 @ fa:7]
+; CHECK-UNWINDER-NEXT: 2
+; CHECK-UNWINDER-NEXT: 7a0-7a7:1
+; CHECK-UNWINDER-NEXT: 7b2-7b5:1
+; CHECK-UNWINDER-NEXT: 2
+; CHECK-UNWINDER-NEXT: 7a7->7b2:1
+; CHECK-UNWINDER-NEXT: 7b5->7c0:1
; clang -O3 -fexperimental-new-pass-manager -fuse-ld=lld -fpseudo-probe-for-profiling
diff --git a/llvm/tools/llvm-profgen/PerfReader.cpp b/llvm/tools/llvm-profgen/PerfReader.cpp
index eaf8f12e1d56..9b7332f7c836 100644
--- a/llvm/tools/llvm-profgen/PerfReader.cpp
+++ b/llvm/tools/llvm-profgen/PerfReader.cpp
@@ -20,6 +20,10 @@ cl::opt<bool> SkipSymbolization("skip-symbolization", cl::ReallyHidden,
cl::desc("Dump the unsymbolized profile to the "
"output file. It will show unwinder "
"output for CS profile generation."));
+cl::opt<bool> UseOffset("use-offset", cl::ReallyHidden, cl::init(true),
+ cl::ZeroOrMore,
+ cl::desc("Work with `--skip-symbolization` to dump the "
+ "offset instead of virtual address."));
extern cl::opt<bool> ShowDisassemblyOnly;
extern cl::opt<bool> ShowSourceLocations;
@@ -328,20 +332,6 @@ void PerfReaderBase::updateBinaryAddress(const MMapEvent &Event) {
}
}
-// Use ordered map to make the output deterministic
-using OrderedCounterForPrint = std::map<std::string, RangeSample>;
-
-static void printSampleCounter(OrderedCounterForPrint &OrderedCounter,
- raw_fd_ostream &OS) {
- for (auto Range : OrderedCounter) {
- OS << Range.first << "\n";
- for (auto I : Range.second) {
- OS << " (" << format("%" PRIx64, I.first.first) << ", "
- << format("%" PRIx64, I.first.second) << "): " << I.second << "\n";
- }
- }
-}
-
static std::string getContextKeyStr(ContextKey *K,
const ProfiledBinary *Binary) {
if (const auto *CtxKey = dyn_cast<StringBasedCtxKey>(K)) {
@@ -359,35 +349,6 @@ static std::string getContextKeyStr(ContextKey *K,
}
}
-static void printRangeCounter(ContextSampleCounterMap &Counter,
- const ProfiledBinary *Binary,
- raw_fd_ostream &OS) {
- OrderedCounterForPrint OrderedCounter;
- for (auto &CI : Counter) {
- OrderedCounter[getContextKeyStr(CI.first.getPtr(), Binary)] =
- CI.second.RangeCounter;
- }
- printSampleCounter(OrderedCounter, OS);
-}
-
-static void printBranchCounter(ContextSampleCounterMap &Counter,
- const ProfiledBinary *Binary,
- raw_fd_ostream &OS) {
- OrderedCounterForPrint OrderedCounter;
- for (auto &CI : Counter) {
- OrderedCounter[getContextKeyStr(CI.first.getPtr(), Binary)] =
- CI.second.BranchCounter;
- }
- printSampleCounter(OrderedCounter, OS);
-}
-
-void HybridPerfReader::writeRawProfile(raw_fd_ostream &OS) {
- OS << "Binary(" << Binary->getName().str() << ")'s Range Counter:\n";
- printRangeCounter(SampleCounters, Binary, OS);
- OS << "\nBinary(" << Binary->getName().str() << ")'s Branch Counter:\n";
- printBranchCounter(SampleCounters, Binary, OS);
-}
-
void HybridPerfReader::unwindSamples() {
std::set<uint64_t> AllUntrackedCallsites;
for (const auto &Item : AggregatedSamples) {
@@ -406,7 +367,7 @@ void HybridPerfReader::unwindSamples() {
<< format("%" PRIx64, Address) << "\n";
if (SkipSymbolization)
- PerfReaderBase::writeRawProfile(OutputFilename);
+ writeRawProfile(OutputFilename);
}
bool PerfReaderBase::extractLBRStack(TraceStream &TraceIt,
@@ -629,9 +590,13 @@ void PerfReaderBase::writeRawProfile(StringRef Filename) {
writeRawProfile(OS);
}
-void LBRPerfReader::writeRawProfile(raw_fd_ostream &OS) {
+// Use ordered map to make the output deterministic
+using OrderedCounterForPrint = std::map<std::string, SampleCounter *>;
+
+void PerfReaderBase::writeRawProfile(raw_fd_ostream &OS) {
/*
Format:
+ [context string]
number of entries in RangeCounter
from_1-to_1:count_1
from_2-to_2:count_2
@@ -644,17 +609,37 @@ void LBRPerfReader::writeRawProfile(raw_fd_ostream &OS) {
src_n->dst_n:count_n
*/
- SampleCounter &Counter = SampleCounters.begin()->second;
- OS << Counter.RangeCounter.size() << "\n";
- for (auto I : Counter.RangeCounter) {
- OS << Twine::utohexstr(I.first.first) << "-"
- << Twine::utohexstr(I.first.second) << ":" << I.second << "\n";
- }
+ OrderedCounterForPrint OrderedCounters;
+ for (auto &CI : SampleCounters) {
+ OrderedCounters[getContextKeyStr(CI.first.getPtr(), Binary)] = &CI.second;
+ }
+
+ auto SCounterPrinter = [&](RangeSample Counter, StringRef Separator,
+ uint32_t Indent) {
+ OS.indent(Indent);
+ OS << Counter.size() << "\n";
+ for (auto I : Counter) {
+ uint64_t Start = UseOffset ? I.first.first
+ : Binary->offsetToVirtualAddr(I.first.first);
+ uint64_t End = UseOffset ? I.first.second
+ : Binary->offsetToVirtualAddr(I.first.second);
+ OS.indent(Indent);
+ OS << Twine::utohexstr(Start) << Separator << Twine::utohexstr(End) << ":"
+ << I.second << "\n";
+ }
+ };
+
+ for (auto &CI : OrderedCounters) {
+ uint32_t Indent = 0;
+ if (!CI.first.empty()) {
+ // Context string key
+ OS << "[" << CI.first << "]\n";
+ Indent = 2;
+ }
- OS << Counter.BranchCounter.size() << "\n";
- for (auto I : Counter.BranchCounter) {
- OS << Twine::utohexstr(I.first.first) << "->"
- << Twine::utohexstr(I.first.second) << ":" << I.second << "\n";
+ SampleCounter &Counter = *CI.second;
+ SCounterPrinter(Counter.RangeCounter, "-", Indent);
+ SCounterPrinter(Counter.BranchCounter, "->", Indent);
}
}
diff --git a/llvm/tools/llvm-profgen/PerfReader.h b/llvm/tools/llvm-profgen/PerfReader.h
index c281e76c9637..25fa44284734 100644
--- a/llvm/tools/llvm-profgen/PerfReader.h
+++ b/llvm/tools/llvm-profgen/PerfReader.h
@@ -612,8 +612,8 @@ class PerfReaderBase {
// Post process the profile after trace aggregation, we will do simple range
// overlap computation for AutoFDO, or unwind for CSSPGO(hybrid sample).
virtual void generateRawProfile() = 0;
- virtual void writeRawProfile(StringRef Filename);
- virtual void writeRawProfile(raw_fd_ostream &OS) = 0;
+ void writeRawProfile(StringRef Filename);
+ void writeRawProfile(raw_fd_ostream &OS);
ProfiledBinary *Binary = nullptr;
@@ -646,7 +646,6 @@ class HybridPerfReader : public PerfReaderBase {
private:
// Unwind the hybrid samples after aggregration
void unwindSamples();
- void writeRawProfile(raw_fd_ostream &OS) override;
};
/*
@@ -673,7 +672,6 @@ class LBRPerfReader : public PerfReaderBase {
private:
void computeCounterFromLBR(const PerfSample *Sample, uint64_t Repeat);
- void writeRawProfile(raw_fd_ostream &OS) override;
};
} // end namespace sampleprof
More information about the llvm-commits
mailing list