[llvm] [memprof] Fix a typo in writeMemProfV1 (PR #87890)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 7 15:02:41 PDT 2024


https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/87890

>From d15bb0dae566e501e4a9628b9fc0917c5f1d1343 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 4 Apr 2024 13:58:31 -0700
Subject: [PATCH 1/2] [memprof] Fix a typo in writeMemProfV1

This patch borrows memprof-merge.test to test --memprof-version.
---
 llvm/lib/ProfileData/InstrProfWriter.cpp      |  2 +-
 .../tools/llvm-profdata/memprof-merge-v0.test | 19 +++++++++++++++++++
 .../tools/llvm-profdata/memprof-merge-v1.test | 19 +++++++++++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/tools/llvm-profdata/memprof-merge-v0.test
 create mode 100644 llvm/test/tools/llvm-profdata/memprof-merge-v1.test

diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index 72d77d5580a5ba..1e0159dd1e6f40 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -493,7 +493,7 @@ static Error writeMemProfV1(
     llvm::MapVector<GlobalValue::GUID, memprof::IndexedMemProfRecord>
         &MemProfRecordData,
     llvm::MapVector<memprof::FrameId, memprof::Frame> &MemProfFrameData) {
-  OS.write(memprof::Version0);
+  OS.write(memprof::Version1);
   uint64_t HeaderUpdatePos = OS.tell();
   OS.write(0ULL); // Reserve space for the memprof record table offset.
   OS.write(0ULL); // Reserve space for the memprof frame payload offset.
diff --git a/llvm/test/tools/llvm-profdata/memprof-merge-v0.test b/llvm/test/tools/llvm-profdata/memprof-merge-v0.test
new file mode 100644
index 00000000000000..333eadb65218f2
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/memprof-merge-v0.test
@@ -0,0 +1,19 @@
+REQUIRES: x86_64-linux
+
+RUN: echo ":ir" > %t.proftext
+RUN: echo "main" >> %t.proftext
+RUN: echo "742261418966908927" >> %t.proftext
+RUN: echo "1" >> %t.proftext
+RUN: echo "1" >> %t.proftext
+
+To update the inputs used below run Inputs/update_memprof_inputs.sh /path/to/updated/clang
+RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version=0 --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof
+RUN: llvm-profdata show %t.prof | FileCheck %s
+
+For now we only check the validity of the instrumented profile since we don't
+have a way to display the contents of the memprof indexed format yet.
+
+CHECK: Instrumentation level: IR  entry_first = 0
+CHECK: Total functions: 1
+CHECK: Maximum function count: 1
+CHECK: Maximum internal block count: 0
diff --git a/llvm/test/tools/llvm-profdata/memprof-merge-v1.test b/llvm/test/tools/llvm-profdata/memprof-merge-v1.test
new file mode 100644
index 00000000000000..1b60b9aaf962af
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/memprof-merge-v1.test
@@ -0,0 +1,19 @@
+REQUIRES: x86_64-linux
+
+RUN: echo ":ir" > %t.proftext
+RUN: echo "main" >> %t.proftext
+RUN: echo "742261418966908927" >> %t.proftext
+RUN: echo "1" >> %t.proftext
+RUN: echo "1" >> %t.proftext
+
+To update the inputs used below run Inputs/update_memprof_inputs.sh /path/to/updated/clang
+RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version=1 --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof
+RUN: llvm-profdata show %t.prof | FileCheck %s
+
+For now we only check the validity of the instrumented profile since we don't
+have a way to display the contents of the memprof indexed format yet.
+
+CHECK: Instrumentation level: IR  entry_first = 0
+CHECK: Total functions: 1
+CHECK: Maximum function count: 1
+CHECK: Maximum internal block count: 0

>From bc1101d465489ef2f64eefc8ebefc157b4359219 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 7 Apr 2024 14:59:06 -0700
Subject: [PATCH 2/2] Combine v0 and v1 into one test.

---
 .../tools/llvm-profdata/memprof-merge-v0.test |  7 +++++--
 .../tools/llvm-profdata/memprof-merge-v1.test | 19 -------------------
 2 files changed, 5 insertions(+), 21 deletions(-)
 delete mode 100644 llvm/test/tools/llvm-profdata/memprof-merge-v1.test

diff --git a/llvm/test/tools/llvm-profdata/memprof-merge-v0.test b/llvm/test/tools/llvm-profdata/memprof-merge-v0.test
index 333eadb65218f2..68132961eb78da 100644
--- a/llvm/test/tools/llvm-profdata/memprof-merge-v0.test
+++ b/llvm/test/tools/llvm-profdata/memprof-merge-v0.test
@@ -7,8 +7,11 @@ RUN: echo "1" >> %t.proftext
 RUN: echo "1" >> %t.proftext
 
 To update the inputs used below run Inputs/update_memprof_inputs.sh /path/to/updated/clang
-RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version=0 --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof
-RUN: llvm-profdata show %t.prof | FileCheck %s
+RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version=0 --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v0
+RUN: llvm-profdata show %t.prof.v0 | FileCheck %s
+
+RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version=1 --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v1
+RUN: llvm-profdata show %t.prof.v1 | FileCheck %s
 
 For now we only check the validity of the instrumented profile since we don't
 have a way to display the contents of the memprof indexed format yet.
diff --git a/llvm/test/tools/llvm-profdata/memprof-merge-v1.test b/llvm/test/tools/llvm-profdata/memprof-merge-v1.test
deleted file mode 100644
index 1b60b9aaf962af..00000000000000
--- a/llvm/test/tools/llvm-profdata/memprof-merge-v1.test
+++ /dev/null
@@ -1,19 +0,0 @@
-REQUIRES: x86_64-linux
-
-RUN: echo ":ir" > %t.proftext
-RUN: echo "main" >> %t.proftext
-RUN: echo "742261418966908927" >> %t.proftext
-RUN: echo "1" >> %t.proftext
-RUN: echo "1" >> %t.proftext
-
-To update the inputs used below run Inputs/update_memprof_inputs.sh /path/to/updated/clang
-RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version=1 --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof
-RUN: llvm-profdata show %t.prof | FileCheck %s
-
-For now we only check the validity of the instrumented profile since we don't
-have a way to display the contents of the memprof indexed format yet.
-
-CHECK: Instrumentation level: IR  entry_first = 0
-CHECK: Total functions: 1
-CHECK: Maximum function count: 1
-CHECK: Maximum internal block count: 0



More information about the llvm-commits mailing list