From 3e0a54e9da9f8db15dcf7dab6cd1f402e0a16f47 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 15 Sep 2018 23:59:13 +0000 Subject: [PATCH] [ELF] Use llvm::toLower instead of libc call tolower tolower() has some overhead because current locale is considered (though in lld the default "C" locale is used which does not matter too much). llvm::toLower is more efficient as it compiles to a compare and a conditional jump, as opposed to a libc call if tolower is used. Disregarding locale also matches gdb's behavior (gdb/minsyms.h): #define SYMBOL_HASH_NEXT(hash, c) \ ((hash) * 67 + TOLOWER ((unsigned char) (c)) - 113) where TOLOWER (include/safe-ctype.h) is a macro that uses a lookup table under the hood which is similar to llvm::toLower. Reviewers: ruiu, espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D52128 llvm-svn: 342342 --- lld/ELF/SyntheticSections.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index b547956..e4b1b0c 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -30,6 +30,7 @@ #include "lld/Common/Threads.h" #include "lld/Common/Version.h" #include "llvm/ADT/SetOperations.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/DebugInfo/DWARF/DWARFDebugPubTable.h" #include "llvm/Object/Decompressor.h" @@ -2338,7 +2339,7 @@ unsigned PltSection::getPltRelocOff() const { static uint32_t computeGdbHash(StringRef S) { uint32_t H = 0; for (uint8_t C : S) - H = H * 67 + tolower(C) - 113; + H = H * 67 + toLower(C) - 113; return H; } -- 2.7.4