[lld] aef2810 - [ELF] Relocations: Avoid MIPS check for ELFCLASS64 with if constexpr. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 12 20:53:50 PDT 2024
Author: Fangrui Song
Date: 2024-04-12T20:53:44-07:00
New Revision: aef28100294d04c2253a1cb8bbf552fa296dea4e
URL: https://github.com/llvm/llvm-project/commit/aef28100294d04c2253a1cb8bbf552fa296dea4e
DIFF: https://github.com/llvm/llvm-project/commit/aef28100294d04c2253a1cb8bbf552fa296dea4e.diff
LOG: [ELF] Relocations: Avoid MIPS check for ELFCLASS64 with if constexpr. NFC
After inlining, `scanSection` is significantly longer (more than 100+
instructions on x86-64 built with Clang) when `i` does not always
increment by one (MIPS).
Added:
Modified:
lld/ELF/Relocations.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 55274344f88119..04db413a6609fd 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1419,11 +1419,16 @@ template <class ELFT, class RelTy> void RelocationScanner::scanOne(RelTy *&i) {
uint32_t symIndex = rel.getSymbol(config->isMips64EL);
Symbol &sym = sec->getFile<ELFT>()->getSymbol(symIndex);
RelType type;
- if (config->mipsN32Abi) {
- type = getMipsN32RelType(i);
- } else {
+ if constexpr (ELFT::Is64Bits) {
type = rel.getType(config->isMips64EL);
++i;
+ } else {
+ if (config->mipsN32Abi) {
+ type = getMipsN32RelType(i);
+ } else {
+ type = rel.getType(config->isMips64EL);
+ ++i;
+ }
}
// Get an offset in an output section this relocation is applied to.
uint64_t offset = getter.get(rel.r_offset);
More information about the llvm-commits
mailing list