[llvm-branch-commits] [clang] [NFC][MemProf] Replace memprofraw with YAML in memprof.cpp test (PR #216861)
Ellis Hoag via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Aug 17 16:04:35 PDT 2026
https://github.com/ellishg updated https://github.com/llvm/llvm-project/pull/216861
>From b29815e429366dd69f5a090b1e2f2e37b3f54a4a Mon Sep 17 00:00:00 2001
From: Ellis Hoag <ellishoag at meta.com>
Date: Mon, 17 Aug 2026 15:15:16 -0700
Subject: [PATCH 1/2] [NFC][MemProf] Replace memprofraw with YAML in
memprof.cpp test
---
clang/test/CodeGen/memprof.cpp | 36 +++++++++++++++++++++++-----------
1 file changed, 25 insertions(+), 11 deletions(-)
diff --git a/clang/test/CodeGen/memprof.cpp b/clang/test/CodeGen/memprof.cpp
index a8d13f3ec0210..c04792671a4e0 100644
--- a/clang/test/CodeGen/memprof.cpp
+++ b/clang/test/CodeGen/memprof.cpp
@@ -1,24 +1,19 @@
// Test if memprof instrumentation and use pass are invoked.
-//
+// RUN: rm -rf %t && split-file %s %t
+
// Instrumentation:
// Ensure Pass MemProfilerPass and ModuleMemProfilerPass are invoked.
-// RUN: %clang_cc1 -O2 -fmemory-profile %s -fdebug-pass-manager -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=INSTRUMENT
+// RUN: %clang_cc1 -O2 -fmemory-profile %t/a.cpp -fdebug-pass-manager -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=INSTRUMENT
// INSTRUMENT: Running pass: MemProfilerPass on main
// INSTRUMENT: Running pass: ModuleMemProfilerPass on [module]
-// Avoid failures on big-endian systems that can't read the raw profile properly
-// REQUIRES: x86_64-linux
-
-// TODO: Use text profile inputs once that is available for memprof.
-//
-// To update the inputs below, run Inputs/update_memprof_inputs.sh
-// RUN: llvm-profdata merge %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdata
-
// Profile use:
// Ensure Pass PGOInstrumentationUse is invoked with the memprof-only profile.
-// RUN: %clang_cc1 -O2 -fmemory-profile-use=%t.memprofdata %s -fdebug-pass-manager -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=USE
+// RUN: llvm-profdata merge %t/a.yaml -o %t/a.memprofdata
+// RUN: %clang_cc1 -O2 -fmemory-profile-use=%t/a.memprofdata %t/a.cpp -fdebug-pass-manager -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=USE
// USE: Running pass: MemProfUsePass on [module]
+//--- a.cpp
char *foo() {
return new char[10];
}
@@ -27,3 +22,22 @@ int main() {
delete[] a;
return 0;
}
+
+//--- a.yaml
+---
+HeapProfileRecords:
+ - GUID: main
+ AllocSites:
+ - Callstack:
+ - { Function: main, LineOffset: 1, Column: 10, IsInlineFrame: false }
+ - { Function: _Z3foov, LineOffset: 1, Column: 13, IsInlineFrame: false }
+ MemInfoBlock:
+ AllocCount: 1
+ TotalSize: 10
+ TotalLifetime: 0
+ TotalLifetimeAccessDensity: 0
+ - GUID: _Z3foov
+ CallSites:
+ - Frames:
+ - { Function: _Z3foov, LineOffset: 1, Column: 13, IsInlineFrame: false }
+...
>From 8648741be4176f97fb33b633389750b4879707ec Mon Sep 17 00:00:00 2001
From: Ellis Hoag <ellishoag at meta.com>
Date: Mon, 17 Aug 2026 16:03:21 -0700
Subject: [PATCH 2/2] Remove clang/test/CodeGen/Inputs/update_memprof_inputs.sh
---
.../CodeGen/Inputs/update_memprof_inputs.sh | 17 -----------------
1 file changed, 17 deletions(-)
delete mode 100755 clang/test/CodeGen/Inputs/update_memprof_inputs.sh
diff --git a/clang/test/CodeGen/Inputs/update_memprof_inputs.sh b/clang/test/CodeGen/Inputs/update_memprof_inputs.sh
deleted file mode 100755
index 1d51419ed1e7f..0000000000000
--- a/clang/test/CodeGen/Inputs/update_memprof_inputs.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-
-if [ -z $1 ]; then
- echo "Path to clang required!"
- echo "Usage: update_memprof_inputs.sh /path/to/updated/clang"
- exit 1
-else
- CLANG=$1
-fi
-
-# Allows the script to be invoked from other directories.
-OUTDIR=$(dirname $(realpath -s $0))
-
-DEFAULT_MEMPROF_FLAGS="-fuse-ld=lld -Wl,--no-rosegment -gmlt -fdebug-info-for-profiling -fmemory-profile -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -m64 -Wl,-build-id -no-pie"
-
-${CLANG} ${DEFAULT_MEMPROF_FLAGS} ${OUTDIR}/../memprof.cpp -o ${OUTDIR}/memprof.exe
-env MEMPROF_OPTIONS=log_path=stdout ${OUTDIR}/memprof.exe > ${OUTDIR}/memprof.memprofraw
More information about the llvm-branch-commits
mailing list