Skip to content

[NFC][MemProf] Replace memprofraw with YAML in memprof.ll test - #216878

Open
ellishg wants to merge 4 commits into
users/ellishg/fix-memprof-inline-testfrom
users/ellishg/fix-memprof-llvm-test
Open

[NFC][MemProf] Replace memprofraw with YAML in memprof.ll test#216878
ellishg wants to merge 4 commits into
users/ellishg/fix-memprof-inline-testfrom
users/ellishg/fix-memprof-llvm-test

Conversation

@ellishg

@ellishg ellishg commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Replace .memprofraw with a .yaml file using split-file. This allows us to delete update_memprof_inputs.sh‎ and the binary blobs that it generates.

Comment on lines -23 to -32
;; Check that the summary can be shown (and is identical) for both the raw and indexed profiles.
; RUN: llvm-profdata show --memory %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe | FileCheck %s --check-prefixes=SUMMARY
; RUN: llvm-profdata show --memory %t.memprofdata | FileCheck %s --check-prefixes=SUMMARY
; SUMMARY: # MemProfSummary:
; SUMMARY: # Total contexts: 8
; SUMMARY: # Total cold contexts: 5
; SUMMARY: # Total hot contexts: 0
; SUMMARY: # Maximum cold context total size: 10
; SUMMARY: # Maximum warm context total size: 10
; SUMMARY: # Maximum hot context total size: 0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This output is already tested in memprof_max_cold_threshold.test

; RUN: llvm-profdata show --memory %t/memprof_max_cold_threshold.memprofdata | FileCheck %s --check-prefixes=SUMMARY
; SUMMARY: # MemProfSummary:
; SUMMARY: # Total contexts: 5
; SUMMARY: # Total cold contexts: 4
; SUMMARY: # Total hot contexts: 0
; SUMMARY: # Maximum cold context total size: 400
; SUMMARY: # Maximum warm context total size: 500
; SUMMARY: # Maximum hot context total size: 0

After removing the .memprofraw binary file, we can no longer test the output from that file, so I've removed it.

Comment on lines +11 to +12
;; Simulate a profile from a -gno-column-info build by zeroing all columns.
; RUN: sed -E 's/Column: [0-9]+,/Column: 0,/g' %t/a.yaml > %t/a.nocolinfo.yaml

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also opted to manually zero out the columns rather than adding a second .yaml file.

@ellishg
ellishg marked this pull request as ready for review August 17, 2026 23:52
@llvmorg-github-actions llvmorg-github-actions Bot added PGO Profile Guided Optimizations llvm:transforms labels Aug 17, 2026
@ellishg
ellishg force-pushed the users/ellishg/fix-memprof-llvm-test branch from e017cc3 to a7bf990 Compare August 17, 2026 23:52
@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-llvm-transforms

Author: Ellis Hoag (ellishg)

Changes

Replace .memprofraw with a .yaml file using split-file. This allows us to delete update_memprof_inputs.sh‎ and the binary blobs that it generates.


Patch is 26.78 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/216878.diff

7 Files Affected:

  • (removed) llvm/test/Transforms/PGOProfile/Inputs/memprof.exe ()
  • (removed) llvm/test/Transforms/PGOProfile/Inputs/memprof.memprofraw ()
  • (removed) llvm/test/Transforms/PGOProfile/Inputs/memprof.nocolinfo.exe ()
  • (removed) llvm/test/Transforms/PGOProfile/Inputs/memprof.nocolinfo.memprofraw ()
  • (removed) llvm/test/Transforms/PGOProfile/Inputs/memprof_pgo.proftext (-60)
  • (removed) llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh (-96)
  • (modified) llvm/test/Transforms/PGOProfile/memprof.ll (+205-49)
