Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / lib / memprof / memprof_stats.h
blobebdaa1909817a0d3c19b154dfb7007c06d512cf0
1 //===-- memprof_stats.h ----------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file is a part of MemProfiler, a memory profiler.
11 // MemProf-private header for statistics.
12 //===----------------------------------------------------------------------===//
13 #ifndef MEMPROF_STATS_H
14 #define MEMPROF_STATS_H
16 #include "memprof_allocator.h"
17 #include "memprof_internal.h"
19 namespace __memprof {
21 // MemprofStats struct is NOT thread-safe.
22 // Each MemprofThread has its own MemprofStats, which are sometimes flushed
23 // to the accumulated MemprofStats.
24 struct MemprofStats {
25 // MemprofStats must be a struct consisting of uptr fields only.
26 // When merging two MemprofStats structs, we treat them as arrays of uptr.
27 uptr mallocs;
28 uptr malloced;
29 uptr malloced_overhead;
30 uptr frees;
31 uptr freed;
32 uptr real_frees;
33 uptr really_freed;
34 uptr reallocs;
35 uptr realloced;
36 uptr mmaps;
37 uptr mmaped;
38 uptr munmaps;
39 uptr munmaped;
40 uptr malloc_large;
41 uptr malloced_by_size[kNumberOfSizeClasses];
43 // Ctor for global MemprofStats (accumulated stats for dead threads).
44 explicit MemprofStats(LinkerInitialized) {}
45 // Creates empty stats.
46 MemprofStats();
48 void Print(); // Prints formatted stats to stderr.
49 void Clear();
50 void MergeFrom(const MemprofStats *stats);
53 // Returns stats for GetCurrentThread(), or stats for fake "unknown thread"
54 // if GetCurrentThread() returns 0.
55 MemprofStats &GetCurrentThreadStats();
56 // Flushes a given stats into accumulated stats of dead threads.
57 void FlushToDeadThreadStats(MemprofStats *stats);
59 } // namespace __memprof
61 #endif // MEMPROF_STATS_H