diff --git a/compiler-rt/lib/hwasan/hwasan.cpp b/compiler-rt/lib/hwasan/hwasan.cpp --- a/compiler-rt/lib/hwasan/hwasan.cpp +++ b/compiler-rt/lib/hwasan/hwasan.cpp @@ -553,7 +553,7 @@ } void __hwasan_tag_memory(uptr p, u8 tag, uptr sz) { - TagMemoryAligned(p, sz, tag); + TagMemoryAligned(UntagAddr(p), sz, tag); } uptr __hwasan_tag_pointer(uptr p, u8 tag) { diff --git a/compiler-rt/test/hwasan/TestCases/hwasan-print-shadow.cpp b/compiler-rt/test/hwasan/TestCases/hwasan-print-shadow.cpp --- a/compiler-rt/test/hwasan/TestCases/hwasan-print-shadow.cpp +++ b/compiler-rt/test/hwasan/TestCases/hwasan-print-shadow.cpp @@ -18,9 +18,7 @@ alloc[79] = 0xee; alloc[95] = 0xff; - // __hwasan_tag_memory expects untagged pointers. - char *p = (char *)__hwasan_tag_pointer(alloc, 0); - assert(p); + char *p = alloc; // Write tags to shadow. __hwasan_tag_memory(p, 1, 32);