[llvm] 057cabd - Remove function name from sanitize-memory-track-origins binary.

Kevin Athey via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 10 15:45:44 PDT 2022


Author: Kevin Athey
Date: 2022-08-10T15:45:40-07:00
New Revision: 057cabd997aeaef136e1e14f2ee645bd5bb197dd

URL: https://github.com/llvm/llvm-project/commit/057cabd997aeaef136e1e14f2ee645bd5bb197dd
DIFF: https://github.com/llvm/llvm-project/commit/057cabd997aeaef136e1e14f2ee645bd5bb197dd.diff

LOG: 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

Added: 
    

Modified: 
    compiler-rt/lib/msan/msan_report.cpp
    compiler-rt/test/msan/chained_origin.cpp
    compiler-rt/test/msan/chained_origin_empty_stack.cpp
    compiler-rt/test/msan/chained_origin_memcpy.cpp
    compiler-rt/test/msan/chained_origin_memmove.cpp
    compiler-rt/test/msan/msan_print_shadow.cpp
    compiler-rt/test/msan/report-demangling.cpp
    compiler-rt/test/msan/select_origin.cpp
    compiler-rt/test/msan/stack-origin.cpp
    compiler-rt/test/msan/stack-origin2.cpp
    compiler-rt/test/msan/unaligned_read_origin.cpp
    compiler-rt/test/msan/vararg.cpp
    llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/msan/msan_report.cpp b/compiler-rt/lib/msan/msan_report.cpp
index ff3e38c7db9ed..5c60f3297fcf1 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 3889edf7fb1aa..9fe73edb255cc 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 f1ed66b75e42c..23d463358f96d 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 <stdio.h>

diff  --git a/compiler-rt/test/msan/chained_origin_memcpy.cpp b/compiler-rt/test/msan/chained_origin_memcpy.cpp
index c5c526e653afc..4d4ae7fc07393 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 580e28c32f68f..1862ec81fef87 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 1a72f5dd0e6a7..0272544d2e12d 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 e77e4b08ac004..9799695ce95d5 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 e832c02e99ced..81e7af819b288 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 8bc485af750a0..53ac6052b0f62 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 14b899bb679ba..f47a393b0c845 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 bdccaf9104c53..d0cfb2f9b8e77 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 e1a7b12661655..e01c92a830bd9 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 8f8b1f5d4ef15..22085e01799c6 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -3875,7 +3875,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
     // 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());
   }


        


More information about the llvm-commits mailing list