Skip to content

Commit

Permalink
Remove function name from sanitize-memory-track-origins binary.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kda committed Aug 10, 2022
1 parent d5fcf8a commit 057cabd
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 22 deletions.
10 changes: 2 additions & 8 deletions compiler-rt/lib/msan/msan_report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/msan/chained_origin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/msan/chained_origin_empty_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/test/msan/chained_origin_memcpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
4 changes: 2 additions & 2 deletions compiler-rt/test/msan/chained_origin_memmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
2 changes: 1 addition & 1 deletion compiler-rt/test/msan/msan_print_shadow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {{.*}}):
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/msan/report-demangling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
}
2 changes: 1 addition & 1 deletion compiler-rt/test/msan/select_origin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion compiler-rt/test/msan/stack-origin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/msan/stack-origin2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/msan/unaligned_read_origin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
}
2 changes: 1 addition & 1 deletion compiler-rt/test/msan/vararg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down

0 comments on commit 057cabd

Please sign in to comment.