[llvm] ca31f82 - [MemProf] Convert PGO raw profile to text format
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 27 11:10:04 PDT 2023
Author: Teresa Johnson
Date: 2023-07-27T11:08:14-07:00
New Revision: ca31f821f2f7ced30f71e17050fb1380dbea3b3a
URL: https://github.com/llvm/llvm-project/commit/ca31f821f2f7ced30f71e17050fb1380dbea3b3a
DIFF: https://github.com/llvm/llvm-project/commit/ca31f821f2f7ced30f71e17050fb1380dbea3b3a.diff
LOG: [MemProf] Convert PGO raw profile to text format
This avoids the need to regenerate the PGO raw profile on version
changes. Modify the update script to autogenerate new PGO proftext
inputs.
Differential Revision: https://reviews.llvm.org/D156460
Added:
llvm/test/Transforms/PGOProfile/Inputs/memprof_pgo.proftext
Modified:
llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh
llvm/test/Transforms/PGOProfile/memprof.ll
Removed:
llvm/test/Transforms/PGOProfile/Inputs/memprof_pgo.profraw
################################################################################
diff --git a/llvm/test/Transforms/PGOProfile/Inputs/memprof_pgo.profraw b/llvm/test/Transforms/PGOProfile/Inputs/memprof_pgo.profraw
deleted file mode 100644
index d5160e75d5ec22..00000000000000
Binary files a/llvm/test/Transforms/PGOProfile/Inputs/memprof_pgo.profraw and /dev/null
diff er
diff --git a/llvm/test/Transforms/PGOProfile/Inputs/memprof_pgo.proftext b/llvm/test/Transforms/PGOProfile/Inputs/memprof_pgo.proftext
new file mode 100644
index 00000000000000..90268346482958
--- /dev/null
+++ b/llvm/test/Transforms/PGOProfile/Inputs/memprof_pgo.proftext
@@ -0,0 +1,60 @@
+# 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
index 0570e2cf2eefa3..a88e6d73ecb717 100755
--- a/llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh
+++ b/llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh
@@ -1,11 +1,12 @@
#!/bin/bash
-if [ -z $1 ]; then
- echo "Path to clang required!"
- echo "Usage: update_memprof_inputs.sh /path/to/updated/clang"
+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.
@@ -84,6 +85,8 @@ env MEMPROF_OPTIONS=log_path=stdout ${OUTDIR}/memprof.exe > ${OUTDIR}/memprof.me
${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 409f9502add770..5bd97b0e934af6 100644
--- a/llvm/test/Transforms/PGOProfile/memprof.ll
+++ b/llvm/test/Transforms/PGOProfile/memprof.ll
@@ -14,8 +14,8 @@
;; 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.profraw %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.pgomemprofdata
-; RUN: llvm-profdata merge %S/Inputs/memprof_pgo.profraw -o %t.pgoprofdata
+; 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
;; 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
More information about the llvm-commits
mailing list