[PATCH] D102901: [HWASAN] Update pointer tag for X86_64

Evgenii Stepanov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 3 14:15:37 PDT 2021


eugenis added inline comments.


================
Comment at: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp:966
 
+static unsigned retagX86(unsigned AllocaNo, uint64_t TagMaskByte) {
+  return AllocaNo & TagMaskByte;
----------------
retagMaskX86

You could also make this non-static and get rid of the second argument. Or apply the mask in `retagMask`.


================
Comment at: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp:1036
+
+  Value *Tag = IRB.CreateXor(StackTag, ConstantInt::get(IntptrTy, 0xFFU));
+  return applyTagMask(IRB, Tag);
----------------
Why not simply replace 0xFF here with TagMaskByte?


================
Comment at: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp:1018
+
+  StackTag = retagTargetTag(IRB, StackTag);
+
----------------
xiangzhangllvm wrote:
> morehouse wrote:
> > This mask of the base tag seems unnecessary since we also mask the final tag.
> make sense, it seem will handle at retagTargetTag fucntion.
It seems more efficient to mask StackTag,  and then make sure that all retag constants are within the mask bits. This way you'll only need to apply the mask once per function.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102901/new/

https://reviews.llvm.org/D102901



More information about the llvm-commits mailing list