[Lldb-commits] [llvm] [clang] [compiler-rt] [lldb] [libcxx] [mlir] [clang-tools-extra] [lld] [hwasan] Add `__hwasan_get_tag_from_pointer` (PR #75267)

Vitaly Buka via lldb-commits lldb-commits at lists.llvm.org
Wed Dec 13 10:28:15 PST 2023


================
@@ -0,0 +1,24 @@
+// RUN: %clangxx_hwasan -O0 %s -o %t && %run %t
+
+#include <assert.h>
+#include <memory>
+#include <sanitizer/hwasan_interface.h>
+#include <set>
+#include <stdio.h>
+
+int main() {
+  auto p = std::make_unique<char>();
+  std::set<void *> ptrs;
+  for (unsigned i = 0;; ++i) {
+    void *ptr = __hwasan_tag_pointer(p.get(), i);
+    if (!ptrs.insert(ptr).second)
+      break;
+    fprintf(stderr, "%p, %u, %u\n", ptr, i, __hwasan_get_tag_from_pointer(ptr));
+    assert(__hwasan_get_tag_from_pointer(ptr) == i);
+  }
+#ifdef __x86_64__
+  assert(ptrs.size() == 8);
----------------
vitalybuka wrote:

REQUIRES will disable the test completely. 
I guess we will update ifdef when we (or someone else) will have LAM

https://github.com/llvm/llvm-project/pull/75267


More information about the lldb-commits mailing list