This patch filters out callstack frames which can't be symbolized or if the frames belong to the runtime. Symbolization may not be possible if debug information is unavailable or if the addresses are from a shared library. For now we only support optimization of the main binary which is statically linked to the compiler runtime. Differential Revision: https://reviews.llvm.org/D120860
55 lines
1.7 KiB
Plaintext
55 lines
1.7 KiB
Plaintext
REQUIRES: x86_64-linux
|
|
|
|
The input raw profile test has been generated from the following source code:
|
|
|
|
```
|
|
#include <sanitizer/memprof_interface.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
int main(int argc, char **argv) {
|
|
char *x = (char *)malloc(10);
|
|
memset(x, 0, 10);
|
|
free(x);
|
|
__memprof_profile_dump();
|
|
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 -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 multi.memprofexe
|
|
|
|
env MEMPROF_OPTIONS=log_path=stdout ./rawprofile.out > multi.memprofraw
|
|
```
|
|
|
|
RUN: llvm-profdata show --memory %p/Inputs/multi.memprofraw --profiled-binary %p/Inputs/multi.memprofexe -o - | FileCheck %s
|
|
|
|
We expect 2 MIB entries, 1 each for the malloc calls in the program.
|
|
|
|
CHECK: MemprofProfile:
|
|
CHECK-NEXT: -
|
|
CHECK-NEXT: Header:
|
|
CHECK-NEXT: Version: 1
|
|
CHECK-NEXT: TotalSizeBytes: 864
|
|
CHECK-NEXT: NumSegments: 9
|
|
CHECK-NEXT: NumMibInfo: 2
|
|
CHECK-NEXT: NumStackOffsets: 2
|
|
CHECK-NEXT: -
|
|
CHECK-NEXT: Header:
|
|
CHECK-NEXT: Version: 1
|
|
CHECK-NEXT: TotalSizeBytes: 864
|
|
CHECK-NEXT: NumSegments: 9
|
|
CHECK-NEXT: NumMibInfo: 2
|
|
CHECK-NEXT: NumStackOffsets: 2
|