Files
clang-p2996/llvm/test/tools/llvm-profdata/memprof-basic.test
Snehasish Kumar 3a4d373ec2 [memprof] Align each rawprofile section to 8b.
The first 8b of each raw profile section need to be aligned to 8b since
the first item in each section is a u64 count of the number of items in
the section.
Summary of changes:
* Assert alignment when reading counts.
* Update test to check alignment, relax some size checks to allow padding.
* Update raw binary inputs for llvm-profdata tests.

Differential Revision: https://reviews.llvm.org/D114826
2021-11-30 20:12:43 -08:00

43 lines
1.3 KiB
Plaintext

REQUIRES: x86_64-linux
The input raw profile test has been 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;
}
```
The following commands were used to compile the source to a memprof instrumented
executable and collect a raw binary format profile. Since the profile contains
virtual addresses for the callstack, we do not expect the raw binary profile to
be deterministic. The summary should be deterministic apart from changes to
the shared libraries linked in which could change the number of segments
recorded.
```
clang -fmemory-profile -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m64 -Wl,-build-id source.c -o rawprofile.out
env MEMPROF_OPTIONS=log_path=stdout ./rawprofile.out > basic.memprofraw
```
RUN: llvm-profdata show --memory %p/Inputs/basic.memprofraw -o - | FileCheck %s
We expect 3 MIB entries, 1 each for the malloc calls in the program and one
additional entry from a realloc in glibc/libio/vasprintf.c.
CHECK: MemProf Profile 1
CHECK: Version: 1
CHECK: TotalSizeBytes: 1016
CHECK: NumSegments: 9
CHECK: NumMIBInfo: 3
CHECK: NumStackOffsets: 3