[AArch64] Fix SDNode type mismatches between *.td files and ISel (#116523)
[llvm-project.git] / compiler-rt / lib / memprof / memprof_stack.cpp
blobb5beeeadafd7084ed7d875a2363057149eff7b2a
1 //===-- memprof_stack.cpp ------------------------------------------------===//
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 // Code for MemProf stack trace.
12 //===----------------------------------------------------------------------===//
13 #include "memprof_stack.h"
14 #include "memprof_internal.h"
15 #include "sanitizer_common/sanitizer_atomic.h"
17 namespace __memprof {
19 static atomic_uint32_t malloc_context_size;
21 void SetMallocContextSize(u32 size) {
22 atomic_store(&malloc_context_size, size, memory_order_release);
25 u32 GetMallocContextSize() {
26 return atomic_load(&malloc_context_size, memory_order_acquire);
29 } // namespace __memprof
31 void __sanitizer::BufferedStackTrace::UnwindImpl(uptr pc, uptr bp,
32 void *context,
33 bool request_fast,
34 u32 max_depth) {
35 using namespace __memprof;
36 size = 0;
37 if (UNLIKELY(!memprof_inited))
38 return;
39 request_fast = StackTrace::WillUseFastUnwind(request_fast);
40 MemprofThread *t = GetCurrentThread();
41 if (request_fast) {
42 if (t) {
43 Unwind(max_depth, pc, bp, nullptr, t->stack_top(), t->stack_bottom(),
44 true);
46 return;
48 Unwind(max_depth, pc, bp, context, 0, 0, false);
51 // ------------------ Interface -------------- {{{1
53 extern "C" {
54 SANITIZER_INTERFACE_ATTRIBUTE
55 void __sanitizer_print_stack_trace() {
56 using namespace __memprof;
57 PRINT_CURRENT_STACK();
59 } // extern "C"