1// RUN: %clangxx_memprof %s -o %t
2
3// RUN: %env_memprof_opts=print_text=true:log_path=stdout %run %t | FileCheck %s
4
5#include <sanitizer/memprof_interface.h>
6#include <stdlib.h>
7#include <string.h>
8int main(int argc, char **argv) {
9 for (int i = 0; i < 3; i++) {
10 char *x = (char *)malloc(size: 10);
11 if (i % 2)
12 memset(s: x, c: 0, n: 10);
13 else
14 memset(s: x, c: 2, n: 10);
15 free(ptr: x);
16 }
17 return 0;
18}
19// We should get one allocation site with alloc_count = loop trip count = 3
20// CHECK: Memory allocation stack id = [[ID:[0-9]+]]
21// CHECK-NEXT-COUNT-1: alloc_count 3
22// CHECK-COUNT-1: Stack for id {{.*}}[[ID]]
23// CHECK-NEXT-COUNT-1: memprof_malloc_linux.cpp
24// CHECK-NEXT-COUNT-1: memprof_merge_mib.cpp
25

source code of compiler-rt/test/memprof/TestCases/memprof_merge_mib.cpp