Skip to content

Commit c3a55dd

Browse files
mingmingl-llvmAlexisPerry
authored andcommitted
[TypeProf][InstrFDO]Omit vtable symbols in indexed profiles by default (llvm#96520)
- 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 now [1], 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. [1] https://github.com/llvm/llvm-project/blob/eac925fb81f26342811ad1765e8f9919628e2254/llvm/include/llvm/ProfileData/InstrProfReader.h#L696-L699
1 parent f3d77cf commit c3a55dd

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

compiler-rt/test/profile/Linux/instrprof-vtable-value-prof.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
// RUN: llvm-profdata show --function=main --ic-targets --show-vtables %t-test.profraw | FileCheck %s --check-prefixes=COMMON,RAW
1313

1414
// Generate indexed profile from raw profile and show the data.
15-
// RUN: llvm-profdata merge %t-test.profraw -o %t-test.profdata
15+
// RUN: llvm-profdata merge --keep-vtable-symbols %t-test.profraw -o %t-test.profdata
1616
// RUN: llvm-profdata show --function=main --ic-targets --show-vtables %t-test.profdata | FileCheck %s --check-prefixes=COMMON,INDEXED
1717

1818
// Generate text profile from raw and indexed profiles respectively and show the data.
19-
// RUN: llvm-profdata merge --text %t-test.profraw -o %t-raw.proftext
19+
// RUN: llvm-profdata merge --keep-vtable-symbols --text %t-test.profraw -o %t-raw.proftext
2020
// RUN: llvm-profdata show --function=main --ic-targets --show-vtables --text %t-raw.proftext | FileCheck %s --check-prefix=ICTEXT
21-
// RUN: llvm-profdata merge --text %t-test.profdata -o %t-indexed.proftext
21+
// RUN: llvm-profdata merge --keep-vtable-symbols --text %t-test.profdata -o %t-indexed.proftext
2222
// RUN: llvm-profdata show --function=main --ic-targets --show-vtables --text %t-indexed.proftext | FileCheck %s --check-prefix=ICTEXT
2323

2424
// Generate indexed profile from text profiles and show the data
25-
// RUN: llvm-profdata merge --binary %t-raw.proftext -o %t-text.profraw
25+
// RUN: llvm-profdata merge --keep-vtable-symbols --binary %t-raw.proftext -o %t-text.profraw
2626
// RUN: llvm-profdata show --function=main --ic-targets --show-vtables %t-text.profraw | FileCheck %s --check-prefixes=COMMON,INDEXED
27-
// RUN: llvm-profdata merge --binary %t-indexed.proftext -o %t-text.profdata
27+
// RUN: llvm-profdata merge --keep-vtable-symbols --binary %t-indexed.proftext -o %t-text.profdata
2828
// RUN: llvm-profdata show --function=main --ic-targets --show-vtables %t-text.profdata | FileCheck %s --check-prefixes=COMMON,INDEXED
2929

3030
// COMMON: Counters:

llvm/test/tools/llvm-profdata/vtable-value-prof.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; RUN: rm -rf %t && mkdir %t && cd %t
22

33
; Generate indexed profiles from text profiles
4-
RUN: llvm-profdata merge %S/Inputs/vtable-value-prof.proftext -o indexed.profdata
4+
RUN: llvm-profdata merge --keep-vtable-symbols %S/Inputs/vtable-value-prof.proftext -o indexed.profdata
55

66
; Show indexed profiles
77
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
1010
RUN: llvm-profdata show --function=main --ic-targets --show-vtables --text %S/Inputs/vtable-value-prof.proftext | FileCheck %s --check-prefix=ICTEXT
1111

1212
; Convert indexed profiles to its textual output and show it.
13-
RUN: llvm-profdata merge --text -o text-from-indexed.proftext indexed.profdata
13+
RUN: llvm-profdata merge --keep-vtable-symbols --text -o text-from-indexed.proftext indexed.profdata
1414
RUN: llvm-profdata show --function=main --ic-targets --show-vtables text-from-indexed.proftext | FileCheck %s --check-prefix=INDEXED
1515
RUN: llvm-profdata show --function=main --ic-targets --show-vtables --text text-from-indexed.proftext | FileCheck %s --check-prefix=ICTEXT
1616

llvm/tools/llvm-profdata/llvm-profdata.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,11 @@ cl::opt<bool> DropProfileSymbolList(
291291
cl::desc("Drop the profile symbol list when merging AutoFDO profiles "
292292
"(only meaningful for -sample)"));
293293

294+
cl::opt<bool> KeepVTableSymbols(
295+
"keep-vtable-symbols", cl::init(false), cl::Hidden,
296+
cl::sub(MergeSubcommand),
297+
cl::desc("If true, keep the vtable symbols in indexed profiles"));
298+
294299
// Temporary support for writing the previous version of the format, to enable
295300
// some forward compatibility.
296301
// TODO: Consider enabling this with future version changes as well, to ease
@@ -767,11 +772,12 @@ static void loadInput(const WeightedFile &Input, SymbolRemapper *Remapper,
767772
});
768773
}
769774

770-
const InstrProfSymtab &symtab = Reader->getSymtab();
771-
const auto &VTableNames = symtab.getVTableNames();
775+
if (KeepVTableSymbols) {
776+
const InstrProfSymtab &symtab = Reader->getSymtab();
777+
const auto &VTableNames = symtab.getVTableNames();
772778

773-
for (const auto &kv : VTableNames) {
774-
WC->Writer.addVTableName(kv.getKey());
779+
for (const auto &kv : VTableNames)
780+
WC->Writer.addVTableName(kv.getKey());
775781
}
776782

777783
if (Reader->hasTemporalProfile()) {

0 commit comments

Comments
 (0)