[compiler-rt] 7607ddd - [NFC][DFSan] Cleanup code to use align functions.

Andrew Browne via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 6 14:43:13 PST 2022


Author: Andrew Browne
Date: 2022-01-06T14:42:38-08:00
New Revision: 7607ddd981dd15a8298e6834a66125f4a389b607

URL: https://github.com/llvm/llvm-project/commit/7607ddd981dd15a8298e6834a66125f4a389b607
DIFF: https://github.com/llvm/llvm-project/commit/7607ddd981dd15a8298e6834a66125f4a389b607.diff

LOG: [NFC][DFSan] Cleanup code to use align functions.

Reviewed By: morehouse

Differential Revision: https://reviews.llvm.org/D116761

Added: 
    

Modified: 
    compiler-rt/lib/dfsan/dfsan.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/dfsan/dfsan.cpp b/compiler-rt/lib/dfsan/dfsan.cpp
index 2220dc9b4b84..afb01c7d889e 100644
--- a/compiler-rt/lib/dfsan/dfsan.cpp
+++ b/compiler-rt/lib/dfsan/dfsan.cpp
@@ -332,9 +332,9 @@ static void MoveOrigin(const void *dst, const void *src, uptr size,
   // origins by copying origins in a reverse order; otherwise, copy origins in
   // a normal order. The orders of origin transfer are consistent with the
   // orders of how memcpy and memmove transfer user data.
-  uptr src_aligned_beg = reinterpret_cast<uptr>(src) & ~3UL;
-  uptr src_aligned_end = (reinterpret_cast<uptr>(src) + size) & ~3UL;
-  uptr dst_aligned_beg = reinterpret_cast<uptr>(dst) & ~3UL;
+  uptr src_aligned_beg = OriginAlignDown((uptr)src);
+  uptr src_aligned_end = OriginAlignDown((uptr)src + size);
+  uptr dst_aligned_beg = OriginAlignDown((uptr)dst);
   if (dst_aligned_beg < src_aligned_end && dst_aligned_beg >= src_aligned_beg)
     return ReverseCopyOrigin(dst, src, size, stack);
   return CopyOrigin(dst, src, size, stack);


        


More information about the llvm-commits mailing list