[llvm] [HWASAN] Use sign extension in memToShadow() and untagPointer() (PR #103727)

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 9 16:07:55 PST 2024


================
@@ -1328,20 +1327,10 @@ Value *HWAddressSanitizer::tagPointer(IRBuilder<> &IRB, Type *Ty,
 
 // Remove tag from an address.
 Value *HWAddressSanitizer::untagPointer(IRBuilder<> &IRB, Value *PtrLong) {
+  unsigned SignExtShift = 64 - PointerTagShift;
   assert(!UsePageAliases);
-  Value *UntaggedPtrLong;
-  if (CompileKernel) {
-    // Kernel addresses have 0xFF in the most significant byte.
-    UntaggedPtrLong =
-        IRB.CreateOr(PtrLong, ConstantInt::get(PtrLong->getType(),
-                                               TagMaskByte << PointerTagShift));
----------------
vitalybuka wrote:

Looks fine for canonical addresses https://godbolt.org/z/z3rYjjbrz

https://github.com/llvm/llvm-project/pull/103727


More information about the llvm-commits mailing list