[msan] allow -fsanitize-coverage=N together with -fsanitize=memory, compiler-rt part

llvm-svn: 223314
This commit is contained in:
Kostya Serebryany 2014-12-03 23:29:14 +00:00
parent 543f3db572
commit 29a2236c7d
3 changed files with 34 additions and 0 deletions

View File

@ -372,6 +372,11 @@ void __msan_init() {
Symbolizer::GetOrInit()->AddHooks(EnterSymbolizer, ExitSymbolizer);
if (common_flags()->coverage) {
__sanitizer_cov_init();
Atexit(__sanitizer_cov_dump);
}
MsanTSDInit(MsanTSDDtor);
MsanThread *main_thread = MsanThread::Create(0, 0);

View File

@ -133,6 +133,8 @@ bool InitShadow(bool map_shadow, bool init_origins) {
}
void MsanDie() {
if (common_flags()->coverage)
__sanitizer_cov_dump();
if (death_callback)
death_callback();
_exit(flags()->exit_code);

View File

@ -0,0 +1,27 @@
// Test various levels of coverage
//
// RUN: %clangxx_msan -DINIT_VAR=1 -O1 -fsanitize-coverage=1 %s -o %t
// RUN: MSAN_OPTIONS=coverage=1:verbosity=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_NOWARN
// RUN: %clangxx_msan -O1 -fsanitize-coverage=1 %s -o %t
// RUN: MSAN_OPTIONS=coverage=1:verbosity=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_WARN
// RUN: %clangxx_msan -O1 -fsanitize-coverage=2 %s -o %t
// RUN: MSAN_OPTIONS=coverage=1:verbosity=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK2 --check-prefix=CHECK_WARN
// RUN: %clangxx_msan -O1 -fsanitize-coverage=3 %s -o %t
// RUN: MSAN_OPTIONS=coverage=1:verbosity=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3 --check-prefix=CHECK_WARN
//
volatile int sink;
int main(int argc, char **argv) {
int var;
#if INIT_VAR
var = 0;
#endif
if (argc == 0)
sink = 0;
return *(volatile int*)&var;
}
// CHECK_WARN: WARNING: MemorySanitizer: use-of-uninitialized-value
// CHECK_NOWARN-NOT: ERROR
// CHECK1: 1 PCs written
// CHECK2: 2 PCs written
// CHECK3: 3 PCs written