[PATCH] D71292: scudo: Tweak how we align UserPtr. NFCI.
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 10 12:10:25 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9fbfdd2bfe42: scudo: Tweak how we align UserPtr. NFCI. (authored by pcc).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71292/new/
https://reviews.llvm.org/D71292
Files:
compiler-rt/lib/scudo/standalone/combined.h
Index: compiler-rt/lib/scudo/standalone/combined.h
===================================================================
--- compiler-rt/lib/scudo/standalone/combined.h
+++ compiler-rt/lib/scudo/standalone/combined.h
@@ -221,11 +221,13 @@
if (UNLIKELY(ZeroContents && ClassId))
memset(Block, 0, PrimaryT::getSizeByClassId(ClassId));
+ const uptr UnalignedUserPtr =
+ reinterpret_cast<uptr>(Block) + Chunk::getHeaderSize();
+ const uptr UserPtr = roundUpTo(UnalignedUserPtr, Alignment);
+
Chunk::UnpackedHeader Header = {};
- uptr UserPtr = reinterpret_cast<uptr>(Block) + Chunk::getHeaderSize();
- if (UNLIKELY(!isAligned(UserPtr, Alignment))) {
- const uptr AlignedUserPtr = roundUpTo(UserPtr, Alignment);
- const uptr Offset = AlignedUserPtr - UserPtr;
+ if (UNLIKELY(UnalignedUserPtr != UserPtr)) {
+ const uptr Offset = UserPtr - UnalignedUserPtr;
DCHECK_GE(Offset, 2 * sizeof(u32));
// The BlockMarker has no security purpose, but is specifically meant for
// the chunk iteration function that can be used in debugging situations.
@@ -233,7 +235,6 @@
// based on its block address.
reinterpret_cast<u32 *>(Block)[0] = BlockMarker;
reinterpret_cast<u32 *>(Block)[1] = static_cast<u32>(Offset);
- UserPtr = AlignedUserPtr;
Header.Offset = (Offset >> MinAlignmentLog) & Chunk::OffsetMask;
}
Header.ClassId = ClassId & Chunk::ClassIdMask;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71292.233167.patch
Type: text/x-patch
Size: 1458 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191210/50c2623a/attachment.bin>
More information about the llvm-commits
mailing list