Skip to content

Commit aef2810

Browse files
committed
[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).
1 parent f22c300 commit aef2810

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lld/ELF/Relocations.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,11 +1419,16 @@ template <class ELFT, class RelTy> void RelocationScanner::scanOne(RelTy *&i) {
14191419
uint32_t symIndex = rel.getSymbol(config->isMips64EL);
14201420
Symbol &sym = sec->getFile<ELFT>()->getSymbol(symIndex);
14211421
RelType type;
1422-
if (config->mipsN32Abi) {
1423-
type = getMipsN32RelType(i);
1424-
} else {
1422+
if constexpr (ELFT::Is64Bits) {
14251423
type = rel.getType(config->isMips64EL);
14261424
++i;
1425+
} else {
1426+
if (config->mipsN32Abi) {
1427+
type = getMipsN32RelType(i);
1428+
} else {
1429+
type = rel.getType(config->isMips64EL);
1430+
++i;
1431+
}
14271432
}
14281433
// Get an offset in an output section this relocation is applied to.
14291434
uint64_t offset = getter.get(rel.r_offset);

0 commit comments

Comments
 (0)