1// Test that tagging of freed large region is 0, which is better for RSS usage.
2// RUN: %clang_hwasan -mllvm -hwasan-globals=0 -mllvm -hwasan-instrument-stack=0 %s -o %t && %run %t 2>&1
3
4#include <assert.h>
5#include <stdlib.h>
6
7#include <sanitizer/hwasan_interface.h>
8
9const int kSize = 10000000;
10
11void *p;
12int main() {
13 for (int i = 0; i < 256; ++i) {
14 p = malloc(size: kSize);
15 assert(-1 == __hwasan_test_shadow(p, kSize));
16
17 free(ptr: p);
18 assert(-1 == __hwasan_test_shadow(__hwasan_tag_pointer(p, 0), kSize));
19 }
20 return 0;
21}
22

source code of compiler-rt/test/hwasan/TestCases/secondary-tag-zero.c