diff options
author | Fangrui Song <i@maskray.me> | 2022-01-25 22:50:03 -0800 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2022-01-25 22:50:03 -0800 |
commit | 9fac78d0e1820b132964f6c1cfe22049d890d1d8 (patch) | |
tree | 27cb290b81778f63ed81c6cf775505fc7129dd73 /lld/ELF/SyntheticSections.cpp | |
parent | 4fb8e0b8621a641b38cf2218cc20301da346cedf (diff) | |
download | llvm-9fac78d0e1820b132964f6c1cfe22049d890d1d8.zip llvm-9fac78d0e1820b132964f6c1cfe22049d890d1d8.tar.gz llvm-9fac78d0e1820b132964f6c1cfe22049d890d1d8.tar.bz2 |
[ELF] Simplify and optimize .relr.dyn NFC
Diffstat (limited to 'lld/ELF/SyntheticSections.cpp')
-rw-r--r-- | lld/ELF/SyntheticSections.cpp | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 87f4269..9f0cbf9 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -2038,28 +2038,16 @@ template <class ELFT> bool RelrSection<ELFT>::updateAllocSize() { ++i; // Find foldable relocations to construct bitmaps. - while (i < e) { + for (;;) { uint64_t bitmap = 0; - - while (i < e) { - uint64_t delta = offsets[i] - base; - - // If it is too far, it cannot be folded. - if (delta >= nBits * wordsize) - break; - - // If it is not a multiple of wordsize away, it cannot be folded. - if (delta % wordsize) + for (; i != e; ++i) { + uint64_t d = offsets[i] - base; + if (d >= nBits * wordsize || d % wordsize) break; - - // Fold it. - bitmap |= 1ULL << (delta / wordsize); - ++i; + bitmap |= uint64_t(1) << (d / wordsize); } - if (!bitmap) break; - relrRelocs.push_back(Elf_Relr((bitmap << 1) | 1)); base += nBits * wordsize; } |