[compiler-rt] 6ad91fc - [hwasan] Don't require untagged pointer in __hwasan_tag_memory

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 11 11:19:15 PDT 2023


Author: Vitaly Buka
Date: 2023-04-11T11:18:58-07:00
New Revision: 6ad91fcb7a8c867cc6cfd03bdbb6ee6fa6b6af79

URL: https://github.com/llvm/llvm-project/commit/6ad91fcb7a8c867cc6cfd03bdbb6ee6fa6b6af79
DIFF: https://github.com/llvm/llvm-project/commit/6ad91fcb7a8c867cc6cfd03bdbb6ee6fa6b6af79.diff

LOG: [hwasan] Don't require untagged pointer in __hwasan_tag_memory

Use likely have tagged pointer. I see no value making user to untag it.

Reviewed By: fmayer

Differential Revision: https://reviews.llvm.org/D147671

Added: 
    

Modified: 
    compiler-rt/lib/hwasan/hwasan.cpp
    compiler-rt/test/hwasan/TestCases/hwasan-print-shadow.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/hwasan/hwasan.cpp b/compiler-rt/lib/hwasan/hwasan.cpp
index 0a5999cf7f2a5..097136fe5480c 100644
--- a/compiler-rt/lib/hwasan/hwasan.cpp
+++ b/compiler-rt/lib/hwasan/hwasan.cpp
@@ -553,7 +553,7 @@ void __hwasan_store16_noabort(uptr p) {
 }
 
 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
index 2be0a0591693c..ecf1d9ba24ed2 100644
--- a/compiler-rt/test/hwasan/TestCases/hwasan-print-shadow.cpp
+++ b/compiler-rt/test/hwasan/TestCases/hwasan-print-shadow.cpp
@@ -18,9 +18,7 @@ int main() {
   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);


        


More information about the llvm-commits mailing list