From 057cabd997aeaef136e1e14f2ee645bd5bb197dd Mon Sep 17 00:00:00 2001 From: Kevin Athey Date: Wed, 10 Aug 2022 11:18:32 -0700 Subject: [PATCH] Remove function name from sanitize-memory-track-origins binary. This work is being done to reduce the size of MSAN with track origins binary. Builds upon: https://reviews.llvm.org/D131205 Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D131415 --- compiler-rt/lib/msan/msan_report.cpp | 10 ++-------- compiler-rt/test/msan/chained_origin.cpp | 2 +- compiler-rt/test/msan/chained_origin_empty_stack.cpp | 2 +- compiler-rt/test/msan/chained_origin_memcpy.cpp | 4 ++-- compiler-rt/test/msan/chained_origin_memmove.cpp | 4 ++-- compiler-rt/test/msan/msan_print_shadow.cpp | 2 +- compiler-rt/test/msan/report-demangling.cpp | 2 +- compiler-rt/test/msan/select_origin.cpp | 2 +- compiler-rt/test/msan/stack-origin.cpp | 2 +- compiler-rt/test/msan/stack-origin2.cpp | 2 +- compiler-rt/test/msan/unaligned_read_origin.cpp | 2 +- compiler-rt/test/msan/vararg.cpp | 2 +- .../lib/Transforms/Instrumentation/MemorySanitizer.cpp | 2 +- 13 files changed, 16 insertions(+), 22 deletions(-) diff --git a/compiler-rt/lib/msan/msan_report.cpp b/compiler-rt/lib/msan/msan_report.cpp index ff3e38c7db9ed8..5c60f3297fcf10 100644 --- a/compiler-rt/lib/msan/msan_report.cpp +++ b/compiler-rt/lib/msan/msan_report.cpp @@ -36,17 +36,11 @@ class Decorator: public __sanitizer::SanitizerCommonDecorator { static void DescribeStackOrigin(const char *so, uptr pc) { Decorator d; - char *s = internal_strdup(so); - char *sep = internal_strchr(s, '@'); - CHECK(sep); - *sep = '\0'; Printf("%s", d.Origin()); Printf( " %sUninitialized value was created by an allocation of '%s%s%s'" - " in the stack frame of function '%s%s%s'%s\n", - d.Origin(), d.Name(), s, d.Origin(), d.Name(), sep + 1, d.Origin(), - d.Default()); - InternalFree(s); + " in the stack frame%s\n", + d.Origin(), d.Name(), so, d.Origin(), d.Default()); if (pc) { // For some reason function address in LLVM IR is 1 less then the address diff --git a/compiler-rt/test/msan/chained_origin.cpp b/compiler-rt/test/msan/chained_origin.cpp index 3889edf7fb1aad..9fe73edb255cc3 100644 --- a/compiler-rt/test/msan/chained_origin.cpp +++ b/compiler-rt/test/msan/chained_origin.cpp @@ -60,7 +60,7 @@ int main(int argc, char *argv[]) { // CHECK-FULL-STACK: {{#2 .* in main.*chained_origin.cpp:}}[[@LINE-16]] // CHECK-SHORT-STACK: {{#0 .* in fn_g.*chained_origin.cpp:}}[[@LINE-37]] -// CHECK-STACK: Uninitialized value was created by an allocation of 'z' in the stack frame of function 'main' +// CHECK-STACK: Uninitialized value was created by an allocation of 'z' in the stack frame // CHECK-STACK: {{#0 .* in main.*chained_origin.cpp:}}[[@LINE-22]] // CHECK-HEAP: Uninitialized value was created by a heap allocation diff --git a/compiler-rt/test/msan/chained_origin_empty_stack.cpp b/compiler-rt/test/msan/chained_origin_empty_stack.cpp index f1ed66b75e42ca..23d463358f96dc 100644 --- a/compiler-rt/test/msan/chained_origin_empty_stack.cpp +++ b/compiler-rt/test/msan/chained_origin_empty_stack.cpp @@ -10,7 +10,7 @@ // CHECK: #0 {{.*}} in fn_g // CHECK-NOT: #1 -// CHECK: Uninitialized value was created by an allocation of 'z' in the stack frame of function 'main' +// CHECK: Uninitialized value was created by an allocation of 'z' in the stack frame // CHECK: #0 {{.*}} in main #include diff --git a/compiler-rt/test/msan/chained_origin_memcpy.cpp b/compiler-rt/test/msan/chained_origin_memcpy.cpp index c5c526e653afc0..4d4ae7fc073930 100644 --- a/compiler-rt/test/msan/chained_origin_memcpy.cpp +++ b/compiler-rt/test/msan/chained_origin_memcpy.cpp @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) { // CHECK-FULL-STACK: {{#1 .* in fn_f.*chained_origin_memcpy.cpp:}}[[@LINE-25]] // CHECK-SHORT-STACK: {{#0 .* in fn_g.*chained_origin_memcpy.cpp:}}[[@LINE-31]] -// CHECK-Z1: Uninitialized value was created by an allocation of 'z1' in the stack frame of function 'main' -// CHECK-Z2: Uninitialized value was created by an allocation of 'z2' in the stack frame of function 'main' +// CHECK-Z1: Uninitialized value was created by an allocation of 'z1' in the stack frame +// CHECK-Z2: Uninitialized value was created by an allocation of 'z2' in the stack frame // CHECK-Z1: {{#0 .* in main.*chained_origin_memcpy.cpp:}}[[@LINE-21]] // CHECK-Z2: {{#0 .* in main.*chained_origin_memcpy.cpp:}}[[@LINE-21]] diff --git a/compiler-rt/test/msan/chained_origin_memmove.cpp b/compiler-rt/test/msan/chained_origin_memmove.cpp index 580e28c32f68fd..1862ec81fef873 100644 --- a/compiler-rt/test/msan/chained_origin_memmove.cpp +++ b/compiler-rt/test/msan/chained_origin_memmove.cpp @@ -52,7 +52,7 @@ int main(int argc, char *argv[]) { // CHECK-FULL-STACK: {{#1 .* in fn_f.*chained_origin_memmove.cpp:}}[[@LINE-24]] // CHECK-SHORT-STACK: {{#0 .* in fn_g.*chained_origin_memmove.cpp:}}[[@LINE-29]] -// CHECK-Z1: Uninitialized value was created by an allocation of 'z1' in the stack frame of function 'main' -// CHECK-Z2: Uninitialized value was created by an allocation of 'z2' in the stack frame of function 'main' +// CHECK-Z1: Uninitialized value was created by an allocation of 'z1' in the stack frame +// CHECK-Z2: Uninitialized value was created by an allocation of 'z2' in the stack frame // CHECK-Z1: {{#0 .* in main.*chained_origin_memmove.cpp:}}[[@LINE-21]] // CHECK-Z2: {{#0 .* in main.*chained_origin_memmove.cpp:}}[[@LINE-21]] diff --git a/compiler-rt/test/msan/msan_print_shadow.cpp b/compiler-rt/test/msan/msan_print_shadow.cpp index 1a72f5dd0e6a78..0272544d2e12d3 100644 --- a/compiler-rt/test/msan/msan_print_shadow.cpp +++ b/compiler-rt/test/msan/msan_print_shadow.cpp @@ -106,7 +106,7 @@ int main(void) { // CHECK-ORIGINS: Origin C (origin_id {{.*}}): // CHECK-ORIGINS-2: Uninitialized value was stored to memory at // CHECK-ORIGINS-2: #0 {{.*}} in main{{.*}}msan_print_shadow.cpp:48 -// CHECK-ORIGINS: Uninitialized value was created by an allocation of 'x' in the stack frame of function 'main' +// CHECK-ORIGINS: Uninitialized value was created by an allocation of 'x' in the stack frame // CHECK-ORIGINS: #0 {{.*}} in main{{.*}}msan_print_shadow.cpp:13 // CHECK-ORIGINS: Origin D (origin_id {{.*}}): diff --git a/compiler-rt/test/msan/report-demangling.cpp b/compiler-rt/test/msan/report-demangling.cpp index e77e4b08ac004f..9799695ce95d59 100644 --- a/compiler-rt/test/msan/report-demangling.cpp +++ b/compiler-rt/test/msan/report-demangling.cpp @@ -14,6 +14,6 @@ int f() { int main(int argc, char **argv) { return f(); // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value - // CHECK: Uninitialized value was created by an allocation of 'x' in the stack frame of function '_Z1fv' + // CHECK: Uninitialized value was created by an allocation of 'x' in the stack frame // CHECK: #0 {{.*}} in f{{.*}} {{.*}}report-demangling.cpp:[[@LINE-9]] } diff --git a/compiler-rt/test/msan/select_origin.cpp b/compiler-rt/test/msan/select_origin.cpp index e832c02e99ced3..81e7af819b288a 100644 --- a/compiler-rt/test/msan/select_origin.cpp +++ b/compiler-rt/test/msan/select_origin.cpp @@ -17,6 +17,6 @@ int main(void) { int *volatile px = &x; int y = 43; int *p = max_by_ptr(px, &y); - // CHECK: Uninitialized value was created by an allocation of 'x' in the stack frame of function 'main' + // CHECK: Uninitialized value was created by an allocation of 'x' in the stack frame return *p; } diff --git a/compiler-rt/test/msan/stack-origin.cpp b/compiler-rt/test/msan/stack-origin.cpp index 8bc485af750a02..53ac6052b0f628 100644 --- a/compiler-rt/test/msan/stack-origin.cpp +++ b/compiler-rt/test/msan/stack-origin.cpp @@ -24,7 +24,7 @@ int main(int argc, char **argv) { // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value // CHECK: {{#0 0x.* in main .*stack-origin.cpp:}}[[@LINE-2]] - // CHECK-ORIGINS: Uninitialized value was created by an allocation of 'x' in the stack frame of function 'main' + // CHECK-ORIGINS: Uninitialized value was created by an allocation of 'x' in the stack frame // CHECK-ORIGINS: {{#0 0x.* in main .*stack-origin.cpp:}}[[@LINE-7]] // CHECK: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*stack-origin.cpp:.* main}} diff --git a/compiler-rt/test/msan/stack-origin2.cpp b/compiler-rt/test/msan/stack-origin2.cpp index 14b899bb679baa..f47a393b0c8455 100644 --- a/compiler-rt/test/msan/stack-origin2.cpp +++ b/compiler-rt/test/msan/stack-origin2.cpp @@ -34,7 +34,7 @@ int main(int argc, char **argv) { // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value // CHECK: {{#0 0x.* in main .*stack-origin2.cpp:}}[[@LINE-2]] - // CHECK-ORIGINS: Uninitialized value was created by an allocation of 'x' in the stack frame of function 'f' + // CHECK-ORIGINS: Uninitialized value was created by an allocation of 'x' in the stack frame // CHECK-ORIGINS: {{#0 0x.* in f .*stack-origin2.cpp:}}[[@LINE-11]] // CHECK: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*stack-origin2.cpp:.* main}} diff --git a/compiler-rt/test/msan/unaligned_read_origin.cpp b/compiler-rt/test/msan/unaligned_read_origin.cpp index bdccaf9104c530..d0cfb2f9b8e77c 100644 --- a/compiler-rt/test/msan/unaligned_read_origin.cpp +++ b/compiler-rt/test/msan/unaligned_read_origin.cpp @@ -11,6 +11,6 @@ int main(int argc, char **argv) { return __sanitizer_unaligned_load32(p); // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value // CHECK: {{#0 0x.* in main .*unaligned_read_origin.cpp:}}[[@LINE-2]] - // CHECK: Uninitialized value was created by an allocation of 'x' in the stack frame of function 'main' + // CHECK: Uninitialized value was created by an allocation of 'x' in the stack frame // CHECK: {{#0 0x.* in main .*unaligned_read_origin.cpp:}}[[@LINE-6]] } diff --git a/compiler-rt/test/msan/vararg.cpp b/compiler-rt/test/msan/vararg.cpp index e1a7b126616555..e01c92a830bd97 100644 --- a/compiler-rt/test/msan/vararg.cpp +++ b/compiler-rt/test/msan/vararg.cpp @@ -57,4 +57,4 @@ int main(int argc, char *argv[]) { } // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value -// CHECK-ORIGIN: Uninitialized value was created by an allocation of 'uninit' in the stack frame of function 'main' +// CHECK-ORIGIN: Uninitialized value was created by an allocation of 'uninit' in the stack frame diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp index 8f8b1f5d4ef155..22085e01799c67 100644 --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -3875,7 +3875,7 @@ struct MemorySanitizerVisitor : public InstVisitor { // It will be printed by the run-time if stack-originated UMR is found. // The first 4 bytes of the string are set to '----' and will be replaced // by __msan_va_arg_overflow_size_tls at the first call. - StackDescription << "----" << I.getName() << "@" << F.getName(); + StackDescription << "----" << I.getName(); return createPrivateNonConstGlobalForString(*F.getParent(), StackDescription.str()); }