[llvm] [memprof] Undrift MemProfRecord (PR #120138)
Snehasish Kumar via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 17 12:23:35 PST 2024
================
@@ -0,0 +1,47 @@
+; REQUIRES: x86_64-linux
+
+; Make sure that we can undrift the MemProf profile and annotate the IR
+; accordingly.
+
+; RUN: split-file %s %t
+; RUN: llvm-profdata merge %t/memprof_annotate_yaml.yaml -o %t/memprof_annotate_yaml.memprofdata
+; RUN: opt < %t/memprof_annotate_yaml.ll -passes='memprof-use<profile-filename=%t/memprof_annotate_yaml.memprofdata>' -memprof-undrift-profile -S 2>&1 | FileCheck %s
+
+;--- memprof_annotate_yaml.yaml
+---
+HeapProfileRecords:
+ - GUID: _Z3foov
+ AllocSites:
+ - Callstack:
+ - { Function: _Z3foov, LineOffset: 3, Column: 30, IsInlineFrame: false }
+ - { Function: main, LineOffset: 2, Column: 5, IsInlineFrame: false }
+ MemInfoBlock:
+ # With these numbers, llvm::memprof::getAllocType will determine that
+ # the call to new is cold. See MemoryProfileInfo.cpp for details.
+ TotalSize: 400
+ AllocCount: 1
+ TotalLifetimeAccessDensity: 1
+ TotalLifetime: 1000000
+ CallSites: []
----------------
snehasish wrote:
Based on the CallSites profile added below bar should have a call to foo (at offset 10) and bar (at offset 20). I don't see these in the IR on L51-L57. I'm expecting that there would be a call to foo with a `!callsite` annotation which we need to check. This would cover the code introduced in MemProfiler.cpp:937.
Additionally, we also want to cover the case where a `!memprof` annotation is introduced. This happens when a single allocation site has hot and cold allocation stacks. Take a look at llvm/test/Transforms/PGOProfile/memprof.ll for examples.
https://github.com/llvm/llvm-project/pull/120138
More information about the llvm-commits
mailing list