1 //===-- memprof_mibmap.cpp -----------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file is a part of MemProfiler, a memory profiler.
11 //===----------------------------------------------------------------------===//
13 #include "memprof_mibmap.h"
14 #include "profile/MemProfData.inc"
15 #include "sanitizer_common/sanitizer_allocator_internal.h"
16 #include "sanitizer_common/sanitizer_mutex.h"
19 using ::llvm::memprof::MemInfoBlock
;
21 void InsertOrMerge(const uptr Id
, const MemInfoBlock
&Block
, MIBMapTy
&Map
) {
22 MIBMapTy::Handle
h(&Map
, static_cast<uptr
>(Id
), /*remove=*/false,
25 LockedMemInfoBlock
*lmib
=
26 (LockedMemInfoBlock
*)InternalAlloc(sizeof(LockedMemInfoBlock
));
31 LockedMemInfoBlock
*lmib
= *h
;
32 SpinMutexLock
lock(&lmib
->mutex
);
33 lmib
->mib
.Merge(Block
);
37 } // namespace __memprof