-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sanitizer] Add compress_stack_depot flag
Depends on D114494. Reviewed By: morehouse Differential Revision: https://reviews.llvm.org/D114495
- Loading branch information
1 parent
d8f9eaa
commit bf18253
Showing
3 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
compiler-rt/test/sanitizer_common/TestCases/compress_stack_depot.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// RUN: %clangxx %s -fsanitize-memory-track-origins=1 -o %t | ||
// RUN: %env_tool_opts="compress_stack_depot=0:malloc_context_size=128:verbosity=1" %run %t 2>&1 | FileCheck %s --implicit-check-not="StackDepot released" | ||
// RUN: %env_tool_opts="compress_stack_depot=1:malloc_context_size=128:verbosity=1" %run %t 2>&1 | FileCheck %s --check-prefixes=COMPRESS | ||
|
||
// Ubsan does not store stacks. | ||
// UNSUPPORTED: ubsan | ||
|
||
#include <memory> | ||
|
||
__attribute__((noinline)) void a(unsigned v); | ||
__attribute__((noinline)) void b(unsigned v); | ||
|
||
std::unique_ptr<int[]> p; | ||
|
||
__attribute__((noinline)) void a(unsigned v) { | ||
int x; | ||
v >>= 1; | ||
if (!v) { | ||
p.reset(new int[100]); | ||
p[1] = x; | ||
return; | ||
} | ||
if (v & 1) | ||
b(v); | ||
else | ||
a(v); | ||
} | ||
|
||
__attribute__((noinline)) void b(unsigned v) { return a(v); } | ||
|
||
int main(int argc, char *argv[]) { | ||
for (unsigned i = 0; i < 100000; ++i) | ||
a(i + (i << 16)); | ||
return 0; | ||
} | ||
|
||
// COMPRESS: StackDepot released {{[0-9]+}} |