diff options
| author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2014-06-24 09:04:06 +0000 |
|---|---|---|
| committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2014-06-24 09:04:06 +0000 |
| commit | ad8065f01a900cd6663e10f8fd857a0aba934bf8 (patch) | |
| tree | 8fe0d1e52e64e25b62f012db05f9864334113c1e | |
| parent | cc91169fd7e683711528401ca3350b205721148e (diff) | |
| download | bcm5719-llvm-ad8065f01a900cd6663e10f8fd857a0aba934bf8.tar.gz bcm5719-llvm-ad8065f01a900cd6663e10f8fd857a0aba934bf8.zip | |
[msan] Print stats even on successful run with atexit=1.
llvm-svn: 211574
| -rw-r--r-- | compiler-rt/lib/msan/msan.cc | 2 | ||||
| -rw-r--r-- | compiler-rt/lib/msan/msan_flags.h | 1 | ||||
| -rw-r--r-- | compiler-rt/lib/msan/msan_linux.cc | 7 | ||||
| -rw-r--r-- | compiler-rt/test/msan/print_stats.cc | 6 |
4 files changed, 10 insertions, 6 deletions
diff --git a/compiler-rt/lib/msan/msan.cc b/compiler-rt/lib/msan/msan.cc index 4c58200f1e7..bd5545fb46d 100644 --- a/compiler-rt/lib/msan/msan.cc +++ b/compiler-rt/lib/msan/msan.cc @@ -144,6 +144,7 @@ static void ParseFlagsFromString(Flags *f, const char *str) { ParseFlag(str, &f->report_umrs, "report_umrs", ""); ParseFlag(str, &f->wrap_signals, "wrap_signals", ""); ParseFlag(str, &f->print_stats, "print_stats", ""); + ParseFlag(str, &f->atexit, "atexit", ""); // keep_going is an old name for halt_on_error, // and it has inverse meaning. @@ -173,6 +174,7 @@ static void InitializeFlags(Flags *f, const char *options) { f->report_umrs = true; f->wrap_signals = true; f->print_stats = false; + f->atexit = false; f->halt_on_error = !&__msan_keep_going; // Override from user-specified string. diff --git a/compiler-rt/lib/msan/msan_flags.h b/compiler-rt/lib/msan/msan_flags.h index 47ac7e435c6..e9ea32bda9f 100644 --- a/compiler-rt/lib/msan/msan_flags.h +++ b/compiler-rt/lib/msan/msan_flags.h @@ -29,6 +29,7 @@ struct Flags { bool wrap_signals; bool print_stats; bool halt_on_error; + bool atexit; }; Flags *flags(); diff --git a/compiler-rt/lib/msan/msan_linux.cc b/compiler-rt/lib/msan/msan_linux.cc index 72f7c594bb1..a8fbabb0154 100644 --- a/compiler-rt/lib/msan/msan_linux.cc +++ b/compiler-rt/lib/msan/msan_linux.cc @@ -90,12 +90,11 @@ void MsanDie() { } static void MsanAtExit(void) { + if (flags()->print_stats && (flags()->atexit || msan_report_count > 0)) + ReportStats(); if (msan_report_count > 0) { ReportAtExitStatistics(); - if (flags()->print_stats) - ReportStats(); - if (flags()->exit_code) - _exit(flags()->exit_code); + if (flags()->exit_code) _exit(flags()->exit_code); } } diff --git a/compiler-rt/test/msan/print_stats.cc b/compiler-rt/test/msan/print_stats.cc index bee364ba0d2..74943835b36 100644 --- a/compiler-rt/test/msan/print_stats.cc +++ b/compiler-rt/test/msan/print_stats.cc @@ -3,6 +3,8 @@ // RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-NOSTATS %s // RUN: MSAN_OPTIONS=print_stats=1 %run %t 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-NOSTATS %s +// RUN: MSAN_OPTIONS=print_stats=1,atexit=1 %run %t 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK --check-prefix=CHECK-STATS %s // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -m64 -g -DPOSITIVE=1 %s -o %t // RUN: not %run %t 2>&1 | \ @@ -30,8 +32,6 @@ int main(int argc, char **argv) { // CHECK: TEST -// CHECK-KEEPGOING: MemorySanitizer: 1 warnings reported. - // CHECK-STATS: Unique heap origins: // CHECK-STATS: Stack depot allocated bytes: // CHECK-STATS: Unique origin histories: @@ -41,3 +41,5 @@ int main(int argc, char **argv) { // CHECK-NOSTATS-NOT: Stack depot allocated bytes: // CHECK-NOSTATS-NOT: Unique origin histories: // CHECK-NOSTATS-NOT: History depot allocated bytes: + +// CHECK-KEEPGOING: MemorySanitizer: 1 warnings reported. |

