[llvm] a03343d - [memprof] YAMLify the profile for memprof_missing_leaf.ll (NFC) (#120488)

via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 19 10:16:14 PST 2024


Author: Kazu Hirata
Date: 2024-12-19T10:16:10-08:00
New Revision: a03343daa6e7a44531e06c8897d6c6d4a46cd430

URL: https://github.com/llvm/llvm-project/commit/a03343daa6e7a44531e06c8897d6c6d4a46cd430
DIFF: https://github.com/llvm/llvm-project/commit/a03343daa6e7a44531e06c8897d6c6d4a46cd430.diff

LOG: [memprof] YAMLify the profile for memprof_missing_leaf.ll (NFC) (#120488)

This patch converts the profile for memprof_missing_leaf.ll to the
recently introduced YAML-based text format.

Added: 
    

Modified: 
    llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh
    llvm/test/Transforms/PGOProfile/memprof_missing_leaf.ll

Removed: 
    llvm/test/Transforms/PGOProfile/Inputs/memprof_missing_leaf.exe
    llvm/test/Transforms/PGOProfile/Inputs/memprof_missing_leaf.memprofraw


################################################################################
diff  --git a/llvm/test/Transforms/PGOProfile/Inputs/memprof_missing_leaf.exe b/llvm/test/Transforms/PGOProfile/Inputs/memprof_missing_leaf.exe
deleted file mode 100755
index 39bc43023559e9..00000000000000
Binary files a/llvm/test/Transforms/PGOProfile/Inputs/memprof_missing_leaf.exe and /dev/null 
diff er

diff  --git a/llvm/test/Transforms/PGOProfile/Inputs/memprof_missing_leaf.memprofraw b/llvm/test/Transforms/PGOProfile/Inputs/memprof_missing_leaf.memprofraw
deleted file mode 100644
index fcb661c0ba81d7..00000000000000
Binary files a/llvm/test/Transforms/PGOProfile/Inputs/memprof_missing_leaf.memprofraw and /dev/null 
diff er

diff  --git a/llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh b/llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh
index f06e6418edd652..ba648bf5ac9f71 100755
--- a/llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh
+++ b/llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh
@@ -95,39 +95,6 @@ rm ${OUTDIR}/memprof.cc
 rm ${OUTDIR}/pgo.exe
 rm ${OUTDIR}/memprof_pgo.profraw
 
-# Use musttail to simulate a missing leaf debug frame in the profiled binary.
-# Note we don't currently match onto explicit ::operator new calls, which is
-# why the non-musttail case uses implicit new (which doesn't support musttail).
-# Note that changes in the code below which affect relative line number
-# offsets of calls from their parent function can affect callsite matching in
-# the LLVM IR.
-cat > ${OUTDIR}/memprof_missing_leaf.cc << EOF
-#include <new>
-#ifndef USE_MUSTTAIL
-#define USE_MUSTTAIL 0
-#endif
-
-// clang::musttail requires that the argument signature matches that of the caller.
-void *bar(std::size_t s) {
-#if USE_MUSTTAIL
-  [[clang::musttail]] return ::operator new (s);
-#else
-  return new char[s];
-#endif
-}
-
-int main() {
-  char *a = (char *)bar(1);
-  delete a;
-  return 0;
-}
-EOF
-
-${CLANG} ${COMMON_FLAGS} -fmemory-profile -DUSE_MUSTTAIL=1 ${OUTDIR}/memprof_missing_leaf.cc -o ${OUTDIR}/memprof_missing_leaf.exe
-env MEMPROF_OPTIONS=log_path=stdout ${OUTDIR}/memprof_missing_leaf.exe > ${OUTDIR}/memprof_missing_leaf.memprofraw
-
-rm ${OUTDIR}/memprof_missing_leaf.cc
-
 cat > ${OUTDIR}/memprof_internal_linkage.cc << EOF
 #include <cstring>
 #include <unistd.h>

diff  --git a/llvm/test/Transforms/PGOProfile/memprof_missing_leaf.ll b/llvm/test/Transforms/PGOProfile/memprof_missing_leaf.ll
index e46945b763b1d0..e6fb1863acbce1 100644
--- a/llvm/test/Transforms/PGOProfile/memprof_missing_leaf.ll
+++ b/llvm/test/Transforms/PGOProfile/memprof_missing_leaf.ll
@@ -6,15 +6,58 @@
 ;; Avoid failures on big-endian systems that can't read the 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.
 ;; # To generate below LLVM IR for use in matching.
 ;; $ clang++ -gmlt -fdebug-info-for-profiling -S memprof_missing_leaf.cc \
 ;; 	-O2 -emit-llvm
+;;
+;; where memprof_missing_leaf.cc is as follows:
+;;
+;; #include <new>
+;;
+;; // Use musttail to simulate a missing leaf debug frame in the profiled binary.
+;; // Note we don't currently match onto explicit ::operator new calls, which is
+;; // why the non-musttail case uses implicit new (which doesn't support musttail).
+;; // Note that changes in the code below which affect relative line number
+;; // offsets of calls from their parent function can affect callsite matching in
+;; // the LLVM IR.
+;; #ifndef USE_MUSTTAIL
+;; #define USE_MUSTTAIL 0
+;; #endif
+;;
+;; // clang::musttail requires that the argument signature matches that of the caller.
+;; void *bar(std::size_t s) {
+;; #if USE_MUSTTAIL
+;;   [[clang::musttail]] return ::operator new (s);
+;; #else
+;;   return new char[s];
+;; #endif
+;; }
+;;
+;; int main() {
+;;   char *a = (char *)bar(1);
+;;   delete a;
+;;   return 0;
+;;}
 
-; RUN: llvm-profdata merge %S/Inputs/memprof_missing_leaf.memprofraw --profiled-binary %S/Inputs/memprof_missing_leaf.exe -o %t.memprofdata
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -S | FileCheck %s
+; RUN: split-file %s %t
+; RUN: llvm-profdata merge %t/memprof_missing_leaf.yaml -o %t/memprof_missing_leaf.memprofdata
+; RUN: opt < %t/memprof_missing_leaf.ll -passes='memprof-use<profile-filename=%t/memprof_missing_leaf.memprofdata>' -S | FileCheck %s
 
+;--- memprof_missing_leaf.yaml
+---
+HeapProfileRecords:
+  - GUID:            main
+    AllocSites:
+      - Callstack:
+          - { Function: main, LineOffset: 1, Column: 21, IsInlineFrame: false }
+        MemInfoBlock:
+          AllocCount:      1
+          TotalSize:       1
+          TotalLifetime:   0
+          TotalLifetimeAccessDensity: 0
+    CallSites:       []
+...
+;--- memprof_missing_leaf.ll
 ; CHECK: call {{.*}} @_Znam{{.*}} #[[ATTR:[0-9]+]]
 ; CHECK: attributes #[[ATTR]] = {{.*}} "memprof"="notcold"
 


        


More information about the llvm-commits mailing list