From aacaebc6c22f81b13598aac69dee4b076f669e3e Mon Sep 17 00:00:00 2001 From: Snehasish Kumar Date: Wed, 10 Nov 2021 14:37:15 -0800 Subject: [PATCH] [memprof] Make the raw binary format the default. Set the default memprof serialization format as binary. 9 tests are updated to use print_text=true. Also fixed an issue with concatenation of default and test specified options (missing separator). Differential Revision: https://reviews.llvm.org/D113617 --- compiler-rt/lib/memprof/memprof_flags.inc | 2 +- .../test/memprof/TestCases/atexit_stats.cpp | 4 ++-- .../test/memprof/TestCases/dump_process_map.cpp | 4 ++-- .../test/memprof/TestCases/log_path_test.cpp | 16 ++++++++-------- .../memprof/TestCases/malloc-size-too-big.cpp | 6 +++--- .../test/memprof/TestCases/memprof_merge_mib.cpp | 2 +- .../memprof/TestCases/memprof_profile_dump.cpp | 4 ++-- compiler-rt/test/memprof/TestCases/stress_dtls.c | 6 +++--- .../memprof/TestCases/test_malloc_load_store.c | 4 ++-- .../test/memprof/TestCases/test_memintrin.cpp | 2 +- .../memprof/TestCases/test_new_load_store.cpp | 6 +++--- .../test/memprof/TestCases/test_terse.cpp | 4 ++-- .../TestCases/unaligned_loads_and_stores.cpp | 2 +- compiler-rt/test/memprof/lit.cfg.py | 1 + 14 files changed, 32 insertions(+), 31 deletions(-) diff --git a/compiler-rt/lib/memprof/memprof_flags.inc b/compiler-rt/lib/memprof/memprof_flags.inc index 6ff236f2119b..ee0760ddc302 100644 --- a/compiler-rt/lib/memprof/memprof_flags.inc +++ b/compiler-rt/lib/memprof/memprof_flags.inc @@ -35,7 +35,7 @@ MEMPROF_FLAG(bool, allocator_frees_and_returns_null_on_realloc_zero, true, "realloc(p, 0) is equivalent to free(p) by default (Same as the " "POSIX standard). If set to false, realloc(p, 0) will return a " "pointer to an allocated space which can not be used.") -MEMPROF_FLAG(bool, print_text, true, +MEMPROF_FLAG(bool, print_text, false, "If set, prints the heap profile in text format. Else use the raw binary serialization format.") MEMPROF_FLAG(bool, print_terse, false, "If set, prints memory profile in a terse format. Only applicable if print_text = true.") diff --git a/compiler-rt/test/memprof/TestCases/atexit_stats.cpp b/compiler-rt/test/memprof/TestCases/atexit_stats.cpp index e5b271b41c7f..4a5fac9b8d26 100644 --- a/compiler-rt/test/memprof/TestCases/atexit_stats.cpp +++ b/compiler-rt/test/memprof/TestCases/atexit_stats.cpp @@ -1,8 +1,8 @@ // Check atexit option. // RUN: %clangxx_memprof -O0 %s -o %t -// RUN: %env_memprof_opts=log_path=stderr:atexit=1 %run %t 2>&1 | FileCheck %s -// RUN: %env_memprof_opts=log_path=stderr:atexit=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOATEXIT +// RUN: %env_memprof_opts=print_text=true:log_path=stderr:atexit=1 %run %t 2>&1 | FileCheck %s +// RUN: %env_memprof_opts=print_text=true:log_path=stderr:atexit=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOATEXIT // CHECK: MemProfiler exit stats: // CHECK: Stats: {{[0-9]+}}M malloced ({{[0-9]+}}M for overhead) by {{[0-9]+}} calls diff --git a/compiler-rt/test/memprof/TestCases/dump_process_map.cpp b/compiler-rt/test/memprof/TestCases/dump_process_map.cpp index a6adb2f661f4..8c5ad1e63492 100644 --- a/compiler-rt/test/memprof/TestCases/dump_process_map.cpp +++ b/compiler-rt/test/memprof/TestCases/dump_process_map.cpp @@ -1,8 +1,8 @@ // Check print_module_map option. // RUN: %clangxx_memprof -O0 %s -o %t -// RUN: %env_memprof_opts=log_path=stderr:print_module_map=1 %run %t 2>&1 | FileCheck %s -// RUN: %env_memprof_opts=log_path=stderr:print_module_map=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOMAP +// RUN: %env_memprof_opts=print_text=true:log_path=stderr:print_module_map=1 %run %t 2>&1 | FileCheck %s +// RUN: %env_memprof_opts=print_text=true:log_path=stderr:print_module_map=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOMAP // CHECK: Process memory map follows: // CHECK: dump_process_map.cpp.tmp diff --git a/compiler-rt/test/memprof/TestCases/log_path_test.cpp b/compiler-rt/test/memprof/TestCases/log_path_test.cpp index 8af937389833..825a6e35d470 100644 --- a/compiler-rt/test/memprof/TestCases/log_path_test.cpp +++ b/compiler-rt/test/memprof/TestCases/log_path_test.cpp @@ -3,19 +3,19 @@ // // RUN: %clangxx_memprof %s -o %t -// stderr log_path -// RUN: %env_memprof_opts=log_path=stderr %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-GOOD --dump-input=always +// stderr print_text=true:log_path +// RUN: %env_memprof_opts=print_text=true:log_path=stderr %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-GOOD --dump-input=always -// Good log_path. +// Good print_text=true:log_path. // RUN: rm -f %t.log.* -// RUN: %env_memprof_opts=log_path=%t.log %run %t +// RUN: %env_memprof_opts=print_text=true:log_path=%t.log %run %t // RUN: FileCheck %s --check-prefix=CHECK-GOOD --dump-input=always < %t.log.* -// Invalid log_path. -// RUN: %env_memprof_opts=log_path=/dev/null/INVALID not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-INVALID --dump-input=always +// Invalid print_text=true:log_path. +// RUN: %env_memprof_opts=print_text=true:log_path=/dev/null/INVALID not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-INVALID --dump-input=always -// Too long log_path. -// RUN: %env_memprof_opts=log_path=`for((i=0;i<10000;i++)); do echo -n $i; done` \ +// Too long print_text=true:log_path. +// RUN: %env_memprof_opts=print_text=true:log_path=`for((i=0;i<10000;i++)); do echo -n $i; done` \ // RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-LONG --dump-input=always // Specifying the log name via the __memprof_profile_filename variable. diff --git a/compiler-rt/test/memprof/TestCases/malloc-size-too-big.cpp b/compiler-rt/test/memprof/TestCases/malloc-size-too-big.cpp index 1bcde5aecc4c..4eb9e8e1fba5 100644 --- a/compiler-rt/test/memprof/TestCases/malloc-size-too-big.cpp +++ b/compiler-rt/test/memprof/TestCases/malloc-size-too-big.cpp @@ -1,8 +1,8 @@ // RUN: %clangxx_memprof -O0 %s -o %t -// RUN: %env_memprof_opts=log_path=stderr:allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-SUMMARY -// RUN: %env_memprof_opts=log_path=stderr:allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NULL +// RUN: %env_memprof_opts=print_text=true:log_path=stderr:allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-SUMMARY +// RUN: %env_memprof_opts=print_text=true:log_path=stderr:allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NULL // Test print_summary -// RUN: %env_memprof_opts=log_path=stderr:allocator_may_return_null=0:print_summary=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOSUMMARY +// RUN: %env_memprof_opts=print_text=true:log_path=stderr:allocator_may_return_null=0:print_summary=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOSUMMARY #include #include diff --git a/compiler-rt/test/memprof/TestCases/memprof_merge_mib.cpp b/compiler-rt/test/memprof/TestCases/memprof_merge_mib.cpp index 793c2aa2c977..ee7f1ad26628 100644 --- a/compiler-rt/test/memprof/TestCases/memprof_merge_mib.cpp +++ b/compiler-rt/test/memprof/TestCases/memprof_merge_mib.cpp @@ -1,6 +1,6 @@ // RUN: %clangxx_memprof %s -o %t -// RUN: %env_memprof_opts=log_path=stdout %run %t | FileCheck %s +// RUN: %env_memprof_opts=print_text=true:log_path=stdout %run %t | FileCheck %s #include #include diff --git a/compiler-rt/test/memprof/TestCases/memprof_profile_dump.cpp b/compiler-rt/test/memprof/TestCases/memprof_profile_dump.cpp index 18399d29f44e..b843f904d867 100644 --- a/compiler-rt/test/memprof/TestCases/memprof_profile_dump.cpp +++ b/compiler-rt/test/memprof/TestCases/memprof_profile_dump.cpp @@ -1,7 +1,7 @@ // RUN: %clangxx_memprof %s -o %t -// RUN: %env_memprof_opts=log_path=stdout %run %t | FileCheck --check-prefix=CHECK-TEXT %s -// RUN: %env_memprof_opts=log_path=stdout,print_text=false %run %t > %t.memprofraw +// RUN: %env_memprof_opts=print_text=true:log_path=stdout %run %t | FileCheck --check-prefix=CHECK-TEXT %s +// RUN: %env_memprof_opts=print_text=true:log_path=stdout,print_text=false %run %t > %t.memprofraw // RUN: od -c -N 8 %t.memprofraw | FileCheck --check-prefix=CHECK-RAW %s #include diff --git a/compiler-rt/test/memprof/TestCases/stress_dtls.c b/compiler-rt/test/memprof/TestCases/stress_dtls.c index f730ccad5043..8a0d671fb241 100644 --- a/compiler-rt/test/memprof/TestCases/stress_dtls.c +++ b/compiler-rt/test/memprof/TestCases/stress_dtls.c @@ -7,9 +7,9 @@ // RUN: %clang_memprof %s -ldl -pthread -o %t // RUN: %run %t 0 3 // RUN: %run %t 2 3 -// RUN: %env_memprof_opts=log_path=stderr:verbosity=2 %run %t 10 2 2>&1 | FileCheck %s -// RUN: %env_memprof_opts=log_path=stderr:verbosity=2:intercept_tls_get_addr=1 %run %t 10 2 2>&1 | FileCheck %s -// RUN: %env_memprof_opts=log_path=stderr:verbosity=2:intercept_tls_get_addr=0 %run %t 10 2 2>&1 | FileCheck %s --check-prefix=CHECK0 +// RUN: %env_memprof_opts=print_text=true:log_path=stderr:verbosity=2 %run %t 10 2 2>&1 | FileCheck %s +// RUN: %env_memprof_opts=print_text=true:log_path=stderr:verbosity=2:intercept_tls_get_addr=1 %run %t 10 2 2>&1 | FileCheck %s +// RUN: %env_memprof_opts=print_text=true:log_path=stderr:verbosity=2:intercept_tls_get_addr=0 %run %t 10 2 2>&1 | FileCheck %s --check-prefix=CHECK0 // CHECK: ==__tls_get_addr: // CHECK: Creating thread 0 // CHECK: ==__tls_get_addr: diff --git a/compiler-rt/test/memprof/TestCases/test_malloc_load_store.c b/compiler-rt/test/memprof/TestCases/test_malloc_load_store.c index 7c44e5a94dbe..0a3e4a3c2959 100644 --- a/compiler-rt/test/memprof/TestCases/test_malloc_load_store.c +++ b/compiler-rt/test/memprof/TestCases/test_malloc_load_store.c @@ -3,10 +3,10 @@ // before exit. // RUN: %clang_memprof -O0 %s -o %t -// RUN: %env_memprof_opts=log_path=stderr %run %t 2>&1 | FileCheck %s +// RUN: %env_memprof_opts=print_text=true:log_path=stderr %run %t 2>&1 | FileCheck %s // RUN: %clang_memprof -DFREE -O0 %s -o %t -// RUN: %env_memprof_opts=log_path=stderr %run %t 2>&1 | FileCheck %s +// RUN: %env_memprof_opts=print_text=true:log_path=stderr %run %t 2>&1 | FileCheck %s // This is actually: // Memory allocation stack id = STACKID diff --git a/compiler-rt/test/memprof/TestCases/test_memintrin.cpp b/compiler-rt/test/memprof/TestCases/test_memintrin.cpp index bc3f66fbc5b6..062290c8eae3 100644 --- a/compiler-rt/test/memprof/TestCases/test_memintrin.cpp +++ b/compiler-rt/test/memprof/TestCases/test_memintrin.cpp @@ -1,6 +1,6 @@ // Check profile with calls to memory intrinsics. -// RUN: %clangxx_memprof -O0 %s -o %t && %env_memprof_opts=log_path=stderr %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_memprof -O0 %s -o %t && %env_memprof_opts=print_text=true:log_path=stderr %run %t 2>&1 | FileCheck %s // This is actually: // Memory allocation stack id = STACKIDP diff --git a/compiler-rt/test/memprof/TestCases/test_new_load_store.cpp b/compiler-rt/test/memprof/TestCases/test_new_load_store.cpp index c9f97b280e3b..9c080b76b88f 100644 --- a/compiler-rt/test/memprof/TestCases/test_new_load_store.cpp +++ b/compiler-rt/test/memprof/TestCases/test_new_load_store.cpp @@ -3,14 +3,14 @@ // before exit. // RUN: %clangxx_memprof -O0 %s -o %t -// RUN: %env_memprof_opts=log_path=stderr %run %t 2>&1 | FileCheck %s +// RUN: %env_memprof_opts=print_text=true:log_path=stderr %run %t 2>&1 | FileCheck %s // RUN: %clangxx_memprof -DFREE -O0 %s -o %t -// RUN: %env_memprof_opts=log_path=stderr %run %t 2>&1 | FileCheck %s +// RUN: %env_memprof_opts=print_text=true:log_path=stderr %run %t 2>&1 | FileCheck %s // Try again with callbacks instead of inline sequences // RUN: %clangxx_memprof -mllvm -memprof-use-callbacks -O0 %s -o %t -// RUN: %env_memprof_opts=log_path=stderr %run %t 2>&1 | FileCheck %s +// RUN: %env_memprof_opts=print_text=true:log_path=stderr %run %t 2>&1 | FileCheck %s // This is actually: // Memory allocation stack id = STACKID diff --git a/compiler-rt/test/memprof/TestCases/test_terse.cpp b/compiler-rt/test/memprof/TestCases/test_terse.cpp index 04763008016e..b121e993b7cb 100644 --- a/compiler-rt/test/memprof/TestCases/test_terse.cpp +++ b/compiler-rt/test/memprof/TestCases/test_terse.cpp @@ -3,10 +3,10 @@ // deallocated before exit. // RUN: %clangxx_memprof -O0 %s -o %t -// RUN: %env_memprof_opts=log_path=stderr:print_terse=1 %run %t 2>&1 | FileCheck %s +// RUN: %env_memprof_opts=print_text=true:log_path=stderr:print_terse=1 %run %t 2>&1 | FileCheck %s // RUN: %clangxx_memprof -DFREE -O0 %s -o %t -// RUN: %env_memprof_opts=log_path=stderr:print_terse=1 %run %t 2>&1 | FileCheck %s +// RUN: %env_memprof_opts=print_text=true:log_path=stderr:print_terse=1 %run %t 2>&1 | FileCheck %s // CHECK: MIB:[[STACKID:[0-9]+]]/1/40.00/40/40/20.00/20/20/[[AVELIFETIME:[0-9]+]].00/[[AVELIFETIME]]/[[AVELIFETIME]]/{{[01]}}/0/0/0 // CHECK: Stack for id [[STACKID]]: diff --git a/compiler-rt/test/memprof/TestCases/unaligned_loads_and_stores.cpp b/compiler-rt/test/memprof/TestCases/unaligned_loads_and_stores.cpp index 58aecdf61e59..8d6fe6b2c5b9 100644 --- a/compiler-rt/test/memprof/TestCases/unaligned_loads_and_stores.cpp +++ b/compiler-rt/test/memprof/TestCases/unaligned_loads_and_stores.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx_memprof -O0 %s -o %t && %env_memprof_opts=log_path=stderr %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_memprof -O0 %s -o %t && %env_memprof_opts=print_text=true:log_path=stderr %run %t 2>&1 | FileCheck %s // This is actually: // Memory allocation stack id = STACKID diff --git a/compiler-rt/test/memprof/lit.cfg.py b/compiler-rt/test/memprof/lit.cfg.py index a247d42d792b..e472101b1f16 100644 --- a/compiler-rt/test/memprof/lit.cfg.py +++ b/compiler-rt/test/memprof/lit.cfg.py @@ -33,6 +33,7 @@ default_memprof_opts = list(config.default_sanitizer_opts) default_memprof_opts_str = ':'.join(default_memprof_opts) if default_memprof_opts_str: config.environment['MEMPROF_OPTIONS'] = default_memprof_opts_str + default_memprof_opts_str += ':' config.substitutions.append(('%env_memprof_opts=', 'env MEMPROF_OPTIONS=' + default_memprof_opts_str))