[llvm] [memprof] Dump call site matching information (PR #125130)
Snehasish Kumar via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 6 09:25:52 PST 2025
================
@@ -0,0 +1,114 @@
+; Tests that the compiler dumps call site matches upon request.
+;
+; The test case is generated from:
+;
+; // main
+; // |
+; // f1 (noinline)
+; // |
+; // f2
+; // |
+; // f3 (noinline)
+; // |
+; // new
+;
+; __attribute__((noinline)) char *f3() { return ::new char[4]; }
+;
+; static char *f2() { return f3(); }
+;
+; __attribute__((noinline)) static char *f1() { return f2(); }
+;
+; int main() {
+; f1();
+; return 0;
+; }
+;
+; Here we expect to match two inline call stacks:
+;
+; - [main]
+; - [f1, f2]
+;
+; Note that f3 is considered to be an allocation site, not a call site, because
+; it directly calls new after inlining.
+
+; REQUIRES: x86_64-linux
+; RUN: split-file %s %t
+; RUN: llvm-profdata merge %t/memprof-dump-matched-call-site.yaml -o %t/memprof-dump-matched-call-site.memprofdata
+; RUN: opt < %t/memprof-dump-matched-call-site.ll -passes='memprof-use<profile-filename=%t/memprof-dump-matched-call-site.memprofdata>' -memprof-print-match-info -S 2>&1 | FileCheck %s
+
+;--- memprof-dump-matched-call-site.yaml
+---
+HeapProfileRecords:
+ - GUID: main
+ AllocSites: []
+ CallSites:
+ - - { Function: main, LineOffset: 1, Column: 3, IsInlineFrame: false }
+ - GUID: _ZL2f1v
+ AllocSites: []
+ CallSites:
+ - - { Function: _ZL2f2v, LineOffset: 0, Column: 28, IsInlineFrame: true }
+ - { Function: _ZL2f1v, LineOffset: 0, Column: 54, IsInlineFrame: false }
+ - GUID: _ZL2f2v
+ AllocSites: []
+ CallSites:
+ - - { Function: _ZL2f2v, LineOffset: 0, Column: 28, IsInlineFrame: true }
+ - { Function: _ZL2f1v, LineOffset: 0, Column: 54, IsInlineFrame: false }
+ - GUID: _Z2f3v
+ AllocSites:
+ - Callstack:
+ - { Function: _Z2f3v, LineOffset: 0, Column: 47, IsInlineFrame: false }
+ - { Function: _ZL2f2v, LineOffset: 0, Column: 28, IsInlineFrame: true }
+ - { Function: _ZL2f1v, LineOffset: 0, Column: 54, IsInlineFrame: false }
+ - { Function: main, LineOffset: 1, Column: 3, IsInlineFrame: false }
+ MemInfoBlock:
+ AllocCount: 1
+ TotalSize: 4
+ TotalLifetime: 0
+ TotalLifetimeAccessDensity: 0
+ CallSites: []
+...
+;--- memprof-dump-matched-call-site.ll
+; CHECK: MemProf notcold context with id 3894143216621363392 has total profiled size 4 is matched
+; CHECK: MemProf callsite match for inline call stack 4745611964195289084 10616861955219347331
----------------
snehasish wrote:
@teresajohnson can you elaborate on this -- `compiler trims unneeded parts of the context during matching`? Are you referring to this [FIXME](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp#L1191-L1194)?
https://github.com/llvm/llvm-project/pull/125130
More information about the llvm-commits
mailing list