[PATCH] D110079: [llvm-profgen] An option to dump disasm of specified symbols
Hongtao Yu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 20 09:45:58 PDT 2021
hoy created this revision.
Herald added subscribers: modimo, wenlei.
hoy requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
For large app, dumping disasm of the whole program can be slow and result in gianant output. Adding a switch to dump specific symbols only.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D110079
Files:
llvm/test/tools/llvm-profgen/pseudoprobe-decoding.test
llvm/tools/llvm-profgen/ProfiledBinary.cpp
llvm/tools/llvm-profgen/ProfiledBinary.h
Index: llvm/tools/llvm-profgen/ProfiledBinary.h
===================================================================
--- llvm/tools/llvm-profgen/ProfiledBinary.h
+++ llvm/tools/llvm-profgen/ProfiledBinary.h
@@ -185,6 +185,9 @@
// String table owning function name strings created from the symbolizer.
std::unordered_set<std::string> NameStrings;
+ // A collection of symbols to print disassembly for.
+ StringSet<> ShowSymbolSet;
+
// Pseudo probe decoder
MCPseudoProbeDecoder ProbeDecoder;
Index: llvm/tools/llvm-profgen/ProfiledBinary.cpp
===================================================================
--- llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -38,6 +38,11 @@
"show-pseudo-probe", cl::ReallyHidden, cl::init(false), cl::ZeroOrMore,
cl::desc("Print pseudo probe section and disassembled info."));
+static cl::list<std::string> ShowSymbols(
+ "show-symbols", cl::CommaSeparated,
+ cl::desc("List of symbols to print disassembly for. Accept demangled "
+ "names only. Only work with show-disassembly-only"));
+
namespace llvm {
namespace sampleprof {
@@ -298,7 +303,10 @@
ShowCanonicalFnName
? FunctionSamples::getCanonicalFnName(Symbols[SI].Name)
: Symbols[SI].Name;
- if (ShowDisassemblyOnly)
+ bool ShowDisassembly =
+ ShowDisassemblyOnly &&
+ (ShowSymbolSet.empty() || ShowSymbolSet.count(SymbolName));
+ if (ShowDisassembly)
outs() << '<' << SymbolName << ">:\n";
auto WarnInvalidInsts = [](uint64_t Start, uint64_t End) {
@@ -321,7 +329,7 @@
if (Size == 0)
Size = 1;
- if (ShowDisassemblyOnly) {
+ if (ShowDisassembly) {
if (ShowPseudoProbe) {
ProbeDecoder.printProbeForAddress(outs(),
Offset + getPreferredBaseAddress());
@@ -385,7 +393,7 @@
if (InvalidInstLength)
WarnInvalidInsts(Offset - InvalidInstLength, Offset - 1);
- if (ShowDisassemblyOnly)
+ if (ShowDisassembly)
outs() << "\n";
FuncStartAddrMap[StartOffset] = Symbols[SI].Name.str();
@@ -452,6 +460,8 @@
for (std::pair<const SectionRef, SectionSymbolsTy> &SecSyms : AllSymbols)
stable_sort(SecSyms.second);
+ ShowSymbolSet.insert(ShowSymbols.begin(), ShowSymbols.end());
+
if (ShowDisassemblyOnly)
outs() << "\nDisassembly of " << FileName << ":\n";
Index: llvm/test/tools/llvm-profgen/pseudoprobe-decoding.test
===================================================================
--- llvm/test/tools/llvm-profgen/pseudoprobe-decoding.test
+++ llvm/test/tools/llvm-profgen/pseudoprobe-decoding.test
@@ -1,4 +1,5 @@
; RUN: llvm-profgen --format=text --perfscript=%s --binary=%S/Inputs/inline-cs-pseudoprobe.perfbin --output=%t --show-pseudo-probe --show-disassembly-only | FileCheck %s
+; RUN: llvm-profgen --format=text --perfscript=%s --binary=%S/Inputs/inline-cs-pseudoprobe.perfbin --output=%t --show-pseudo-probe --show-disassembly-only --show-symbols=main,foo | FileCheck %s -check-prefix=SYM
PERF_RECORD_MMAP2 2854748/2854748: [0x400000(0x1000) @ 0 00:1d 123291722 526021]: r-xp /home/inline-cs-pseudoprobe.perfbin
@@ -79,6 +80,11 @@
; CHECK: [Probe]: FUNC: foo Index: 9 Type: DirectCall Inlined: @ main:2
; CHECK-NEXT: 865: callq 0x930
+; SYM-NOT: <bar>:
+; SYM: <foo>:
+; SYM: <main>:
+
+
; 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110079.373629.patch
Type: text/x-patch
Size: 3548 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210920/5589b41e/attachment.bin>
More information about the llvm-commits
mailing list