[compiler-rt] ab658a4 - [HWASAN] Removed right_aligned from HWASAN allocator Metadata.
Kirill Stoimenov via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 8 11:55:51 PST 2022
Author: Kirill Stoimenov
Date: 2022-12-08T19:55:39Z
New Revision: ab658a48479b9c9a5c6eaee199357f1ee4bb4124
URL: https://github.com/llvm/llvm-project/commit/ab658a48479b9c9a5c6eaee199357f1ee4bb4124
DIFF: https://github.com/llvm/llvm-project/commit/ab658a48479b9c9a5c6eaee199357f1ee4bb4124.diff
LOG: [HWASAN] Removed right_aligned from HWASAN allocator Metadata.
This came up during review of D139464. Looks like this filed is always set to false to it is basically unused.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D139654
Added:
Modified:
compiler-rt/lib/hwasan/hwasan_allocator.cpp
compiler-rt/lib/hwasan/hwasan_allocator.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/hwasan/hwasan_allocator.cpp b/compiler-rt/lib/hwasan/hwasan_allocator.cpp
index 842455150c7b..0f7a0ac8f000 100644
--- a/compiler-rt/lib/hwasan/hwasan_allocator.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_allocator.cpp
@@ -46,16 +46,7 @@ bool HwasanChunkView::IsAllocated() const {
metadata_->get_requested_size();
}
-// Aligns the 'addr' right to the granule boundary.
-static uptr AlignRight(uptr addr, uptr requested_size) {
- uptr tail_size = requested_size % kShadowAlignment;
- if (!tail_size) return addr;
- return addr + kShadowAlignment - tail_size;
-}
-
uptr HwasanChunkView::Beg() const {
- if (metadata_ && metadata_->right_aligned)
- return AlignRight(block_, metadata_->get_requested_size());
return block_;
}
uptr HwasanChunkView::End() const {
@@ -159,7 +150,6 @@ static void *HwasanAllocate(StackTrace *stack, uptr orig_size, uptr alignment,
reinterpret_cast<Metadata *>(allocator.GetMetaData(allocated));
meta->set_requested_size(orig_size);
meta->alloc_context_id = StackDepotPut(*stack);
- meta->right_aligned = false;
if (zeroise) {
internal_memset(allocated, 0, size);
} else if (flags()->max_malloc_fill_size > 0) {
@@ -353,13 +343,7 @@ static uptr AllocationSize(const void *tagged_ptr) {
if (!untagged_ptr) return 0;
const void *beg = allocator.GetBlockBegin(untagged_ptr);
Metadata *b = (Metadata *)allocator.GetMetaData(untagged_ptr);
- if (b->right_aligned) {
- if (beg != reinterpret_cast<void *>(RoundDownTo(
- reinterpret_cast<uptr>(untagged_ptr), kShadowAlignment)))
- return 0;
- } else {
- if (beg != untagged_ptr) return 0;
- }
+ if (beg != untagged_ptr) return 0;
return b->get_requested_size();
}
diff --git a/compiler-rt/lib/hwasan/hwasan_allocator.h b/compiler-rt/lib/hwasan/hwasan_allocator.h
index bae53b565592..c38b28d12624 100644
--- a/compiler-rt/lib/hwasan/hwasan_allocator.h
+++ b/compiler-rt/lib/hwasan/hwasan_allocator.h
@@ -32,8 +32,7 @@ namespace __hwasan {
struct Metadata {
u32 requested_size_low;
- u32 requested_size_high : 31;
- u32 right_aligned : 1;
+ u32 requested_size_high;
u32 alloc_context_id;
u64 get_requested_size() {
return (static_cast<u64>(requested_size_high) << 32) + requested_size_low;
More information about the llvm-commits
mailing list