[llvm] [TypeProf][InstrFDO]Omit vtable symbols in indexed profiles by default (PR #96520)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 24 10:36:41 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-pgo
Author: Mingming Liu (minglotus-6)
<details>
<summary>Changes</summary>
- The indexed iFDO profiles contains compressed vtable names for `llvm-profdata show --show-vtables` debugging usage. An optimized build doesn't need it (and [doesn't decompress the blob](https://github.com/llvm/llvm-project/blob/eac925fb81f26342811ad1765e8f9919628e2254/llvm/include/llvm/ProfileData/InstrProfReader.h#L696-L701)) since optimized binary has the source code and IR to find vtable symbols.
- The motivation is to avoid increasing profile size when it's not necessary.
- This doesn't change the indexed profile format and thereby doesn't need a version change.
---
Full diff: https://github.com/llvm/llvm-project/pull/96520.diff
2 Files Affected:
- (modified) llvm/test/tools/llvm-profdata/vtable-value-prof.test (+2-2)
- (modified) llvm/tools/llvm-profdata/llvm-profdata.cpp (+9-4)
``````````diff
diff --git a/llvm/test/tools/llvm-profdata/vtable-value-prof.test b/llvm/test/tools/llvm-profdata/vtable-value-prof.test
index 378c2e11b236b..8dc8f6f0d480e 100644
--- a/llvm/test/tools/llvm-profdata/vtable-value-prof.test
+++ b/llvm/test/tools/llvm-profdata/vtable-value-prof.test
@@ -1,7 +1,7 @@
; RUN: rm -rf %t && mkdir %t && cd %t
; Generate indexed profiles from text profiles
-RUN: llvm-profdata merge %S/Inputs/vtable-value-prof.proftext -o indexed.profdata
+RUN: llvm-profdata merge --keep-vtable-symbols %S/Inputs/vtable-value-prof.proftext -o indexed.profdata
; Show indexed profiles
RUN: llvm-profdata show --function=main --ic-targets --show-vtables indexed.profdata | FileCheck %s --check-prefix=INDEXED
@@ -10,7 +10,7 @@ RUN: llvm-profdata show --function=main --ic-targets --show-vtables indexed.prof
RUN: llvm-profdata show --function=main --ic-targets --show-vtables --text %S/Inputs/vtable-value-prof.proftext | FileCheck %s --check-prefix=ICTEXT
; Convert indexed profiles to its textual output and show it.
-RUN: llvm-profdata merge --text -o text-from-indexed.proftext indexed.profdata
+RUN: llvm-profdata merge --keep-vtable-symbols --text -o text-from-indexed.proftext indexed.profdata
RUN: llvm-profdata show --function=main --ic-targets --show-vtables text-from-indexed.proftext | FileCheck %s --check-prefix=INDEXED
RUN: llvm-profdata show --function=main --ic-targets --show-vtables --text text-from-indexed.proftext | FileCheck %s --check-prefix=ICTEXT
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index fae6d1e989ab5..8a9345920f71e 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -291,6 +291,10 @@ cl::opt<bool> DropProfileSymbolList(
cl::desc("Drop the profile symbol list when merging AutoFDO profiles "
"(only meaningful for -sample)"));
+cl::opt<bool> KeepVTableSymbols(
+ "keep-vtable-symbols", cl::init(false), cl::Hidden,
+ cl::desc("If true, keep the vtable symbols in indexed profiles"));
+
// Temporary support for writing the previous version of the format, to enable
// some forward compatibility.
// TODO: Consider enabling this with future version changes as well, to ease
@@ -767,11 +771,12 @@ static void loadInput(const WeightedFile &Input, SymbolRemapper *Remapper,
});
}
- const InstrProfSymtab &symtab = Reader->getSymtab();
- const auto &VTableNames = symtab.getVTableNames();
+ if (KeepVTableSymbols) {
+ const InstrProfSymtab &symtab = Reader->getSymtab();
+ const auto &VTableNames = symtab.getVTableNames();
- for (const auto &kv : VTableNames) {
- WC->Writer.addVTableName(kv.getKey());
+ for (const auto &kv : VTableNames)
+ WC->Writer.addVTableName(kv.getKey());
}
if (Reader->hasTemporalProfile()) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/96520
More information about the llvm-commits
mailing list