Skip to content

Commit d6a261a

Browse files
stephan-yichao-zhaomemfrob
authored andcommitted
[dfsan] extend a test case to measure origin memory usage
This is to support D101204. Reviewed By: gbalats Differential Revision: https://reviews.llvm.org/D101877
1 parent c2282d0 commit d6a261a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

compiler-rt/test/dfsan/release_shadow_space.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// DFSAN_OPTIONS=no_huge_pages_for_shadow=false RUN: %clang_dfsan %s -o %t && setarch `uname -m` -R %run %t
22
// DFSAN_OPTIONS=no_huge_pages_for_shadow=true RUN: %clang_dfsan %s -o %t && setarch `uname -m` -R %run %t
3+
// DFSAN_OPTIONS=no_huge_pages_for_shadow=false RUN: %clang_dfsan %s -DORIGIN_TRACKING -mllvm -dfsan-fast-16-labels -mllvm -dfsan-track-origins=1 -o %t && setarch `uname -m` -R %run %t
4+
// DFSAN_OPTIONS=no_huge_pages_for_shadow=true RUN: %clang_dfsan %s -DORIGIN_TRACKING -mllvm -dfsan-fast-16-labels -mllvm -dfsan-track-origins=1 -o %t && setarch `uname -m` -R %run %t
35
//
46
// REQUIRES: x86_64-target-arch
57

@@ -72,9 +74,16 @@ int main(int argc, char **argv) {
7274

7375
const size_t mmap_cost_kb = map_size >> 10;
7476
const size_t mmap_shadow_cost_kb = sizeof(dfsan_label) * mmap_cost_kb;
77+
#ifdef ORIGIN_TRACKING
78+
const size_t mmap_origin_cost_kb = mmap_cost_kb;
79+
#else
80+
const size_t mmap_origin_cost_kb = 0;
81+
#endif
7582
assert(after_mmap >= before + mmap_cost_kb);
76-
assert(after_mmap_and_set_label >= after_mmap + mmap_shadow_cost_kb);
77-
assert(after_mmap_and_set_label2 >= before + mmap_cost_kb + mmap_shadow_cost_kb);
83+
assert(after_mmap_and_set_label >=
84+
after_mmap + mmap_shadow_cost_kb + mmap_origin_cost_kb);
85+
assert(after_mmap_and_set_label2 >=
86+
before + mmap_cost_kb + mmap_shadow_cost_kb + mmap_origin_cost_kb);
7887

7988
// RSS may not change memory amount after munmap to the same level as the
8089
// start of the program. The assert checks the memory up to a delta.

0 commit comments

Comments
 (0)