Skip to content

Commit 057cabd

Browse files
committed
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
1 parent d5fcf8a commit 057cabd

13 files changed

+16
-22
lines changed

compiler-rt/lib/msan/msan_report.cpp

+2-8
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,11 @@ class Decorator: public __sanitizer::SanitizerCommonDecorator {
3636

3737
static void DescribeStackOrigin(const char *so, uptr pc) {
3838
Decorator d;
39-
char *s = internal_strdup(so);
40-
char *sep = internal_strchr(s, '@');
41-
CHECK(sep);
42-
*sep = '\0';
4339
Printf("%s", d.Origin());
4440
Printf(
4541
" %sUninitialized value was created by an allocation of '%s%s%s'"
46-
" in the stack frame of function '%s%s%s'%s\n",
47-
d.Origin(), d.Name(), s, d.Origin(), d.Name(), sep + 1, d.Origin(),
48-
d.Default());
49-
InternalFree(s);
42+
" in the stack frame%s\n",
43+
d.Origin(), d.Name(), so, d.Origin(), d.Default());
5044

5145
if (pc) {
5246
// For some reason function address in LLVM IR is 1 less then the address

compiler-rt/test/msan/chained_origin.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int main(int argc, char *argv[]) {
6060
// CHECK-FULL-STACK: {{#2 .* in main.*chained_origin.cpp:}}[[@LINE-16]]
6161
// CHECK-SHORT-STACK: {{#0 .* in fn_g.*chained_origin.cpp:}}[[@LINE-37]]
6262

63-
// CHECK-STACK: Uninitialized value was created by an allocation of 'z' in the stack frame of function 'main'
63+
// CHECK-STACK: Uninitialized value was created by an allocation of 'z' in the stack frame
6464
// CHECK-STACK: {{#0 .* in main.*chained_origin.cpp:}}[[@LINE-22]]
6565

6666
// CHECK-HEAP: Uninitialized value was created by a heap allocation

compiler-rt/test/msan/chained_origin_empty_stack.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// CHECK: #0 {{.*}} in fn_g
1111
// CHECK-NOT: #1
1212

13-
// CHECK: Uninitialized value was created by an allocation of 'z' in the stack frame of function 'main'
13+
// CHECK: Uninitialized value was created by an allocation of 'z' in the stack frame
1414
// CHECK: #0 {{.*}} in main
1515

1616
#include <stdio.h>

compiler-rt/test/msan/chained_origin_memcpy.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ int main(int argc, char *argv[]) {
5757
// CHECK-FULL-STACK: {{#1 .* in fn_f.*chained_origin_memcpy.cpp:}}[[@LINE-25]]
5858
// CHECK-SHORT-STACK: {{#0 .* in fn_g.*chained_origin_memcpy.cpp:}}[[@LINE-31]]
5959

60-
// CHECK-Z1: Uninitialized value was created by an allocation of 'z1' in the stack frame of function 'main'
61-
// CHECK-Z2: Uninitialized value was created by an allocation of 'z2' in the stack frame of function 'main'
60+
// CHECK-Z1: Uninitialized value was created by an allocation of 'z1' in the stack frame
61+
// CHECK-Z2: Uninitialized value was created by an allocation of 'z2' in the stack frame
6262
// CHECK-Z1: {{#0 .* in main.*chained_origin_memcpy.cpp:}}[[@LINE-21]]
6363
// CHECK-Z2: {{#0 .* in main.*chained_origin_memcpy.cpp:}}[[@LINE-21]]

compiler-rt/test/msan/chained_origin_memmove.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int main(int argc, char *argv[]) {
5252
// CHECK-FULL-STACK: {{#1 .* in fn_f.*chained_origin_memmove.cpp:}}[[@LINE-24]]
5353
// CHECK-SHORT-STACK: {{#0 .* in fn_g.*chained_origin_memmove.cpp:}}[[@LINE-29]]
5454

55-
// CHECK-Z1: Uninitialized value was created by an allocation of 'z1' in the stack frame of function 'main'
56-
// CHECK-Z2: Uninitialized value was created by an allocation of 'z2' in the stack frame of function 'main'
55+
// CHECK-Z1: Uninitialized value was created by an allocation of 'z1' in the stack frame
56+
// CHECK-Z2: Uninitialized value was created by an allocation of 'z2' in the stack frame
5757
// CHECK-Z1: {{#0 .* in main.*chained_origin_memmove.cpp:}}[[@LINE-21]]
5858
// CHECK-Z2: {{#0 .* in main.*chained_origin_memmove.cpp:}}[[@LINE-21]]

compiler-rt/test/msan/msan_print_shadow.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ int main(void) {
106106
// CHECK-ORIGINS: Origin C (origin_id {{.*}}):
107107
// CHECK-ORIGINS-2: Uninitialized value was stored to memory at
108108
// CHECK-ORIGINS-2: #0 {{.*}} in main{{.*}}msan_print_shadow.cpp:48
109-
// CHECK-ORIGINS: Uninitialized value was created by an allocation of 'x' in the stack frame of function 'main'
109+
// CHECK-ORIGINS: Uninitialized value was created by an allocation of 'x' in the stack frame
110110
// CHECK-ORIGINS: #0 {{.*}} in main{{.*}}msan_print_shadow.cpp:13
111111

112112
// CHECK-ORIGINS: Origin D (origin_id {{.*}}):

compiler-rt/test/msan/report-demangling.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ int f() {
1414
int main(int argc, char **argv) {
1515
return f();
1616
// CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
17-
// CHECK: Uninitialized value was created by an allocation of 'x' in the stack frame of function '_Z1fv'
17+
// CHECK: Uninitialized value was created by an allocation of 'x' in the stack frame
1818
// CHECK: #0 {{.*}} in f{{.*}} {{.*}}report-demangling.cpp:[[@LINE-9]]
1919
}

compiler-rt/test/msan/select_origin.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ int main(void) {
1717
int *volatile px = &x;
1818
int y = 43;
1919
int *p = max_by_ptr(px, &y);
20-
// CHECK: Uninitialized value was created by an allocation of 'x' in the stack frame of function 'main'
20+
// CHECK: Uninitialized value was created by an allocation of 'x' in the stack frame
2121
return *p;
2222
}

compiler-rt/test/msan/stack-origin.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ int main(int argc, char **argv) {
2424
// CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
2525
// CHECK: {{#0 0x.* in main .*stack-origin.cpp:}}[[@LINE-2]]
2626

27-
// CHECK-ORIGINS: Uninitialized value was created by an allocation of 'x' in the stack frame of function 'main'
27+
// CHECK-ORIGINS: Uninitialized value was created by an allocation of 'x' in the stack frame
2828
// CHECK-ORIGINS: {{#0 0x.* in main .*stack-origin.cpp:}}[[@LINE-7]]
2929

3030
// CHECK: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*stack-origin.cpp:.* main}}

compiler-rt/test/msan/stack-origin2.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ int main(int argc, char **argv) {
3434
// CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
3535
// CHECK: {{#0 0x.* in main .*stack-origin2.cpp:}}[[@LINE-2]]
3636

37-
// CHECK-ORIGINS: Uninitialized value was created by an allocation of 'x' in the stack frame of function 'f'
37+
// CHECK-ORIGINS: Uninitialized value was created by an allocation of 'x' in the stack frame
3838
// CHECK-ORIGINS: {{#0 0x.* in f .*stack-origin2.cpp:}}[[@LINE-11]]
3939

4040
// CHECK: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*stack-origin2.cpp:.* main}}

compiler-rt/test/msan/unaligned_read_origin.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ int main(int argc, char **argv) {
1111
return __sanitizer_unaligned_load32(p);
1212
// CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
1313
// CHECK: {{#0 0x.* in main .*unaligned_read_origin.cpp:}}[[@LINE-2]]
14-
// CHECK: Uninitialized value was created by an allocation of 'x' in the stack frame of function 'main'
14+
// CHECK: Uninitialized value was created by an allocation of 'x' in the stack frame
1515
// CHECK: {{#0 0x.* in main .*unaligned_read_origin.cpp:}}[[@LINE-6]]
1616
}

compiler-rt/test/msan/vararg.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ int main(int argc, char *argv[]) {
5757
}
5858

5959
// CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
60-
// CHECK-ORIGIN: Uninitialized value was created by an allocation of 'uninit' in the stack frame of function 'main'
60+
// CHECK-ORIGIN: Uninitialized value was created by an allocation of 'uninit' in the stack frame

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3875,7 +3875,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
38753875
// It will be printed by the run-time if stack-originated UMR is found.
38763876
// The first 4 bytes of the string are set to '----' and will be replaced
38773877
// by __msan_va_arg_overflow_size_tls at the first call.
3878-
StackDescription << "----" << I.getName() << "@" << F.getName();
3878+
StackDescription << "----" << I.getName();
38793879
return createPrivateNonConstGlobalForString(*F.getParent(),
38803880
StackDescription.str());
38813881
}

0 commit comments

Comments
 (0)