Skip to content

Commit 969eb4e

Browse files
committed
[msan][NFC] Correct and clarify comment for getShadowPtrOffset()
The stated return type was incorrect; this patch corrects it. More generally, it explains how the Offset and its components fits into the overall shadow mapping calculation.
1 parent d2234ca commit 969eb4e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,13 +1724,15 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
17241724
return ConstantInt::get(MS.IntptrTy, C);
17251725
}
17261726

1727-
/// Compute the integer shadow offset that corresponds to a given
1728-
/// application address.
1727+
/// Returns the integer shadow offset that corresponds to a given
1728+
/// application address, whereby:
17291729
///
1730-
/// Offset = (Addr & ~AndMask) ^ XorMask
1731-
/// Addr can be a ptr or <N x ptr>. In both cases ShadowTy the shadow type of
1732-
/// a single pointee.
1733-
/// Returns <shadow_ptr, origin_ptr> or <<N x shadow_ptr>, <N x origin_ptr>>.
1730+
/// Offset = (Addr & ~AndMask) ^ XorMask
1731+
/// Shadow = ShadowBase + Offset
1732+
/// Origin = (OriginBase + Offset) & ~Alignment
1733+
///
1734+
/// Note: for efficiency, many shadow mappings only require use the XorMask
1735+
/// and OriginBase; the AndMask and ShadowBase are often zero.
17341736
Value *getShadowPtrOffset(Value *Addr, IRBuilder<> &IRB) {
17351737
Type *IntptrTy = ptrToIntPtrType(Addr->getType());
17361738
Value *OffsetLong = IRB.CreatePointerCast(Addr, IntptrTy);

0 commit comments

Comments
 (0)