diff --git a/llvm/test/Transforms/PGOProfile/Inputs/memprof.exe b/llvm/test/Transforms/PGOProfile/Inputs/memprof.exe
deleted file mode 100755
index 710e49ce7ec89..0000000000000
Binary files a/llvm/test/Transforms/PGOProfile/Inputs/memprof.exe and /dev/null differ
diff --git a/llvm/test/Transforms/PGOProfile/Inputs/memprof.memprofraw b/llvm/test/Transforms/PGOProfile/Inputs/memprof.memprofraw
deleted file mode 100644
index 255f7012e333d..0000000000000
Binary files a/llvm/test/Transforms/PGOProfile/Inputs/memprof.memprofraw and /dev/null differ
diff --git a/llvm/test/Transforms/PGOProfile/Inputs/memprof.nocolinfo.exe b/llvm/test/Transforms/PGOProfile/Inputs/memprof.nocolinfo.exe
deleted file mode 100755
index c24a0fdbb0e95..0000000000000
Binary files a/llvm/test/Transforms/PGOProfile/Inputs/memprof.nocolinfo.exe and /dev/null differ
diff --git a/llvm/test/Transforms/PGOProfile/Inputs/memprof.nocolinfo.memprofraw b/llvm/test/Transforms/PGOProfile/Inputs/memprof.nocolinfo.memprofraw
deleted file mode 100644
index 8886204350470..0000000000000
Binary files a/llvm/test/Transforms/PGOProfile/Inputs/memprof.nocolinfo.memprofraw and /dev/null differ
diff --git a/llvm/test/Transforms/PGOProfile/Inputs/memprof_pgo.proftext b/llvm/test/Transforms/PGOProfile/Inputs/memprof_pgo.proftext
deleted file mode 100644
index 9026834648295..0000000000000
--- a/llvm/test/Transforms/PGOProfile/Inputs/memprof_pgo.proftext
+++ /dev/null
@@ -1,60 +0,0 @@
-# IR level Instrumentation Flag
-:ir
-_Z3barv
-# Func Hash:
-742261418966908927
-# Num Counters:
-1
-# Counter Values:
-1
-
-_Z3bazv
-# Func Hash:
-742261418966908927
-# Num Counters:
-1
-# Counter Values:
-1
-
-_Z3foov
-# Func Hash:
-742261418966908927
-# Num Counters:
-1
-# Counter Values:
-6
-
-_Z4foo2v
-# Func Hash:
-742261418966908927
-# Num Counters:
-1
-# Counter Values:
-2
-
-_Z7recursej
-# Func Hash:
-146835647075900052
-# Num Counters:
-2
-# Counter Values:
-7
-2
-
-main
-# Func Hash:
-303685788594980264
-# Num Counters:
-10
-# Counter Values:
-2
-2
-1
-1
-1
-1
-1
-1
-1
-1
-
diff --git a/llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh b/llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh
deleted file mode 100755
index cbf9a401a6072..0000000000000
--- a/llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh
+++ /dev/null
@@ -1,96 +0,0 @@
-#!/bin/bash
-
-if [ $# -lt 2 ]; then
-  echo "Path to clang and llvm-profdata required!"
-  echo "Usage: update_memprof_inputs.sh /path/to/updated/clang /path/to/updated/llvm-profdata"
-  exit 1
-else
-  CLANG=$1
-  LLVMPROFDATA=$2
-fi
-
-# Allows the script to be invoked from other directories.
-OUTDIR=$(dirname $(realpath -s $0))
-
-# 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.cc << EOF
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-char *foo() {
-  return new char[10];
-}
-char *foo2() {
-  return foo();
-}
-char *bar() {
-  return foo2();
-}
-char *baz() {
-  return foo2();
-}
-char *recurse(unsigned n) {
-  if (!n)
-    return foo();
-  return recurse(n-1);
-}
-int main(int argc, char **argv) {
-  // Test allocations with different combinations of stack contexts and
-  // coldness (based on lifetime, since they are all accessed a single time
-  // per byte via the memset).
-  char *a = new char[10];
-  char *b = new char[10];
-  char *c = foo();
-  char *d = foo();
-  char *e = bar();
-  char *f = baz();
-  memset(a, 0, 10);
-  memset(b, 0, 10);
-  memset(c, 0, 10);
-  memset(d, 0, 10);
-  memset(e, 0, 10);
-  memset(f, 0, 10);
-  // a and c have short lifetimes
-  delete[] a;
-  delete[] c;
-  // b, d, e, and f have long lifetimes and will be detected as cold by default.
-  sleep(200);
-  delete[] b;
-  delete[] d;
-  delete[] e;
-  delete[] f;
-
-  // Loop ensures the two calls to recurse have stack contexts that only differ
-  // in one level of recursion. We should get two stack contexts reflecting the
-  // different levels of recursion and different allocation behavior (since the
-  // first has a very long lifetime and the second has a short lifetime).
-  for (unsigned i = 0; i < 2; i++) {
-    char *g = recurse(i + 3);
-    memset(g, 0, 10);
-    if (!i)
-      sleep(200);
-    delete[] g;
-  }
-  return 0;
-}
-EOF
-
-COMMON_FLAGS="-fuse-ld=lld -Wl,--no-rosegment -gmlt -fdebug-info-for-profiling -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -m64 -Wl,-build-id -no-pie"
-
-${CLANG} ${COMMON_FLAGS} -fmemory-profile ${OUTDIR}/memprof.cc -o ${OUTDIR}/memprof.exe
-env MEMPROF_OPTIONS=log_path=stdout ${OUTDIR}/memprof.exe > ${OUTDIR}/memprof.memprofraw
-
-# Generate another profile without any column numbers.
-${CLANG} ${COMMON_FLAGS} -gno-column-info -fmemory-profile ${OUTDIR}/memprof.cc -o ${OUTDIR}/memprof.nocolinfo.exe
-env MEMPROF_OPTIONS=log_path=stdout ${OUTDIR}/memprof.nocolinfo.exe > ${OUTDIR}/memprof.nocolinfo.memprofraw
-
-${CLANG} ${COMMON_FLAGS} -fprofile-generate=. \
-  ${OUTDIR}/memprof.cc -o ${OUTDIR}/pgo.exe
-env LLVM_PROFILE_FILE=${OUTDIR}/memprof_pgo.profraw ${OUTDIR}/pgo.exe
-${LLVMPROFDATA} merge --text ${OUTDIR}/memprof_pgo.profraw -o ${OUTDIR}/memprof_pgo.proftext
-
-rm ${OUTDIR}/memprof.cc
-rm ${OUTDIR}/pgo.exe
-rm ${OUTDIR}/memprof_pgo.profraw
diff --git a/llvm/test/Transforms/PGOProfile/memprof.ll b/llvm/test/Transforms/PGOProfile/memprof.ll
index 037ed3b256fb7..626e37d9ceb80 100644
--- a/llvm/test/Transforms/PGOProfile/memprof.ll
+++ b/llvm/test/Transforms/PGOProfile/memprof.ll
@@ -1,35 +1,16 @@
 ;; Tests memprof profile matching (with and without instrumentation profiles).
+; RUN: rm -rf %t && split-file %s %t
 
-;; Several requirements due to using raw profile inputs:
-;; PGO profile uses zlib compression
-; REQUIRES: zlib
-;; Avoid failures on big-endian systems that can't read the profile properly
-; REQUIRES: x86_64-linux
 ;; -stats requires asserts
 ; REQUIRES: asserts
 
-;; 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 -fno-omit-frame-pointer \
-;;	-fno-optimize-sibling-calls memprof.cc -S -emit-llvm
-
 ;; Generate indexed profiles of all combinations:
-; RUN: llvm-profdata merge %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdata
-; RUN: llvm-profdata merge %S/Inputs/memprof_pgo.proftext %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.pgomemprofdata
-; RUN: llvm-profdata merge %S/Inputs/memprof_pgo.proftext -o %t.pgoprofdata
-; RUN: llvm-profdata merge %S/Inputs/memprof.nocolinfo.memprofraw --profiled-binary %S/Inputs/memprof.nocolinfo.exe -o %t.nocolinfo.memprofdata
-
-;; Check that the summary can be shown (and is identical) for both the raw and indexed profiles.
-; RUN: llvm-profdata show --memory %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe | FileCheck %s --check-prefixes=SUMMARY
-; RUN: llvm-profdata show --memory %t.memprofdata | FileCheck %s --check-prefixes=SUMMARY
-; SUMMARY: # MemProfSummary:
-; SUMMARY: #   Total contexts: 8
-; SUMMARY: #   Total cold contexts: 5
-; SUMMARY: #   Total hot contexts: 0
-; SUMMARY: #   Maximum cold context total size: 10
-; SUMMARY: #   Maximum warm context total size: 10
-; SUMMARY: #   Maximum hot context total size: 0
+; RUN: llvm-profdata merge %t/a.yaml -o %t/a.memprofdata
+; RUN: llvm-profdata merge %t/a.proftext %t/a.yaml -o %t/a.pgomemprofdata
+; RUN: llvm-profdata merge %t/a.proftext -o %t/a.pgoprofdata
+;; Simulate a profile from a -gno-column-info build by zeroing all columns.
+; RUN: sed -E 's/Column: [0-9]+,/Column: 0,/g' %t/a.yaml > %t/a.nocolinfo.yaml
+; RUN: llvm-profdata merge %t/a.nocolinfo.yaml -o %t/a.nocolinfo.memprofdata
 
 ;; In all below cases we should not get any messages about missing profile data
 ;; for any functions. Either we are not performing any matching for a particular
@@ -38,7 +19,7 @@
 ; ALL-NOT: no profile data available for function
 
 ;; Using a memprof-only profile for memprof-use should only give memprof metadata
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-print-match-info -stats 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY,MEMPROFMATCHINFO,MEMPROFSTATS,AMBIG
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-print-match-info -stats 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY,MEMPROFMATCHINFO,MEMPROFSTATS,AMBIG
 ; There should not be any PGO metadata
 ; MEMPROFONLY-NOT: !prof
 
@@ -46,83 +27,83 @@
 ;; should recognize that there are no non-zero columns in the profile and
 ;; not attempt to include column numbers in the matching (which means that the
 ;; stack ids will be different).
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.nocolinfo.memprofdata>' -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROFNOCOLINFO,ALL,MEMPROFONLY
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.nocolinfo.memprofdata>' -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROFNOCOLINFO,ALL,MEMPROFONLY
 
 ;; Test the same thing but by passing the memory profile through to a default
 ;; pipeline via -memory-profile-file=, which should cause the necessary field
 ;; of the PGOOptions structure to be populated with the profile filename.
-; RUN: opt < %s -passes='default<O2>' -memory-profile-file=%t.memprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY,AMBIG
+; RUN: opt < %t/a.ll -passes='default<O2>' -memory-profile-file=%t/a.memprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY,AMBIG
 
 ;; Using a pgo+memprof profile for memprof-use should only give memprof metadata
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.pgomemprofdata>' -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY,AMBIG
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.pgomemprofdata>' -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY,AMBIG
 
 ;; Using a pgo-only profile for memprof-use should give an error
-; RUN: not opt < %s -passes='memprof-use<profile-filename=%t.pgoprofdata>' -S 2>&1 | FileCheck %s --check-prefixes=MEMPROFWITHPGOONLY
+; RUN: not opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.pgoprofdata>' -S 2>&1 | FileCheck %s --check-prefixes=MEMPROFWITHPGOONLY
 ; MEMPROFWITHPGOONLY: Not a memory profile
 
 ;; Using a memprof-only profile for pgo-instr-use should give an error
-; RUN: not opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.memprofdata -S 2>&1 | FileCheck %s --check-prefixes=PGOWITHMEMPROFONLY
+; RUN: not opt < %t/a.ll -passes=pgo-instr-use -pgo-test-profile-file=%t/a.memprofdata -S 2>&1 | FileCheck %s --check-prefixes=PGOWITHMEMPROFONLY
 ; PGOWITHMEMPROFONLY: Not an IR level instrumentation profile
 
 ;; Using a pgo+memprof profile for pgo-instr-use should only give pgo metadata
-; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.pgomemprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=PGO,ALL,PGOONLY
+; RUN: opt < %t/a.ll -passes=pgo-instr-use -pgo-test-profile-file=%t/a.pgomemprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=PGO,ALL,PGOONLY
 ; There should not be any memprof related metadata
 ; PGOONLY-NOT: !memprof
 ; PGOONLY-NOT: !callsite
 
 ;; Using a pgo+memprof profile for both memprof-use and pgo-instr-use should
 ;; give both memprof and pgo metadata.
-; RUN: opt < %s -passes='pgo-instr-use,memprof-use<profile-filename=%t.pgomemprofdata>' -pgo-test-profile-file=%t.pgomemprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,PGO,AMBIG
+; RUN: opt < %t/a.ll -passes='pgo-instr-use,memprof-use<profile-filename=%t/a.pgomemprofdata>' -pgo-test-profile-file=%t/a.pgomemprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,PGO,AMBIG
 
 ;; Check that the total sizes are reported if requested. A message should be
 ;; emitted for the pruned context. Also check that remarks are emitted for the
 ;; allocations hinted without context sensitivity.
 ;; Per-context remarks with size info should be emitted when -memprof-report-hinted-sizes is enabled.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-report-hinted-sizes -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=TOTALSIZESSINGLE,TOTALSIZES,TOTALSIZENOKEEPALL,REMARKSINGLESIZE
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-report-hinted-sizes -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=TOTALSIZESSINGLE,TOTALSIZES,TOTALSIZENOKEEPALL,REMARKSINGLESIZE
 ;; Per-context remarks with size info should be emitted when -memprof-keep-context-size-info is enabled.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-keep-context-size-info -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=REMARKSINGLESIZE
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-keep-context-size-info -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=REMARKSINGLESIZE
 ;; Only per-allocation remarks should be emitted by default.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=REMARKSINGLEBASIC
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=REMARKSINGLEBASIC
 
 ;; Check that the total sizes are reported if requested, and prevent pruning
 ;; via -memprof-keep-all-not-cold-contexts.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-report-hinted-sizes -memprof-keep-all-not-cold-contexts 2>&1 | FileCheck %s --check-prefixes=TOTALSIZESSINGLE,TOTALSIZES,TOTALSIZESKEEPALL
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-report-hinted-sizes -memprof-keep-all-not-cold-contexts 2>&1 | FileCheck %s --check-prefixes=TOTALSIZESSINGLE,TOTALSIZES,TOTALSIZESKEEPALL
 
 ;; Check that we hint additional allocations with a threshold < 100%.
 ;; Per-context remarks with size info should be emitted when -memprof-report-hinted-sizes is enabled.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-report-hinted-sizes -memprof-matching-cold-threshold=60 -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=TOTALSIZESSINGLE,TOTALSIZESTHRESH60,REMARKSINGLESIZE,REMARKDOMSIZE
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-report-hinted-sizes -memprof-matching-cold-threshold=60 -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=TOTALSIZESSINGLE,TOTALSIZESTHRESH60,REMARKSINGLESIZE,REMARKDOMSIZE
 ;; Per-context remarks with size info should be emitted when -memprof-keep-context-size-info is enabled.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-matching-cold-threshold=60 -memprof-keep-context-size-info -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=REMARKSINGLESIZE,REMARKDOMSIZE
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-matching-cold-threshold=60 -memprof-keep-context-size-info -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=REMARKSINGLESIZE,REMARKDOMSIZE
 ;; Only per-allocation remarks should be emitted by default.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-matching-cold-threshold=60 -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=REMARKSINGLEBASIC,REMARKDOMBASIC
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-matching-cold-threshold=60 -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=REMARKSINGLEBASIC,REMARKDOMBASIC
 
 ;; Make sure that the -memprof-cloning-cold-threshold flag is enough to cause
 ;; the size metadata to be generated for the LTO link.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-cloning-cold-threshold=80 -memprof-keep-all-not-cold-contexts 2>&1 | FileCheck %s --check-prefixes=TOTALSIZES,TOTALSIZESKEEPALL
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-cloning-cold-threshold=80 -memprof-keep-all-not-cold-contexts 2>&1 | FileCheck %s --check-prefixes=TOTALSIZES,TOTALSIZESKEEPALL
 
 ;; Make sure we emit a random hotness seed if requested.
-; RUN: llvm-profdata merge -memprof-random-hotness %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdatarand 2>&1 | FileCheck %s --check-prefix=RAND
+; RUN: llvm-profdata merge -memprof-random-hotness %t/a.yaml -o %t/a.memprofdatarand 2>&1 | FileCheck %s --check-prefix=RAND
 ; RAND: random hotness seed =
 ;; Can't check the exact values, but make sure applying the random profile
 ;; succeeds with the same stats
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdatarand>' -pgo-warn-missing-function -S -stats 2>&1 | FileCheck %s --check-prefixes=ALL,MEMPROFONLY,MEMPROFSTATS
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdatarand>' -pgo-warn-missing-function -S -stats 2>&1 | FileCheck %s --check-prefixes=ALL,MEMPROFONLY,MEMPROFSTATS
 
 ;; Make sure we use a specific random hotness seed if requested.
-; RUN: llvm-profdata merge -memprof-random-hotness -memprof-random-hotness-seed=1730170724 %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdatarand2 2>&1 | FileCheck %s --check-prefix=RAND2
+; RUN: llvm-profdata merge -memprof-random-hotness -memprof-random-hotness-seed=1730170724 %t/a.yaml -o %t/a.memprofdatarand2 2>&1 | FileCheck %s --check-prefix=RAND2
 ; RAND2: random hotness seed = 1730170724
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdatarand2>' -pgo-warn-missing-function -S -stats 2>&1 | FileCheck %s --check-prefixes=MEMPROFRAND2,ALL,MEMPROFONLY,MEMPROFSTATS
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdatarand2>' -pgo-warn-missing-function -S -stats 2>&1 | FileCheck %s --check-prefixes=MEMPROFRAND2,ALL,MEMPROFONLY,MEMPROFSTATS
 
 ;; With the hot access density threshold set to 0, and hot hints enabled,
 ;; the unconditionally notcold call to new should instead get a hot attribute.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-print-match-info -stats -memprof-min-ave-lifetime-access-density-hot-threshold=0 -memprof-use-hot-hints 2>&1 | FileCheck %s --check-prefixes=MEMPROFHOT,ALL
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-print-match-info -stats -memprof-min-ave-lifetime-access-density-hot-threshold=0 -memprof-use-hot-hints 2>&1 | FileCheck %s --check-prefixes=MEMPROFHOT,ALL
 
 ;; However, with the same threshold, but hot hints not enabled, it should be
 ;; notcold again.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-min-ave-lifetime-access-density-hot-threshold=0 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,AMBIG
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-min-ave-lifetime-access-density-hot-threshold=0 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,AMBIG
 
 ;; Test that we don't get an ambiguous memprof attribu...
[truncated]

@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-pgo

Author: Ellis Hoag (ellishg)

Changes

Replace .memprofraw with a .yaml file using split-file. This allows us to delete update_memprof_inputs.sh‎ and the binary blobs that it generates.


Patch is 26.78 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/216878.diff

7 Files Affected:

  • (removed) llvm/test/Transforms/PGOProfile/Inputs/memprof.exe ()
  • (removed) llvm/test/Transforms/PGOProfile/Inputs/memprof.memprofraw ()
  • (removed) llvm/test/Transforms/PGOProfile/Inputs/memprof.nocolinfo.exe ()
  • (removed) llvm/test/Transforms/PGOProfile/Inputs/memprof.nocolinfo.memprofraw ()
  • (removed) llvm/test/Transforms/PGOProfile/Inputs/memprof_pgo.proftext (-60)
  • (removed) llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh (-96)
  • (modified) llvm/test/Transforms/PGOProfile/memprof.ll (+205-49)
diff --git a/llvm/test/Transforms/PGOProfile/Inputs/memprof.exe b/llvm/test/Transforms/PGOProfile/Inputs/memprof.exe
deleted file mode 100755
index 710e49ce7ec89..0000000000000
Binary files a/llvm/test/Transforms/PGOProfile/Inputs/memprof.exe and /dev/null differ
diff --git a/llvm/test/Transforms/PGOProfile/Inputs/memprof.memprofraw b/llvm/test/Transforms/PGOProfile/Inputs/memprof.memprofraw
deleted file mode 100644
index 255f7012e333d..0000000000000
Binary files a/llvm/test/Transforms/PGOProfile/Inputs/memprof.memprofraw and /dev/null differ
diff --git a/llvm/test/Transforms/PGOProfile/Inputs/memprof.nocolinfo.exe b/llvm/test/Transforms/PGOProfile/Inputs/memprof.nocolinfo.exe
deleted file mode 100755
index c24a0fdbb0e95..0000000000000
Binary files a/llvm/test/Transforms/PGOProfile/Inputs/memprof.nocolinfo.exe and /dev/null differ
diff --git a/llvm/test/Transforms/PGOProfile/Inputs/memprof.nocolinfo.memprofraw b/llvm/test/Transforms/PGOProfile/Inputs/memprof.nocolinfo.memprofraw
deleted file mode 100644
index 8886204350470..0000000000000
Binary files a/llvm/test/Transforms/PGOProfile/Inputs/memprof.nocolinfo.memprofraw and /dev/null differ
diff --git a/llvm/test/Transforms/PGOProfile/Inputs/memprof_pgo.proftext b/llvm/test/Transforms/PGOProfile/Inputs/memprof_pgo.proftext
deleted file mode 100644
index 9026834648295..0000000000000
--- a/llvm/test/Transforms/PGOProfile/Inputs/memprof_pgo.proftext
+++ /dev/null
@@ -1,60 +0,0 @@
-# IR level Instrumentation Flag
-:ir
-_Z3barv
-# Func Hash:
-742261418966908927
-# Num Counters:
-1
-# Counter Values:
-1
-
-_Z3bazv
-# Func Hash:
-742261418966908927
-# Num Counters:
-1
-# Counter Values:
-1
-
-_Z3foov
-# Func Hash:
-742261418966908927
-# Num Counters:
-1
-# Counter Values:
-6
-
-_Z4foo2v
-# Func Hash:
-742261418966908927
-# Num Counters:
-1
-# Counter Values:
-2
-
-_Z7recursej
-# Func Hash:
-146835647075900052
-# Num Counters:
-2
-# Counter Values:
-7
-2
-
-main
-# Func Hash:
-303685788594980264
-# Num Counters:
-10
-# Counter Values:
-2
-2
-1
-1
-1
-1
-1
-1
-1
-1
-
diff --git a/llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh b/llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh
deleted file mode 100755
index cbf9a401a6072..0000000000000
--- a/llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh
+++ /dev/null
@@ -1,96 +0,0 @@
-#!/bin/bash
-
-if [ $# -lt 2 ]; then
-  echo "Path to clang and llvm-profdata required!"
-  echo "Usage: update_memprof_inputs.sh /path/to/updated/clang /path/to/updated/llvm-profdata"
-  exit 1
-else
-  CLANG=$1
-  LLVMPROFDATA=$2
-fi
-
-# Allows the script to be invoked from other directories.
-OUTDIR=$(dirname $(realpath -s $0))
-
-# 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.cc << EOF
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-char *foo() {
-  return new char[10];
-}
-char *foo2() {
-  return foo();
-}
-char *bar() {
-  return foo2();
-}
-char *baz() {
-  return foo2();
-}
-char *recurse(unsigned n) {
-  if (!n)
-    return foo();
-  return recurse(n-1);
-}
-int main(int argc, char **argv) {
-  // Test allocations with different combinations of stack contexts and
-  // coldness (based on lifetime, since they are all accessed a single time
-  // per byte via the memset).
-  char *a = new char[10];
-  char *b = new char[10];
-  char *c = foo();
-  char *d = foo();
-  char *e = bar();
-  char *f = baz();
-  memset(a, 0, 10);
-  memset(b, 0, 10);
-  memset(c, 0, 10);
-  memset(d, 0, 10);
-  memset(e, 0, 10);
-  memset(f, 0, 10);
-  // a and c have short lifetimes
-  delete[] a;
-  delete[] c;
-  // b, d, e, and f have long lifetimes and will be detected as cold by default.
-  sleep(200);
-  delete[] b;
-  delete[] d;
-  delete[] e;
-  delete[] f;
-
-  // Loop ensures the two calls to recurse have stack contexts that only differ
-  // in one level of recursion. We should get two stack contexts reflecting the
-  // different levels of recursion and different allocation behavior (since the
-  // first has a very long lifetime and the second has a short lifetime).
-  for (unsigned i = 0; i < 2; i++) {
-    char *g = recurse(i + 3);
-    memset(g, 0, 10);
-    if (!i)
-      sleep(200);
-    delete[] g;
-  }
-  return 0;
-}
-EOF
-
-COMMON_FLAGS="-fuse-ld=lld -Wl,--no-rosegment -gmlt -fdebug-info-for-profiling -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -m64 -Wl,-build-id -no-pie"
-
-${CLANG} ${COMMON_FLAGS} -fmemory-profile ${OUTDIR}/memprof.cc -o ${OUTDIR}/memprof.exe
-env MEMPROF_OPTIONS=log_path=stdout ${OUTDIR}/memprof.exe > ${OUTDIR}/memprof.memprofraw
-
-# Generate another profile without any column numbers.
-${CLANG} ${COMMON_FLAGS} -gno-column-info -fmemory-profile ${OUTDIR}/memprof.cc -o ${OUTDIR}/memprof.nocolinfo.exe
-env MEMPROF_OPTIONS=log_path=stdout ${OUTDIR}/memprof.nocolinfo.exe > ${OUTDIR}/memprof.nocolinfo.memprofraw
-
-${CLANG} ${COMMON_FLAGS} -fprofile-generate=. \
-  ${OUTDIR}/memprof.cc -o ${OUTDIR}/pgo.exe
-env LLVM_PROFILE_FILE=${OUTDIR}/memprof_pgo.profraw ${OUTDIR}/pgo.exe
-${LLVMPROFDATA} merge --text ${OUTDIR}/memprof_pgo.profraw -o ${OUTDIR}/memprof_pgo.proftext
-
-rm ${OUTDIR}/memprof.cc
-rm ${OUTDIR}/pgo.exe
-rm ${OUTDIR}/memprof_pgo.profraw
diff --git a/llvm/test/Transforms/PGOProfile/memprof.ll b/llvm/test/Transforms/PGOProfile/memprof.ll
index 037ed3b256fb7..626e37d9ceb80 100644
--- a/llvm/test/Transforms/PGOProfile/memprof.ll
+++ b/llvm/test/Transforms/PGOProfile/memprof.ll
@@ -1,35 +1,16 @@
 ;; Tests memprof profile matching (with and without instrumentation profiles).
+; RUN: rm -rf %t && split-file %s %t
 
-;; Several requirements due to using raw profile inputs:
-;; PGO profile uses zlib compression
-; REQUIRES: zlib
-;; Avoid failures on big-endian systems that can't read the profile properly
-; REQUIRES: x86_64-linux
 ;; -stats requires asserts
 ; REQUIRES: asserts
 
-;; 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 -fno-omit-frame-pointer \
-;;	-fno-optimize-sibling-calls memprof.cc -S -emit-llvm
-
 ;; Generate indexed profiles of all combinations:
-; RUN: llvm-profdata merge %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdata
-; RUN: llvm-profdata merge %S/Inputs/memprof_pgo.proftext %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.pgomemprofdata
-; RUN: llvm-profdata merge %S/Inputs/memprof_pgo.proftext -o %t.pgoprofdata
-; RUN: llvm-profdata merge %S/Inputs/memprof.nocolinfo.memprofraw --profiled-binary %S/Inputs/memprof.nocolinfo.exe -o %t.nocolinfo.memprofdata
-
-;; Check that the summary can be shown (and is identical) for both the raw and indexed profiles.
-; RUN: llvm-profdata show --memory %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe | FileCheck %s --check-prefixes=SUMMARY
-; RUN: llvm-profdata show --memory %t.memprofdata | FileCheck %s --check-prefixes=SUMMARY
-; SUMMARY: # MemProfSummary:
-; SUMMARY: #   Total contexts: 8
-; SUMMARY: #   Total cold contexts: 5
-; SUMMARY: #   Total hot contexts: 0
-; SUMMARY: #   Maximum cold context total size: 10
-; SUMMARY: #   Maximum warm context total size: 10
-; SUMMARY: #   Maximum hot context total size: 0
+; RUN: llvm-profdata merge %t/a.yaml -o %t/a.memprofdata
+; RUN: llvm-profdata merge %t/a.proftext %t/a.yaml -o %t/a.pgomemprofdata
+; RUN: llvm-profdata merge %t/a.proftext -o %t/a.pgoprofdata
+;; Simulate a profile from a -gno-column-info build by zeroing all columns.
+; RUN: sed -E 's/Column: [0-9]+,/Column: 0,/g' %t/a.yaml > %t/a.nocolinfo.yaml
+; RUN: llvm-profdata merge %t/a.nocolinfo.yaml -o %t/a.nocolinfo.memprofdata
 
 ;; In all below cases we should not get any messages about missing profile data
 ;; for any functions. Either we are not performing any matching for a particular
@@ -38,7 +19,7 @@
 ; ALL-NOT: no profile data available for function
 
 ;; Using a memprof-only profile for memprof-use should only give memprof metadata
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-print-match-info -stats 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY,MEMPROFMATCHINFO,MEMPROFSTATS,AMBIG
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-print-match-info -stats 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY,MEMPROFMATCHINFO,MEMPROFSTATS,AMBIG
 ; There should not be any PGO metadata
 ; MEMPROFONLY-NOT: !prof
 
@@ -46,83 +27,83 @@
 ;; should recognize that there are no non-zero columns in the profile and
 ;; not attempt to include column numbers in the matching (which means that the
 ;; stack ids will be different).
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.nocolinfo.memprofdata>' -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROFNOCOLINFO,ALL,MEMPROFONLY
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.nocolinfo.memprofdata>' -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROFNOCOLINFO,ALL,MEMPROFONLY
 
 ;; Test the same thing but by passing the memory profile through to a default
 ;; pipeline via -memory-profile-file=, which should cause the necessary field
 ;; of the PGOOptions structure to be populated with the profile filename.
-; RUN: opt < %s -passes='default<O2>' -memory-profile-file=%t.memprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY,AMBIG
+; RUN: opt < %t/a.ll -passes='default<O2>' -memory-profile-file=%t/a.memprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY,AMBIG
 
 ;; Using a pgo+memprof profile for memprof-use should only give memprof metadata
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.pgomemprofdata>' -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY,AMBIG
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.pgomemprofdata>' -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY,AMBIG
 
 ;; Using a pgo-only profile for memprof-use should give an error
-; RUN: not opt < %s -passes='memprof-use<profile-filename=%t.pgoprofdata>' -S 2>&1 | FileCheck %s --check-prefixes=MEMPROFWITHPGOONLY
+; RUN: not opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.pgoprofdata>' -S 2>&1 | FileCheck %s --check-prefixes=MEMPROFWITHPGOONLY
 ; MEMPROFWITHPGOONLY: Not a memory profile
 
 ;; Using a memprof-only profile for pgo-instr-use should give an error
-; RUN: not opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.memprofdata -S 2>&1 | FileCheck %s --check-prefixes=PGOWITHMEMPROFONLY
+; RUN: not opt < %t/a.ll -passes=pgo-instr-use -pgo-test-profile-file=%t/a.memprofdata -S 2>&1 | FileCheck %s --check-prefixes=PGOWITHMEMPROFONLY
 ; PGOWITHMEMPROFONLY: Not an IR level instrumentation profile
 
 ;; Using a pgo+memprof profile for pgo-instr-use should only give pgo metadata
-; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.pgomemprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=PGO,ALL,PGOONLY
+; RUN: opt < %t/a.ll -passes=pgo-instr-use -pgo-test-profile-file=%t/a.pgomemprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=PGO,ALL,PGOONLY
 ; There should not be any memprof related metadata
 ; PGOONLY-NOT: !memprof
 ; PGOONLY-NOT: !callsite
 
 ;; Using a pgo+memprof profile for both memprof-use and pgo-instr-use should
 ;; give both memprof and pgo metadata.
-; RUN: opt < %s -passes='pgo-instr-use,memprof-use<profile-filename=%t.pgomemprofdata>' -pgo-test-profile-file=%t.pgomemprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,PGO,AMBIG
+; RUN: opt < %t/a.ll -passes='pgo-instr-use,memprof-use<profile-filename=%t/a.pgomemprofdata>' -pgo-test-profile-file=%t/a.pgomemprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,PGO,AMBIG
 
 ;; Check that the total sizes are reported if requested. A message should be
 ;; emitted for the pruned context. Also check that remarks are emitted for the
 ;; allocations hinted without context sensitivity.
 ;; Per-context remarks with size info should be emitted when -memprof-report-hinted-sizes is enabled.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-report-hinted-sizes -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=TOTALSIZESSINGLE,TOTALSIZES,TOTALSIZENOKEEPALL,REMARKSINGLESIZE
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-report-hinted-sizes -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=TOTALSIZESSINGLE,TOTALSIZES,TOTALSIZENOKEEPALL,REMARKSINGLESIZE
 ;; Per-context remarks with size info should be emitted when -memprof-keep-context-size-info is enabled.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-keep-context-size-info -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=REMARKSINGLESIZE
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-keep-context-size-info -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=REMARKSINGLESIZE
 ;; Only per-allocation remarks should be emitted by default.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=REMARKSINGLEBASIC
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=REMARKSINGLEBASIC
 
 ;; Check that the total sizes are reported if requested, and prevent pruning
 ;; via -memprof-keep-all-not-cold-contexts.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-report-hinted-sizes -memprof-keep-all-not-cold-contexts 2>&1 | FileCheck %s --check-prefixes=TOTALSIZESSINGLE,TOTALSIZES,TOTALSIZESKEEPALL
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-report-hinted-sizes -memprof-keep-all-not-cold-contexts 2>&1 | FileCheck %s --check-prefixes=TOTALSIZESSINGLE,TOTALSIZES,TOTALSIZESKEEPALL
 
 ;; Check that we hint additional allocations with a threshold < 100%.
 ;; Per-context remarks with size info should be emitted when -memprof-report-hinted-sizes is enabled.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-report-hinted-sizes -memprof-matching-cold-threshold=60 -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=TOTALSIZESSINGLE,TOTALSIZESTHRESH60,REMARKSINGLESIZE,REMARKDOMSIZE
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-report-hinted-sizes -memprof-matching-cold-threshold=60 -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=TOTALSIZESSINGLE,TOTALSIZESTHRESH60,REMARKSINGLESIZE,REMARKDOMSIZE
 ;; Per-context remarks with size info should be emitted when -memprof-keep-context-size-info is enabled.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-matching-cold-threshold=60 -memprof-keep-context-size-info -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=REMARKSINGLESIZE,REMARKDOMSIZE
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-matching-cold-threshold=60 -memprof-keep-context-size-info -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=REMARKSINGLESIZE,REMARKDOMSIZE
 ;; Only per-allocation remarks should be emitted by default.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-matching-cold-threshold=60 -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=REMARKSINGLEBASIC,REMARKDOMBASIC
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-matching-cold-threshold=60 -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=REMARKSINGLEBASIC,REMARKDOMBASIC
 
 ;; Make sure that the -memprof-cloning-cold-threshold flag is enough to cause
 ;; the size metadata to be generated for the LTO link.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-cloning-cold-threshold=80 -memprof-keep-all-not-cold-contexts 2>&1 | FileCheck %s --check-prefixes=TOTALSIZES,TOTALSIZESKEEPALL
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-cloning-cold-threshold=80 -memprof-keep-all-not-cold-contexts 2>&1 | FileCheck %s --check-prefixes=TOTALSIZES,TOTALSIZESKEEPALL
 
 ;; Make sure we emit a random hotness seed if requested.
-; RUN: llvm-profdata merge -memprof-random-hotness %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdatarand 2>&1 | FileCheck %s --check-prefix=RAND
+; RUN: llvm-profdata merge -memprof-random-hotness %t/a.yaml -o %t/a.memprofdatarand 2>&1 | FileCheck %s --check-prefix=RAND
 ; RAND: random hotness seed =
 ;; Can't check the exact values, but make sure applying the random profile
 ;; succeeds with the same stats
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdatarand>' -pgo-warn-missing-function -S -stats 2>&1 | FileCheck %s --check-prefixes=ALL,MEMPROFONLY,MEMPROFSTATS
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdatarand>' -pgo-warn-missing-function -S -stats 2>&1 | FileCheck %s --check-prefixes=ALL,MEMPROFONLY,MEMPROFSTATS
 
 ;; Make sure we use a specific random hotness seed if requested.
-; RUN: llvm-profdata merge -memprof-random-hotness -memprof-random-hotness-seed=1730170724 %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdatarand2 2>&1 | FileCheck %s --check-prefix=RAND2
+; RUN: llvm-profdata merge -memprof-random-hotness -memprof-random-hotness-seed=1730170724 %t/a.yaml -o %t/a.memprofdatarand2 2>&1 | FileCheck %s --check-prefix=RAND2
 ; RAND2: random hotness seed = 1730170724
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdatarand2>' -pgo-warn-missing-function -S -stats 2>&1 | FileCheck %s --check-prefixes=MEMPROFRAND2,ALL,MEMPROFONLY,MEMPROFSTATS
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdatarand2>' -pgo-warn-missing-function -S -stats 2>&1 | FileCheck %s --check-prefixes=MEMPROFRAND2,ALL,MEMPROFONLY,MEMPROFSTATS
 
 ;; With the hot access density threshold set to 0, and hot hints enabled,
 ;; the unconditionally notcold call to new should instead get a hot attribute.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-print-match-info -stats -memprof-min-ave-lifetime-access-density-hot-threshold=0 -memprof-use-hot-hints 2>&1 | FileCheck %s --check-prefixes=MEMPROFHOT,ALL
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-print-match-info -stats -memprof-min-ave-lifetime-access-density-hot-threshold=0 -memprof-use-hot-hints 2>&1 | FileCheck %s --check-prefixes=MEMPROFHOT,ALL
 
 ;; However, with the same threshold, but hot hints not enabled, it should be
 ;; notcold again.
-; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-min-ave-lifetime-access-density-hot-threshold=0 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,AMBIG
+; RUN: opt < %t/a.ll -passes='memprof-use<profile-filename=%t/a.memprofdata>' -pgo-warn-missing-function -S -memprof-min-ave-lifetime-access-density-hot-threshold=0 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,AMBIG
 
 ;; Test that we don't get an ambiguous memprof attribu...
[truncated]

@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown

🪟 Windows x64 Test Results

  • 139943 tests passed
  • 3712 tests skipped

✅ The build succeeded and all tests passed.

@kazutakahirata kazutakahirata left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@boomanaiden154 boomanaiden154 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llvm:transforms PGO Profile Guided Optimizations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants