Skip to content

Commit 0e21ea5

Browse files
[memprof] YAMLify one test (NFC)
This patch replaces the raw binary profile with a YAML profile. I've trimmed the profile by removing all MemProfRecords except the one for _Z3foov. This patch demonstrates that we can see !memprof generated even with a YAML profile.
1 parent 2291e5a commit 0e21ea5

File tree

2 files changed

+131
-63
lines changed

2 files changed

+131
-63
lines changed

llvm/test/Transforms/PGOProfile/memprof_match_hot_cold_new_calls.ll

Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
;; Tests optional matching of memprof profile on call to operator new
2+
;; with manual hot/cold hint.
3+
4+
;; Avoid failures on big-endian systems that can't read the profile properly
5+
; REQUIRES: x86_64-linux
6+
7+
;; Generate the profile and the IR.
8+
; RUN: split-file %s %t
9+
10+
;; Generate indexed profile
11+
; RUN: llvm-profdata merge %t/memprof_match_hot_cold_new_calls.yaml -o %t.memprofdata
12+
13+
;; By default we should not match profile on to manually hinted operator
14+
;; new calls, because we don't currently override the manual hints anyway.
15+
; RUN: opt < %t/memprof_match_hot_cold_new_calls.ll -passes='memprof-use<profile-filename=%t.memprofdata>' -S 2>&1 | FileCheck %s --implicit-check-not !memprof --implicit-check-not !callsite
16+
17+
;; Check that we match profiles onto these manually hinted new calls
18+
;; under the -memprof-match-hot-cold-new=true option.
19+
; RUN: opt < %t/memprof_match_hot_cold_new_calls.ll -passes='memprof-use<profile-filename=%t.memprofdata>' -S -memprof-match-hot-cold-new=true 2>&1 | FileCheck %s --check-prefixes=MEMPROF
20+
21+
;--- memprof_match_hot_cold_new_calls.yaml
22+
---
23+
HeapProfileRecords:
24+
- GUID: _Z3foov
25+
AllocSites:
26+
- Callstack:
27+
- { Function: _Z3foov, LineOffset: 1, Column: 10, IsInlineFrame: false }
28+
- { Function: main, LineOffset: 6, Column: 13, IsInlineFrame: false }
29+
MemInfoBlock:
30+
AllocCount: 1
31+
TotalSize: 10
32+
TotalLifetime: 0
33+
TotalLifetimeAccessDensity: 20000
34+
- Callstack:
35+
- { Function: _Z3foov, LineOffset: 1, Column: 10, IsInlineFrame: false }
36+
- { Function: main, LineOffset: 7, Column: 13, IsInlineFrame: false }
37+
MemInfoBlock:
38+
AllocCount: 1
39+
TotalSize: 10
40+
TotalLifetime: 200000
41+
TotalLifetimeAccessDensity: 0
42+
- Callstack:
43+
- { Function: _Z3foov, LineOffset: 1, Column: 10, IsInlineFrame: false }
44+
- { Function: _Z4foo2v, LineOffset: 1, Column: 10, IsInlineFrame: false }
45+
- { Function: _Z3barv, LineOffset: 1, Column: 10, IsInlineFrame: false }
46+
- { Function: main, LineOffset: 8, Column: 13, IsInlineFrame: false }
47+
MemInfoBlock:
48+
AllocCount: 1
49+
TotalSize: 10
50+
TotalLifetime: 200000
51+
TotalLifetimeAccessDensity: 0
52+
- Callstack:
53+
- { Function: _Z3foov, LineOffset: 1, Column: 10, IsInlineFrame: false }
54+
- { Function: _Z4foo2v, LineOffset: 1, Column: 10, IsInlineFrame: false }
55+
- { Function: _Z3bazv, LineOffset: 1, Column: 10, IsInlineFrame: false }
56+
- { Function: main, LineOffset: 9, Column: 13, IsInlineFrame: false }
57+
MemInfoBlock:
58+
AllocCount: 1
59+
TotalSize: 10
60+
TotalLifetime: 200000
61+
TotalLifetimeAccessDensity: 0
62+
- Callstack:
63+
- { Function: _Z3foov, LineOffset: 1, Column: 10, IsInlineFrame: false }
64+
- { Function: _Z7recursej, LineOffset: 2, Column: 12, IsInlineFrame: false }
65+
- { Function: _Z7recursej, LineOffset: 3, Column: 10, IsInlineFrame: false }
66+
- { Function: _Z7recursej, LineOffset: 3, Column: 10, IsInlineFrame: false }
67+
- { Function: _Z7recursej, LineOffset: 3, Column: 10, IsInlineFrame: false }
68+
- { Function: main, LineOffset: 31, Column: 15, IsInlineFrame: false }
69+
MemInfoBlock:
70+
AllocCount: 1
71+
TotalSize: 10
72+
TotalLifetime: 200000
73+
TotalLifetimeAccessDensity: 0
74+
- Callstack:
75+
- { Function: _Z3foov, LineOffset: 1, Column: 10, IsInlineFrame: false }
76+
- { Function: _Z7recursej, LineOffset: 2, Column: 12, IsInlineFrame: false }
77+
- { Function: _Z7recursej, LineOffset: 3, Column: 10, IsInlineFrame: false }
78+
- { Function: _Z7recursej, LineOffset: 3, Column: 10, IsInlineFrame: false }
79+
- { Function: _Z7recursej, LineOffset: 3, Column: 10, IsInlineFrame: false }
80+
- { Function: _Z7recursej, LineOffset: 3, Column: 10, IsInlineFrame: false }
81+
- { Function: main, LineOffset: 31, Column: 15, IsInlineFrame: false }
82+
MemInfoBlock:
83+
AllocCount: 1
84+
TotalSize: 10
85+
TotalLifetime: 0
86+
TotalLifetimeAccessDensity: 20000
87+
CallSites: []
88+
...
89+
;--- memprof_match_hot_cold_new_calls.ll
90+
; ModuleID = 'memprof_match_hot_cold_new_calls.cc'
91+
source_filename = "memprof_match_hot_cold_new_calls.cc"
92+
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
93+
target triple = "x86_64-unknown-linux-gnu"
94+
95+
%"struct.std::nothrow_t" = type { i8 }
96+
97+
@_ZSt7nothrow = external global %"struct.std::nothrow_t", align 1
98+
99+
define dso_local noundef ptr @_Z3foov() !dbg !10 {
100+
entry:
101+
; MEMPROF: call {{.*}} @_Znwm{{.*}} !memprof ![[M1:[0-9]+]], !callsite ![[C1:[0-9]+]]
102+
%call = call noalias noundef align 32 ptr @_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64 noundef 32, i64 noundef 32, ptr noundef nonnull align 1 dereferenceable(1) @_ZSt7nothrow, i8 noundef zeroext 0), !dbg !13
103+
ret ptr %call
104+
}
105+
106+
declare noundef ptr @_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64 noundef, i64 noundef, ptr noundef nonnull align 1 dereferenceable(1), i8 noundef zeroext)
107+
108+
; MEMPROF: ![[M1]] = !{![[MIB1:[0-9]+]], ![[MIB2:[0-9]+]], ![[MIB3:[0-9]+]], ![[MIB4:[0-9]+]], ![[MIB5:[0-9]+]]}
109+
; MEMPROF: ![[MIB1]] = !{![[STACK1:[0-9]+]], !"cold"}
110+
; MEMPROF: ![[STACK1]] = !{i64 2732490490862098848, i64 748269490701775343}
111+
; MEMPROF: ![[MIB2]] = !{![[STACK2:[0-9]+]], !"cold"}
112+
; MEMPROF: ![[STACK2]] = !{i64 2732490490862098848, i64 2104812325165620841, i64 6281715513834610934, i64 6281715513834610934, i64 6281715513834610934, i64 1544787832369987002}
113+
; MEMPROF: ![[MIB3]] = !{![[STACK3:[0-9]+]], !"notcold"}
114+
; MEMPROF: ![[STACK3]] = !{i64 2732490490862098848, i64 2104812325165620841, i64 6281715513834610934, i64 6281715513834610934, i64 6281715513834610934, i64 6281715513834610934}
115+
; MEMPROF: ![[MIB4]] = !{![[STACK4:[0-9]+]], !"cold"}
116+
; MEMPROF: ![[STACK4]] = !{i64 2732490490862098848, i64 8467819354083268568}
117+
; MEMPROF: ![[MIB5]] = !{![[STACK5:[0-9]+]], !"notcold"}
118+
; MEMPROF: ![[STACK5]] = !{i64 2732490490862098848, i64 8690657650969109624}
119+
; MEMPROF: ![[C1]] = !{i64 2732490490862098848}
120+
121+
!llvm.dbg.cu = !{!0}
122+
!llvm.module.flags = !{!2, !3}
123+
124+
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 15.0.0 (https://github.com/llvm/llvm-project.git 6cbe6284d1f0a088b5c6482ae27b738f03d82fe7)", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, splitDebugInlining: false, debugInfoForProfiling: true, nameTableKind: None)
125+
!1 = !DIFile(filename: "memprof.cc", directory: "/usr/local/google/home/tejohnson/llvm/tmp", checksumkind: CSK_MD5, checksum: "e8c40ebe4b21776b4d60e9632cbc13c2")
126+
!2 = !{i32 7, !"Dwarf Version", i32 5}
127+
!3 = !{i32 2, !"Debug Info Version", i32 3}
128+
!10 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 4, type: !11, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !12)
129+
!11 = !DISubroutineType(types: !12)
130+
!12 = !{}
131+
!13 = !DILocation(line: 5, column: 10, scope: !10)

0 commit comments

Comments
 (0)