@@ -1114,8 +1114,6 @@ void HWAddressSanitizer::tagAlloca(IRBuilder<> &IRB, AllocaInst *AI, Value *Tag,
1114
1114
// FIXME: the interceptor is not as fast as real memset. Consider lowering
1115
1115
// llvm.memset right here into either a sequence of stores, or a call to
1116
1116
// hwasan_tag_memory.
1117
- // Mechanical proof of this address calculation can be found at:
1118
- // https://github.com/google/sanitizers/blob/master/hwaddress-sanitizer/prove_hwasanwrap.smt2
1119
1117
if (ShadowSize)
1120
1118
IRB.CreateMemSet (ShadowPtr, Tag, ShadowSize, Align (1 ));
1121
1119
if (Size != AlignedSize) {
@@ -1312,6 +1310,22 @@ void HWAddressSanitizer::emitPrologue(IRBuilder<> &IRB, bool WithFrameRecord) {
1312
1310
// The use of AShr instead of LShr is due to
1313
1311
// https://bugs.llvm.org/show_bug.cgi?id=39030
1314
1312
// Runtime library makes sure not to use the highest bit.
1313
+ //
1314
+ // Mechanical proof of this address calculation can be found at:
1315
+ // https://github.com/google/sanitizers/blob/master/hwaddress-sanitizer/prove_hwasanwrap.smt2
1316
+ //
1317
+ // Example of the wrap case for N = 1
1318
+ // Pointer: 0x01AAAAAAAAAAAFF8
1319
+ // +
1320
+ // 0x0000000000000008
1321
+ // =
1322
+ // 0x01AAAAAAAAAAB000
1323
+ // &
1324
+ // WrapMask: 0xFFFFFFFFFFFFF000
1325
+ // =
1326
+ // 0x01AAAAAAAAAAA000
1327
+ //
1328
+ // Then the WrapMask will be a no-op until the next wrap case.
1315
1329
Value *WrapMask = IRB.CreateXor (
1316
1330
IRB.CreateShl (IRB.CreateAShr (ThreadLong, 56 ), 12 , " " , true , true ),
1317
1331
ConstantInt::get (IntptrTy, (uint64_t )-1 ));
0 commit comments