Skip to content

Commit a03343d

Browse files
[memprof] YAMLify the profile for memprof_missing_leaf.ll (NFC) (llvm#120488)
This patch converts the profile for memprof_missing_leaf.ll to the recently introduced YAML-based text format.
1 parent 46e7823 commit a03343d

File tree

4 files changed

+47
-37
lines changed

4 files changed

+47
-37
lines changed
-1.53 MB
Binary file not shown.
Binary file not shown.

llvm/test/Transforms/PGOProfile/Inputs/update_memprof_inputs.sh

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -95,39 +95,6 @@ rm ${OUTDIR}/memprof.cc
9595
rm ${OUTDIR}/pgo.exe
9696
rm ${OUTDIR}/memprof_pgo.profraw
9797

98-
# Use musttail to simulate a missing leaf debug frame in the profiled binary.
99-
# Note we don't currently match onto explicit ::operator new calls, which is
100-
# why the non-musttail case uses implicit new (which doesn't support musttail).
101-
# Note that changes in the code below which affect relative line number
102-
# offsets of calls from their parent function can affect callsite matching in
103-
# the LLVM IR.
104-
cat > ${OUTDIR}/memprof_missing_leaf.cc << EOF
105-
#include <new>
106-
#ifndef USE_MUSTTAIL
107-
#define USE_MUSTTAIL 0
108-
#endif
109-
110-
// clang::musttail requires that the argument signature matches that of the caller.
111-
void *bar(std::size_t s) {
112-
#if USE_MUSTTAIL
113-
[[clang::musttail]] return ::operator new (s);
114-
#else
115-
return new char[s];
116-
#endif
117-
}
118-
119-
int main() {
120-
char *a = (char *)bar(1);
121-
delete a;
122-
return 0;
123-
}
124-
EOF
125-
126-
${CLANG} ${COMMON_FLAGS} -fmemory-profile -DUSE_MUSTTAIL=1 ${OUTDIR}/memprof_missing_leaf.cc -o ${OUTDIR}/memprof_missing_leaf.exe
127-
env MEMPROF_OPTIONS=log_path=stdout ${OUTDIR}/memprof_missing_leaf.exe > ${OUTDIR}/memprof_missing_leaf.memprofraw
128-
129-
rm ${OUTDIR}/memprof_missing_leaf.cc
130-
13198
cat > ${OUTDIR}/memprof_internal_linkage.cc << EOF
13299
#include <cstring>
133100
#include <unistd.h>

llvm/test/Transforms/PGOProfile/memprof_missing_leaf.ll

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,58 @@
66
;; Avoid failures on big-endian systems that can't read the profile properly
77
; REQUIRES: x86_64-linux
88

9-
;; TODO: Use text profile inputs once that is available for memprof.
10-
;; # To update the Inputs below, run Inputs/update_memprof_inputs.sh.
119
;; # To generate below LLVM IR for use in matching.
1210
;; $ clang++ -gmlt -fdebug-info-for-profiling -S memprof_missing_leaf.cc \
1311
;; -O2 -emit-llvm
12+
;;
13+
;; where memprof_missing_leaf.cc is as follows:
14+
;;
15+
;; #include <new>
16+
;;
17+
;; // Use musttail to simulate a missing leaf debug frame in the profiled binary.
18+
;; // Note we don't currently match onto explicit ::operator new calls, which is
19+
;; // why the non-musttail case uses implicit new (which doesn't support musttail).
20+
;; // Note that changes in the code below which affect relative line number
21+
;; // offsets of calls from their parent function can affect callsite matching in
22+
;; // the LLVM IR.
23+
;; #ifndef USE_MUSTTAIL
24+
;; #define USE_MUSTTAIL 0
25+
;; #endif
26+
;;
27+
;; // clang::musttail requires that the argument signature matches that of the caller.
28+
;; void *bar(std::size_t s) {
29+
;; #if USE_MUSTTAIL
30+
;; [[clang::musttail]] return ::operator new (s);
31+
;; #else
32+
;; return new char[s];
33+
;; #endif
34+
;; }
35+
;;
36+
;; int main() {
37+
;; char *a = (char *)bar(1);
38+
;; delete a;
39+
;; return 0;
40+
;;}
1441

15-
; RUN: llvm-profdata merge %S/Inputs/memprof_missing_leaf.memprofraw --profiled-binary %S/Inputs/memprof_missing_leaf.exe -o %t.memprofdata
16-
; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -S | FileCheck %s
42+
; RUN: split-file %s %t
43+
; RUN: llvm-profdata merge %t/memprof_missing_leaf.yaml -o %t/memprof_missing_leaf.memprofdata
44+
; RUN: opt < %t/memprof_missing_leaf.ll -passes='memprof-use<profile-filename=%t/memprof_missing_leaf.memprofdata>' -S | FileCheck %s
1745

46+
;--- memprof_missing_leaf.yaml
47+
---
48+
HeapProfileRecords:
49+
- GUID: main
50+
AllocSites:
51+
- Callstack:
52+
- { Function: main, LineOffset: 1, Column: 21, IsInlineFrame: false }
53+
MemInfoBlock:
54+
AllocCount: 1
55+
TotalSize: 1
56+
TotalLifetime: 0
57+
TotalLifetimeAccessDensity: 0
58+
CallSites: []
59+
...
60+
;--- memprof_missing_leaf.ll
1861
; CHECK: call {{.*}} @_Znam{{.*}} #[[ATTR:[0-9]+]]
1962
; CHECK: attributes #[[ATTR]] = {{.*}} "memprof"="notcold"
2063

0 commit comments

Comments
 (0)