[lld] 9fac78d - [ELF] Simplify and optimize .relr.dyn NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 25 22:50:09 PST 2022


Author: Fangrui Song
Date: 2022-01-25T22:50:03-08:00
New Revision: 9fac78d0e1820b132964f6c1cfe22049d890d1d8

URL: https://github.com/llvm/llvm-project/commit/9fac78d0e1820b132964f6c1cfe22049d890d1d8
DIFF: https://github.com/llvm/llvm-project/commit/9fac78d0e1820b132964f6c1cfe22049d890d1d8.diff

LOG: [ELF] Simplify and optimize .relr.dyn NFC

Added: 
    

Modified: 
    lld/ELF/SyntheticSections.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 87f4269b8391..9f0cbf9e8488 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;
     }


        


More information about the llvm-commits mailing list