[compiler-rt] [compiler-rt][nsan] Add more tests for shadow memory (PR #100906)
Alexander Shaposhnikov via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 10:44:14 PDT 2024
================
@@ -0,0 +1,55 @@
+// RUN: %clangxx_nsan -O2 -g %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+// RUN: %clangxx_nsan -fno-builtin -O2 -g %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+// This tests a particularaly hard case of memory tracking. stable_sort does
+// conditional swaps of pairs of elements with mixed types (int/double).
+
+#include <algorithm>
+#include <cstddef>
+#include <cstdio>
+#include <utility>
+#include <vector>
+
+extern "C" void __nsan_dump_shadow_mem(const char *addr, size_t size_bytes,
+ size_t bytes_per_line, size_t reserved);
+
+__attribute__((noinline)) void Run(std::vector<int> &indices,
+ std::vector<double> &values) {
+ const auto num_entries = indices.size();
+ std::vector<std::pair<int, double>> entries;
+ entries.reserve(num_entries);
+ for (int i = 0; i < num_entries; ++i) {
+ entries.emplace_back(indices[i], values[i]);
----------------
alexander-shaposhnikov wrote:
done
https://github.com/llvm/llvm-project/pull/100906
More information about the llvm-commits
mailing list