xref: /freebsd/contrib/llvm-project/compiler-rt/lib/memprof/memprof_mibmap.h (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
1 #ifndef MEMPROF_MIBMAP_H_
2 #define MEMPROF_MIBMAP_H_
3 
4 #include <stdint.h>
5 
6 #include "profile/MemProfData.inc"
7 #include "sanitizer_common/sanitizer_addrhashmap.h"
8 #include "sanitizer_common/sanitizer_mutex.h"
9 
10 namespace __memprof {
11 
12 struct LockedMemInfoBlock {
13   __sanitizer::StaticSpinMutex mutex;
14   ::llvm::memprof::MemInfoBlock mib;
15 };
16 
17 // The MIB map stores a mapping from stack ids to MemInfoBlocks.
18 typedef __sanitizer::AddrHashMap<LockedMemInfoBlock *, 200003> MIBMapTy;
19 
20 // Insert a new MemInfoBlock or merge with an existing block identified by the
21 // stack id.
22 void InsertOrMerge(const uptr Id, const ::llvm::memprof::MemInfoBlock &Block,
23                    MIBMapTy &Map);
24 
25 } // namespace __memprof
26 
27 #endif // MEMPROF_MIBMAP_H_
28