Skip to content

Commit

Permalink
[sanitizer] Remove low-hanging-fruit dead code
Browse files Browse the repository at this point in the history
Summary:
Going through the dead code findings, the code removed in this CL appears to be
pretty straightforward to remove, and seems to be some leftover from previous
refactors.

Reviewers: alekseyshl, eugenis

Reviewed By: alekseyshl

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

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

llvm-svn: 330190
  • Loading branch information
Kostya Kortchinsky committed Apr 17, 2018
1 parent 31dff53 commit 54764ca
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,6 @@ void *InternalCalloc(uptr countr, uptr size,
void InternalFree(void *p, InternalAllocatorCache *cache = nullptr);
InternalAllocator *internal_allocator();

enum InternalAllocEnum {
INTERNAL_ALLOC
};

} // namespace __sanitizer

inline void *operator new(__sanitizer::operator_new_size_type size,
__sanitizer::InternalAllocEnum) {
return __sanitizer::InternalAlloc(size);
}

#endif // SANITIZER_ALLOCATOR_INTERNAL_H
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace __sanitizer {
// bypassing libc.
#if !SANITIZER_WINDOWS
#if SANITIZER_LINUX
bool ShouldLogAfterPrintf() { return false; }
void LogMessageOnPrintf(const char *str) {}
#endif
void WriteToSyslog(const char *buffer) {}
Expand Down
8 changes: 0 additions & 8 deletions compiler-rt/lib/sanitizer_common/sanitizer_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ namespace __sanitizer {

CommonFlags common_flags_dont_use;

struct FlagDescription {
const char *name;
const char *description;
FlagDescription *next;
};

IntrusiveList<FlagDescription> flag_descriptions;

void CommonFlags::SetDefaults() {
#define COMMON_FLAG(Type, Name, DefaultValue, Description) Name = DefaultValue;
#include "sanitizer_flags.inc"
Expand Down
25 changes: 0 additions & 25 deletions compiler-rt/lib/sanitizer_common/sanitizer_libc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,6 @@ void *internal_memmove(void *dest, const void *src, uptr n) {
return dest;
}

// Semi-fast bzero for 16-aligned data. Still far from peak performance.
void internal_bzero_aligned16(void *s, uptr n) {
struct ALIGNED(16) S16 { u64 a, b; };
CHECK_EQ((reinterpret_cast<uptr>(s) | n) & 15, 0);
for (S16 *p = reinterpret_cast<S16*>(s), *end = p + n / 16; p < end; p++) {
p->a = p->b = 0;
// Make sure this does not become memset.
SanitizerBreakOptimization(nullptr);
}
}

void *internal_memset(void* s, int c, uptr n) {
// The next line prevents Clang from making a call to memset() instead of the
// loop below.
Expand Down Expand Up @@ -112,14 +101,6 @@ char* internal_strdup(const char *s) {
return s2;
}

char* internal_strndup(const char *s, uptr n) {
uptr len = internal_strnlen(s, n);
char *s2 = (char*)InternalAlloc(len + 1);
internal_memcpy(s2, s, len);
s2[len] = 0;
return s2;
}

int internal_strcmp(const char *s1, const char *s2) {
while (true) {
unsigned c1 = *s1;
Expand Down Expand Up @@ -234,12 +215,6 @@ char *internal_strstr(const char *haystack, const char *needle) {
return nullptr;
}

uptr internal_wcslen(const wchar_t *s) {
uptr i = 0;
while (s[i]) i++;
return i;
}

s64 internal_simple_strtoll(const char *nptr, char **endptr, int base) {
CHECK_EQ(base, 10);
while (IsSpace(*nptr)) nptr++;
Expand Down
5 changes: 0 additions & 5 deletions compiler-rt/lib/sanitizer_common/sanitizer_libc.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,13 @@ void *internal_memrchr(const void *s, int c, uptr n);
int internal_memcmp(const void* s1, const void* s2, uptr n);
void *internal_memcpy(void *dest, const void *src, uptr n);
void *internal_memmove(void *dest, const void *src, uptr n);
// Set [s, s + n) to 0. Both s and n should be 16-aligned.
void internal_bzero_aligned16(void *s, uptr n);
// Should not be used in performance-critical places.
void *internal_memset(void *s, int c, uptr n);
char* internal_strchr(const char *s, int c);
char *internal_strchrnul(const char *s, int c);
int internal_strcmp(const char *s1, const char *s2);
uptr internal_strcspn(const char *s, const char *reject);
char *internal_strdup(const char *s);
char *internal_strndup(const char *s, uptr n);
uptr internal_strlen(const char *s);
uptr internal_strlcat(char *dst, const char *src, uptr maxlen);
char *internal_strncat(char *dst, const char *src, uptr n);
Expand All @@ -50,8 +47,6 @@ uptr internal_strlcpy(char *dst, const char *src, uptr maxlen);
char *internal_strncpy(char *dst, const char *src, uptr n);
uptr internal_strnlen(const char *s, uptr maxlen);
char *internal_strrchr(const char *s, int c);
// This is O(N^2), but we are not using it in hot places.
uptr internal_wcslen(const wchar_t *s);
char *internal_strstr(const char *haystack, const char *needle);
// Works only for base=10 and doesn't set errno.
s64 internal_simple_strtoll(const char *nptr, char **endptr, int base);
Expand Down

0 comments on commit 54764ca

Please sign in to comment.