Skip to content

Commit bd13241

Browse files
authored
[MemProf][NFC] Clean up runtime code (#80581)
1 parent 6d26857 commit bd13241

File tree

5 files changed

+11
-17
lines changed

5 files changed

+11
-17
lines changed

compiler-rt/lib/memprof/memprof_allocator.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,7 @@ struct Allocator {
515515
return ptr;
516516
}
517517

518-
void CommitBack(MemprofThreadLocalMallocStorage *ms,
519-
BufferedStackTrace *stack) {
518+
void CommitBack(MemprofThreadLocalMallocStorage *ms) {
520519
AllocatorCache *ac = GetAllocatorCache(ms);
521520
allocator.SwallowCache(ac);
522521
}
@@ -561,7 +560,7 @@ struct Allocator {
561560
return reinterpret_cast<MemprofChunk *>(p - kChunkHeaderSize)->UsedSize();
562561
}
563562

564-
void Purge(BufferedStackTrace *stack) { allocator.ForceReleaseToOS(); }
563+
void Purge() { allocator.ForceReleaseToOS(); }
565564

566565
void PrintStats() { allocator.PrintStats(); }
567566

@@ -583,8 +582,7 @@ static MemprofAllocator &get_allocator() { return instance.allocator; }
583582
void InitializeAllocator() { instance.InitLinkerInitialized(); }
584583

585584
void MemprofThreadLocalMallocStorage::CommitBack() {
586-
GET_STACK_TRACE_MALLOC;
587-
instance.CommitBack(this, &stack);
585+
instance.CommitBack(this);
588586
}
589587

590588
void PrintInternalAllocatorStats() { instance.PrintStats(); }
@@ -699,7 +697,7 @@ static const void *memprof_malloc_begin(const void *p) {
699697
return (const void *)m->Beg();
700698
}
701699

702-
uptr memprof_malloc_usable_size(const void *ptr, uptr pc, uptr bp) {
700+
uptr memprof_malloc_usable_size(const void *ptr) {
703701
if (!ptr)
704702
return 0;
705703
uptr usable_size = instance.AllocationSize(reinterpret_cast<uptr>(ptr));
@@ -714,15 +712,15 @@ using namespace __memprof;
714712
uptr __sanitizer_get_estimated_allocated_size(uptr size) { return size; }
715713

716714
int __sanitizer_get_ownership(const void *p) {
717-
return memprof_malloc_usable_size(p, 0, 0) != 0;
715+
return memprof_malloc_usable_size(p) != 0;
718716
}
719717

720718
const void *__sanitizer_get_allocated_begin(const void *p) {
721719
return memprof_malloc_begin(p);
722720
}
723721

724722
uptr __sanitizer_get_allocated_size(const void *p) {
725-
return memprof_malloc_usable_size(p, 0, 0);
723+
return memprof_malloc_usable_size(p);
726724
}
727725

728726
uptr __sanitizer_get_allocated_size_fast(const void *p) {
@@ -732,6 +730,8 @@ uptr __sanitizer_get_allocated_size_fast(const void *p) {
732730
return ret;
733731
}
734732

733+
void __sanitizer_purge_allocator() { instance.Purge(); }
734+
735735
int __memprof_profile_dump() {
736736
instance.FinishAndWrite();
737737
// In the future we may want to return non-zero if there are any errors

compiler-rt/lib/memprof/memprof_allocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void *memprof_aligned_alloc(uptr alignment, uptr size,
9999
BufferedStackTrace *stack);
100100
int memprof_posix_memalign(void **memptr, uptr alignment, uptr size,
101101
BufferedStackTrace *stack);
102-
uptr memprof_malloc_usable_size(const void *ptr, uptr pc, uptr bp);
102+
uptr memprof_malloc_usable_size(const void *ptr);
103103

104104
void PrintInternalAllocatorStats();
105105

compiler-rt/lib/memprof/memprof_interceptors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ INTERCEPTOR(int, pthread_create, void *thread, void *attr,
163163
}
164164

165165
INTERCEPTOR(int, pthread_join, void *t, void **arg) {
166-
return real_pthread_join(t, arg);
166+
return REAL(pthread_join)(t, arg);
167167
}
168168

169169
DEFINE_REAL_PTHREAD_FUNCTIONS

compiler-rt/lib/memprof/memprof_internal.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
#include "sanitizer_common/sanitizer_libc.h"
2121
#include "sanitizer_common/sanitizer_stacktrace.h"
2222

23-
#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
24-
#error "The MemProfiler run-time should not be instrumented by MemProfiler"
25-
#endif
26-
2723
// Build-time configuration options.
2824

2925
// If set, memprof will intercept C++ exception api call(s).

compiler-rt/lib/memprof/memprof_malloc_linux.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ INTERCEPTOR(void *, aligned_alloc, uptr boundary, uptr size) {
104104
#endif // SANITIZER_INTERCEPT_ALIGNED_ALLOC
105105

106106
INTERCEPTOR(uptr, malloc_usable_size, void *ptr) {
107-
GET_CURRENT_PC_BP_SP;
108-
(void)sp;
109-
return memprof_malloc_usable_size(ptr, pc, bp);
107+
return memprof_malloc_usable_size(ptr);
110108
}
111109

112110
#if SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO

0 commit comments

Comments
 (0)