[compiler-rt] r330724 - [sanitizer] More dead code removal

Kostya Kortchinsky via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 24 07:58:11 PDT 2018


Author: cryptoad
Date: Tue Apr 24 07:58:10 2018
New Revision: 330724

URL: http://llvm.org/viewvc/llvm-project?rev=330724&view=rev
Log:
[sanitizer] More dead code removal

Summary:
The following functions are only used in tests: `SetEnv`,
`SanitizerSetThreadName`, `SanitizerGetThreadName`. I don't think they are
going to be used in the future, and I propose to get rid of them, and associated
tests and include.

Reviewers: alekseyshl, eugenis, vitalybuka

Reviewed By: vitalybuka

Subscribers: dvyukov, vitalybuka, kubamracek, delcypher, llvm-commits, #sanitizers

Differential Revision: https://reviews.llvm.org/D45838

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc
    compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=330724&r1=330723&r2=330724&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h Tue Apr 24 07:58:10 2018
@@ -308,13 +308,6 @@ void NORETURN ReportMmapFailureAndDie(up
                                       const char *mmap_type, error_t err,
                                       bool raw_report = false);
 
-// Set the name of the current thread to 'name', return true on succees.
-// The name may be truncated to a system-dependent limit.
-bool SanitizerSetThreadName(const char *name);
-// Get the name of the current thread (no more than max_len bytes),
-// return true on succees. name should have space for at least max_len+1 bytes.
-bool SanitizerGetThreadName(char *name, int max_len);
-
 // Specific tools may override behavior of "Die" and "CheckFailed" functions
 // to do tool-specific job.
 typedef void (*DieCallbackType)(void);

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc?rev=330724&r1=330723&r2=330724&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc Tue Apr 24 07:58:10 2018
@@ -55,10 +55,6 @@
 #include <thread.h>
 #endif
 
-#if SANITIZER_LINUX
-#include <sys/prctl.h>
-#endif
-
 #if SANITIZER_ANDROID
 #include <android/api-level.h>
 #if !defined(CPU_COUNT) && !defined(__aarch64__)
@@ -161,27 +157,6 @@ bool SetEnv(const char *name, const char
 }
 #endif
 
-bool SanitizerSetThreadName(const char *name) {
-#ifdef PR_SET_NAME
-  return 0 == prctl(PR_SET_NAME, (unsigned long)name, 0, 0, 0);  // NOLINT
-#else
-  return false;
-#endif
-}
-
-bool SanitizerGetThreadName(char *name, int max_len) {
-#ifdef PR_GET_NAME
-  char buff[17];
-  if (prctl(PR_GET_NAME, (unsigned long)buff, 0, 0, 0))  // NOLINT
-    return false;
-  internal_strncpy(name, buff, max_len);
-  name[max_len] = 0;
-  return true;
-#else
-  return false;
-#endif
-}
-
 #if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO &&               \
     !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS
 static uptr g_tls_size;

Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc?rev=330724&r1=330723&r2=330724&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc Tue Apr 24 07:58:10 2018
@@ -88,23 +88,6 @@ TEST(SanitizerCommon, MmapAlignedOrDieOn
   }
 }
 
-#if SANITIZER_LINUX
-TEST(SanitizerCommon, SanitizerSetThreadName) {
-  const char *names[] = {
-    "0123456789012",
-    "01234567890123",
-    "012345678901234",  // Larger names will be truncated on linux.
-  };
-
-  for (size_t i = 0; i < ARRAY_SIZE(names); i++) {
-    EXPECT_TRUE(SanitizerSetThreadName(names[i]));
-    char buff[100];
-    EXPECT_TRUE(SanitizerGetThreadName(buff, sizeof(buff) - 1));
-    EXPECT_EQ(0, internal_strcmp(buff, names[i]));
-  }
-}
-#endif
-
 TEST(SanitizerCommon, InternalMmapVector) {
   InternalMmapVector<uptr> vector(1);
   for (uptr i = 0; i < 100; i++) {




More information about the llvm-commits mailing list