[llvm] [InstrProf]Merge vtable names from multiple sources in llvm-profdata (PR #90100)
Mingming Liu via llvm-commits
llvm-commits at lists.llvm.org
Wed May 8 13:59:26 PDT 2024
https://github.com/minglotus-6 updated https://github.com/llvm/llvm-project/pull/90100
>From b95cc9b658f71e4390a4c4f852994a19b34ba1e8 Mon Sep 17 00:00:00 2001
From: mingmingl <mingmingl at google.com>
Date: Thu, 25 Apr 2024 11:12:45 -0700
Subject: [PATCH 1/3] [InstrProf]Merge vtable names from multiple sources in
llvm-profdata
---
llvm/lib/ProfileData/InstrProfWriter.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index 7c56cde3e6ced..a8d770ff5741f 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -367,6 +367,9 @@ void InstrProfWriter::mergeRecordsFromWriter(InstrProfWriter &&IPW,
for (auto &I : IPW.BinaryIds)
addBinaryIds(I);
+ for (auto& kv: IPW.VTableNames)
+ addVTableName(kv.getKey());
+
addTemporalProfileTraces(IPW.TemporalProfTraces,
IPW.TemporalProfTraceStreamSize);
>From 56ddfec9693ca9ada5f1a6055c84684782322e6e Mon Sep 17 00:00:00 2001
From: mingmingl <mingmingl at google.com>
Date: Thu, 25 Apr 2024 13:33:41 -0700
Subject: [PATCH 2/3] add regression test
---
.../llvm-profdata/vtable-value-prof.test | 42 ++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/llvm/test/tools/llvm-profdata/vtable-value-prof.test b/llvm/test/tools/llvm-profdata/vtable-value-prof.test
index 378c2e11b236b..c652e8ecc3fa2 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 %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
@@ -14,6 +14,10 @@ RUN: llvm-profdata merge --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
+; Test vtable profile counters accumulate when multiple profiles are merged.
+RUN: llvm-profdata merge %S/Inputs/vtable-value-prof.proftext %S/Inputs/vtable-value-prof.proftext -o merge.profdata
+RUN: llvm-profdata show --function=main --ic-targets --show-vtables merge.profdata | FileCheck %s --check-prefix=MERGED
+
INDEXED: Counters:
INDEXED-NEXT: main:
INDEXED-NEXT: Hash: 0x0f9a16fe6d398548
@@ -81,3 +85,39 @@ ICTEXT: _ZTV8Derived1:250
ICTEXT: 2
ICTEXT: {{.*}}vtable_prof.cc;_ZTVN12_GLOBAL__N_18Derived2E:750
ICTEXT: _ZTV8Derived1:250
+
+MERGED: Counters:
+MERGED-NEXT: main:
+MERGED-NEXT: Hash: 0x0f9a16fe6d398548
+MERGED-NEXT: Counters: 2
+MERGED-NEXT: Indirect Call Site Count: 2
+MERGED-NEXT: Number of instrumented vtables: 2
+MERGED-NEXT: Indirect Target Results:
+MERGED-NEXT: [ 0, {{.*}}vtable_prof.cc;_ZN12_GLOBAL__N_18Derived25func1Eii, 1500 ] (75.00%)
+MERGED-NEXT: [ 0, _ZN8Derived15func1Eii, 500 ] (25.00%)
+MERGED-NEXT: [ 1, {{.*}}vtable_prof.cc;_ZN12_GLOBAL__N_18Derived25func2Eii, 1500 ] (75.00%)
+MERGED-NEXT: [ 1, _ZN8Derived15func2Eii, 500 ] (25.00%)
+MERGED-NEXT: VTable Results:
+MERGED-NEXT: [ 0, {{.*}}vtable_prof.cc;_ZTVN12_GLOBAL__N_18Derived2E, 1500 ] (75.00%)
+MERGED-NEXT: [ 0, _ZTV8Derived1, 500 ] (25.00%)
+MERGED-NEXT: [ 1, {{.*}}vtable_prof.cc;_ZTVN12_GLOBAL__N_18Derived2E, 1500 ] (75.00%)
+MERGED-NEXT: [ 1, _ZTV8Derived1, 500 ] (25.00%)
+MERGED-NEXT: Instrumentation level: IR entry_first = 0
+MERGED-NEXT: Functions shown: 1
+MERGED-NEXT: Total functions: 6
+MERGED-NEXT: Maximum function count: 2000
+MERGED-NEXT: Maximum internal block count: 500
+MERGED-NEXT: Statistics for indirect call sites profile:
+MERGED-NEXT: Total number of sites: 2
+MERGED-NEXT: Total number of sites with values: 2
+MERGED-NEXT: Total number of profiled values: 4
+MERGED-NEXT: Value sites histogram:
+MERGED-NEXT: NumTargets, SiteCount
+MERGED-NEXT: 2, 2
+MERGED-NEXT: Statistics for vtable profile:
+MERGED-NEXT: Total number of sites: 2
+MERGED-NEXT: Total number of sites with values: 2
+MERGED-NEXT: Total number of profiled values: 4
+MERGED-NEXT: Value sites histogram:
+MERGED-NEXT: NumTargets, SiteCount
+MERGED-NEXT: 2, 2
>From 54030cb4512a92f4234171844dd2d2c06df08fec Mon Sep 17 00:00:00 2001
From: mingmingl <mingmingl at google.com>
Date: Thu, 25 Apr 2024 14:12:37 -0700
Subject: [PATCH 3/3] revert regression test
---
.../llvm-profdata/vtable-value-prof.test | 42 +------------------
1 file changed, 1 insertion(+), 41 deletions(-)
diff --git a/llvm/test/tools/llvm-profdata/vtable-value-prof.test b/llvm/test/tools/llvm-profdata/vtable-value-prof.test
index c652e8ecc3fa2..378c2e11b236b 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 %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
@@ -14,10 +14,6 @@ RUN: llvm-profdata merge --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
-; Test vtable profile counters accumulate when multiple profiles are merged.
-RUN: llvm-profdata merge %S/Inputs/vtable-value-prof.proftext %S/Inputs/vtable-value-prof.proftext -o merge.profdata
-RUN: llvm-profdata show --function=main --ic-targets --show-vtables merge.profdata | FileCheck %s --check-prefix=MERGED
-
INDEXED: Counters:
INDEXED-NEXT: main:
INDEXED-NEXT: Hash: 0x0f9a16fe6d398548
@@ -85,39 +81,3 @@ ICTEXT: _ZTV8Derived1:250
ICTEXT: 2
ICTEXT: {{.*}}vtable_prof.cc;_ZTVN12_GLOBAL__N_18Derived2E:750
ICTEXT: _ZTV8Derived1:250
-
-MERGED: Counters:
-MERGED-NEXT: main:
-MERGED-NEXT: Hash: 0x0f9a16fe6d398548
-MERGED-NEXT: Counters: 2
-MERGED-NEXT: Indirect Call Site Count: 2
-MERGED-NEXT: Number of instrumented vtables: 2
-MERGED-NEXT: Indirect Target Results:
-MERGED-NEXT: [ 0, {{.*}}vtable_prof.cc;_ZN12_GLOBAL__N_18Derived25func1Eii, 1500 ] (75.00%)
-MERGED-NEXT: [ 0, _ZN8Derived15func1Eii, 500 ] (25.00%)
-MERGED-NEXT: [ 1, {{.*}}vtable_prof.cc;_ZN12_GLOBAL__N_18Derived25func2Eii, 1500 ] (75.00%)
-MERGED-NEXT: [ 1, _ZN8Derived15func2Eii, 500 ] (25.00%)
-MERGED-NEXT: VTable Results:
-MERGED-NEXT: [ 0, {{.*}}vtable_prof.cc;_ZTVN12_GLOBAL__N_18Derived2E, 1500 ] (75.00%)
-MERGED-NEXT: [ 0, _ZTV8Derived1, 500 ] (25.00%)
-MERGED-NEXT: [ 1, {{.*}}vtable_prof.cc;_ZTVN12_GLOBAL__N_18Derived2E, 1500 ] (75.00%)
-MERGED-NEXT: [ 1, _ZTV8Derived1, 500 ] (25.00%)
-MERGED-NEXT: Instrumentation level: IR entry_first = 0
-MERGED-NEXT: Functions shown: 1
-MERGED-NEXT: Total functions: 6
-MERGED-NEXT: Maximum function count: 2000
-MERGED-NEXT: Maximum internal block count: 500
-MERGED-NEXT: Statistics for indirect call sites profile:
-MERGED-NEXT: Total number of sites: 2
-MERGED-NEXT: Total number of sites with values: 2
-MERGED-NEXT: Total number of profiled values: 4
-MERGED-NEXT: Value sites histogram:
-MERGED-NEXT: NumTargets, SiteCount
-MERGED-NEXT: 2, 2
-MERGED-NEXT: Statistics for vtable profile:
-MERGED-NEXT: Total number of sites: 2
-MERGED-NEXT: Total number of sites with values: 2
-MERGED-NEXT: Total number of profiled values: 4
-MERGED-NEXT: Value sites histogram:
-MERGED-NEXT: NumTargets, SiteCount
-MERGED-NEXT: 2, 2
More information about the llvm-commits
mailing list