-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[memprof] Dump the number of matched frames #137082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kazutakahirata
merged 2 commits into
llvm:main
from
kazutakahirata:memprof_inlinedcallstack_size
Apr 24, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
llvm/test/Transforms/PGOProfile/memprof-dump-matched-alloc-site.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| ; Tests that the compiler dumps an allocation site with multiple inlined frames. | ||
| ; | ||
| ; The test case is generated from: | ||
| ; | ||
| ; // main | ||
| ; // | | ||
| ; // f1 (noinline) | ||
| ; // | | ||
| ; // f2 | ||
| ; // | | ||
| ; // f3 | ||
| ; // | | ||
| ; // new | ||
| ; | ||
| ; char *f1() { return new char[3]; } | ||
| ; char *f2() { return f1(); } | ||
| ; __attribute__((noinline)) char *f3() { return f2(); } | ||
| ; | ||
| ; int main() { | ||
| ; f3(); | ||
| ; return 0; | ||
| ; } | ||
| ; | ||
| ; Here we expect to match the allocation site to encompass 3 frames. | ||
|
|
||
| ; REQUIRES: x86_64-linux | ||
| ; RUN: split-file %s %t | ||
| ; RUN: llvm-profdata merge %t/memprof-dump-matched-alloc-site.yaml -o %t/memprof-dump-matched-alloc-site.memprofdata | ||
| ; RUN: opt < %t/memprof-dump-matched-alloc-site.ll -passes='memprof-use<profile-filename=%t/memprof-dump-matched-alloc-site.memprofdata>' -memprof-print-match-info -S 2>&1 | FileCheck %s | ||
|
|
||
| ;--- memprof-dump-matched-alloc-site.yaml | ||
| --- | ||
| HeapProfileRecords: | ||
| - GUID: _Z2f3v | ||
| AllocSites: | ||
| - Callstack: | ||
| - { Function: _ZL2f1v, LineOffset: 0, Column: 35, IsInlineFrame: true } | ||
| - { Function: _ZL2f2v, LineOffset: 0, Column: 35, IsInlineFrame: true } | ||
| - { Function: _Z2f3v, LineOffset: 0, Column: 47, IsInlineFrame: false } | ||
| - { Function: main, LineOffset: 1, Column: 3, IsInlineFrame: false } | ||
| MemInfoBlock: | ||
| AllocCount: 1 | ||
| TotalSize: 3 | ||
| TotalLifetime: 0 | ||
| TotalLifetimeAccessDensity: 0 | ||
| CallSites: | ||
| # Kept empty here because this section is irrelevant for this test. | ||
| ... | ||
| ;--- memprof-dump-matched-alloc-site.ll | ||
| ; CHECK: MemProf notcold context with id 12978026349401156968 has total profiled size 3 is matched with 3 frames | ||
|
|
||
| target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" | ||
| target triple = "x86_64-unknown-linux-gnu" | ||
|
|
||
| define ptr @_Z2f3v() { | ||
| entry: | ||
| %call.i.i = call ptr @_Znam(i64 0), !dbg !3 | ||
| ret ptr null | ||
| } | ||
|
|
||
| declare ptr @_Znam(i64) | ||
|
|
||
| !llvm.dbg.cu = !{!0} | ||
| !llvm.module.flags = !{!2} | ||
|
|
||
| !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1) | ||
| !1 = !DIFile(filename: "memprof-dump-matched-alloc-site.cc", directory: "/") | ||
| !2 = !{i32 2, !"Debug Info Version", i32 3} | ||
| !3 = !DILocation(line: 1, column: 35, scope: !4, inlinedAt: !7) | ||
| !4 = distinct !DISubprogram(name: "f1", linkageName: "_ZL2f1v", scope: !1, file: !1, line: 1, type: !5, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0) | ||
| !5 = !DISubroutineType(types: !6) | ||
| !6 = !{} | ||
| !7 = distinct !DILocation(line: 2, column: 35, scope: !8, inlinedAt: !9) | ||
| !8 = distinct !DISubprogram(name: "f2", linkageName: "_ZL2f2v", scope: !1, file: !1, line: 2, type: !5, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0) | ||
| !9 = distinct !DILocation(line: 3, column: 47, scope: !10) | ||
| !10 = distinct !DISubprogram(name: "f3", linkageName: "_Z2f3v", scope: !1, file: !1, line: 3, type: !5, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) | ||
| !11 = !DILocation(line: 6, column: 3, scope: !12) | ||
| !12 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 5, type: !5, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.