[lld] 8617996 - [ELF] maybeReportUndefined: move sym.isUndefined() check to the caller. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 16 00:27:24 PST 2021
Author: Fangrui Song
Date: 2021-12-16T00:27:19-08:00
New Revision: 8617996ac1fdc52c5215165275fe61d82a594cc7
URL: https://github.com/llvm/llvm-project/commit/8617996ac1fdc52c5215165275fe61d82a594cc7
DIFF: https://github.com/llvm/llvm-project/commit/8617996ac1fdc52c5215165275fe61d82a594cc7.diff
LOG: [ELF] maybeReportUndefined: move sym.isUndefined() check to the caller. NFC
Avoid a function call in the majority of cases.
Added:
Modified:
lld/ELF/Relocations.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index a8def765621c..79ba3194d73b 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -739,8 +739,6 @@ template <class ELFT> void elf::reportUndefinedSymbols() {
// Returns true if the undefined symbol will produce an error message.
static bool maybeReportUndefined(Symbol &sym, InputSectionBase &sec,
uint64_t offset) {
- if (!sym.isUndefined())
- return false;
// If versioned, issue an error (even if the symbol is weak) because we don't
// know the defining filename which is required to construct a Verneed entry.
if (*sym.getVersionSuffix() == '@') {
@@ -1327,7 +1325,8 @@ static void scanReloc(InputSectionBase &sec, OffsetGetter &getOffset, RelTy *&i,
// Error if the target symbol is undefined. Symbol index 0 may be used by
// marker relocations, e.g. R_*_NONE and R_ARM_V4BX. Don't error on them.
- if (symIndex != 0 && maybeReportUndefined(sym, sec, rel.r_offset))
+ if (sym.isUndefined() && symIndex != 0 &&
+ maybeReportUndefined(sym, sec, rel.r_offset))
return;
const uint8_t *relocatedAddr = sec.data().begin() + rel.r_offset;
More information about the llvm-commits
mailing list