1// RUN: mkdir -p %t.d && cd %t.d
2// RUN: rm -f *.profraw
3// RUN: %clang_pgogen %s -o a.out
4
5// Need to run a.out twice. On the second time, a merge will occur, which will
6// trigger an mmap.
7// RUN: ./a.out
8// RUN: llvm-profdata show default_*.profraw --all-functions --counts --memop-sizes 2>&1 | FileCheck %s -check-prefix=PROFDATA
9// RUN: env LLVM_PROFILE_NO_MMAP=1 LLVM_PROFILE_VERBOSE=1 ./a.out 2>&1 | FileCheck %s
10// RUN: llvm-profdata show default_*.profraw --all-functions --counts --memop-sizes 2>&1 | FileCheck %s -check-prefix=PROFDATA2
11
12// CHECK: could not use mmap; using fread instead
13// PROFDATA: Block counts: [1]
14// PROFDATA: [ 0, 0, 1 ]
15// PROFDATA: Maximum function count: 1
16// PROFDATA2: Block counts: [2]
17// PROFDATA2: [ 0, 0, 2 ]
18// PROFDATA2: Maximum function count: 2
19
20int ar[8];
21int main() {
22 __builtin_memcpy(ar, ar + 2, ar[0]);
23 __builtin_memcpy(ar, ar + 2, ar[2]);
24 return ar[2];
25}
26

source code of compiler-rt/test/profile/instrprof-no-mmap-during-merging.c