|
6 | 6 | ;; Avoid failures on big-endian systems that can't read the profile properly |
7 | 7 | ; REQUIRES: x86_64-linux |
8 | 8 |
|
9 | | -;; TODO: Use text profile inputs once that is available for memprof. |
10 | | -;; # To update the Inputs below, run Inputs/update_memprof_inputs.sh. |
11 | 9 | ;; # To generate below LLVM IR for use in matching. |
12 | 10 | ;; $ clang++ -gmlt -fdebug-info-for-profiling -S memprof_missing_leaf.cc \ |
13 | 11 | ;; -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 | +;;} |
14 | 41 |
|
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 |
17 | 45 |
|
| 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 |
18 | 61 | ; CHECK: call {{.*}} @_Znam{{.*}} #[[ATTR:[0-9]+]] |
19 | 62 | ; CHECK: attributes #[[ATTR]] = {{.*}} "memprof"="notcold" |
20 | 63 |
|
|
0 commit comments