diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp @@ -1585,6 +1585,9 @@ Hasher.final(Hash); uint8_t Tag = Hash[0]; + // TagMaskByte must be one less than a power of two for the logic below to + // work reliably. + assert((TagMaskByte & (TagMaskByte + 1)) == 0); for (GlobalVariable *GV : Globals) { Tag &= TagMaskByte; // Skip tag 0 in order to avoid collisions with untagged memory.