[lld] 888d0a5 - [lld-macho][NFC] Remove redundant StringRef construction
Daniel Bertalan via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 21 06:37:48 PDT 2022
Author: Daniel Bertalan
Date: 2022-07-21T15:36:56+02:00
New Revision: 888d0a5ef2590f9f3e4c6820dfacb800db029d97
URL: https://github.com/llvm/llvm-project/commit/888d0a5ef2590f9f3e4c6820dfacb800db029d97
DIFF: https://github.com/llvm/llvm-project/commit/888d0a5ef2590f9f3e4c6820dfacb800db029d97.diff
LOG: [lld-macho][NFC] Remove redundant StringRef construction
It's only used in one branch, so we were unnecessarily calculating the
length of many symbol names.
Tiny speedup when linking chromium_framework on my M1 Mac mini:
x before.txt
+ after.txt
N Min Max Median Avg Stddev
x 10 3.9917109 4.0418 4.0318099 4.0203902 0.021459873
+ 10 3.944725 4.053988 3.9708955 3.9825602 0.037257609
Difference at 95.0% confidence
-0.03783 +/- 0.0285663
-0.940953% +/- 0.710536%
(Student's t, pooled s = 0.0304028)
Differential Revision: https://reviews.llvm.org/D130234
Added:
Modified:
lld/MachO/InputFiles.cpp
Removed:
################################################################################
diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index 93cde5f5deb2c..5bc333f57db55 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -903,7 +903,6 @@ void ObjFile::parseSymbols(ArrayRef<typename LP::section> sectionHeaders,
if (sym.n_type & N_STAB)
continue;
- StringRef name = strtab + sym.n_strx;
if ((sym.n_type & N_TYPE) == N_SECT) {
Subsections &subsections = sections[sym.n_sect - 1]->subsections;
// parseSections() may have chosen not to parse this section.
@@ -913,7 +912,7 @@ void ObjFile::parseSymbols(ArrayRef<typename LP::section> sectionHeaders,
} else if (isUndef(sym)) {
undefineds.push_back(i);
} else {
- symbols[i] = parseNonSectionSymbol(sym, name);
+ symbols[i] = parseNonSectionSymbol(sym, StringRef(strtab + sym.n_strx));
}
}
More information about the llvm-commits
mailing list