Skip to content

Commit cad961b

Browse files
committed
[NFC][Asan] Remove from_memalign and rz_log
Before D87643 they where used to optimize UsedSize(). Which was called frequently from leak scanner. It was also used for calls from QuarantineCallback but we have heavy get_allocator().Deallocate call there anyway. Depends on D87643. Reviewed By: morehouse Differential Revision: https://reviews.llvm.org/D87644
1 parent d74e1f3 commit cad961b

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

compiler-rt/lib/asan/asan_allocator.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ static const uptr kAllocBegMagic = 0xCC6E96B9;
8989
class ChunkHeader {
9090
public:
9191
atomic_uint8_t chunk_state;
92-
u8 from_memalign : 1;
9392
u8 alloc_type : 2;
94-
u8 rz_log : 3;
9593
u8 lsan_tag : 2;
9694

9795
// align < 8 -> 0
@@ -161,12 +159,6 @@ enum {
161159
class AsanChunk : public ChunkBase {
162160
public:
163161
uptr Beg() { return reinterpret_cast<uptr>(this) + kChunkHeaderSize; }
164-
165-
void *AllocBeg() {
166-
if (from_memalign)
167-
return get_allocator().GetBlockBegin(reinterpret_cast<void *>(this));
168-
return reinterpret_cast<void*>(Beg() - RZLog2Size(rz_log));
169-
}
170162
};
171163

172164
struct QuarantineCallback {
@@ -185,7 +177,7 @@ struct QuarantineCallback {
185177
PoisonShadow(m->Beg(),
186178
RoundUpTo(m->UsedSize(), SHADOW_GRANULARITY),
187179
kAsanHeapLeftRedzoneMagic);
188-
void *p = reinterpret_cast<void *>(m->AllocBeg());
180+
void *p = get_allocator().GetBlockBegin(m);
189181
if (p != m) {
190182
uptr *alloc_magic = reinterpret_cast<uptr *>(p);
191183
CHECK_EQ(alloc_magic[0], kAllocBegMagic);
@@ -541,17 +533,14 @@ struct Allocator {
541533

542534
uptr alloc_beg = reinterpret_cast<uptr>(allocated);
543535
uptr alloc_end = alloc_beg + needed_size;
544-
uptr beg_plus_redzone = alloc_beg + rz_size;
545-
uptr user_beg = beg_plus_redzone;
536+
uptr user_beg = alloc_beg + rz_size;
546537
if (!IsAligned(user_beg, alignment))
547538
user_beg = RoundUpTo(user_beg, alignment);
548539
uptr user_end = user_beg + size;
549540
CHECK_LE(user_end, alloc_end);
550541
uptr chunk_beg = user_beg - kChunkHeaderSize;
551542
AsanChunk *m = reinterpret_cast<AsanChunk *>(chunk_beg);
552543
m->alloc_type = alloc_type;
553-
m->rz_log = rz_log;
554-
m->from_memalign = user_beg != beg_plus_redzone;
555544
if (alloc_beg != chunk_beg) {
556545
CHECK_LE(alloc_beg + 2 * sizeof(uptr), chunk_beg);
557546
reinterpret_cast<uptr *>(alloc_beg)[0] = kAllocBegMagic;

0 commit comments

Comments
 (0)