Files
clang-p2996/llvm/test/tools/llvm-profdata/memprof-merge.test
Snehasish Kumar 0a4184909a Reland "[memprof] Extend the index prof format to include memory profiles."
This patch adds support for optional memory profile information to be
included with and indexed profile. The indexed profile header adds a new
field which points to the offset of the memory profile section (if
present) in the indexed profile. For users who do not utilize this
feature the only overhead is a 64-bit offset in the header.

The memory profile section contains (1) profile metadata describing the
information recorded for each entry (2) an on-disk hashtable containing
the profile records indexed via llvm::md5(function_name). We chose to
introduce a separate hash table instead of the existing one since the
indexing for the instrumented fdo hash table is based on a CFG hash
which itself is perturbed by memprof instrumentation.

This commit also includes the changes reviewed separately in D120093.

Differential Revision: https://reviews.llvm.org/D120103
2022-02-17 22:09:52 -08:00

48 lines
1.4 KiB
Plaintext

REQUIRES: x86_64-linux
The input memprof and instrumented raw profiles were generated from the following source code:
```
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv) {
char *x = (char *)malloc(10);
memset(x, 0, 10);
free(x);
x = (char *)malloc(10);
memset(x, 0, 10);
free(x);
return 0;
}
```
Steps to collect the memprof raw profile and the instrprof raw profile:
```
# Collect instrprof profile with name compression disabled since some buildbots
# do not have zlib.
clang -mllvm -enable-name-compression=false -fprofile-generate source.c -o instr.out
./instr.out
mv *.profraw basic.profraw
# Collect memprof profile.
clang -fuse-ld=lld -Wl,--no-rosegment -gmlt -fdebug-info-for-profiling \
-fmemory-profile -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer \
-fno-optimize-sibling-calls -m64 -Wl,-build-id source.c -o basic.memprofexe
env MEMPROF_OPTIONS=log_path=stdout ./rawprofile.out > basic.memprofraw
```
RUN: llvm-profdata merge %p/Inputs/basic.profraw %p/Inputs/basic.memprofraw --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof
RUN: llvm-profdata show %t.prof | FileCheck %s
For now we only check the validity of the instrumented profile since we don't
have a way to display the contents of the memprof indexed format yet.
CHECK: Instrumentation level: IR entry_first = 0
CHECK: Total functions: 1
CHECK: Maximum function count: 1
CHECK: Maximum internal block count: 0