[lld] 233a889 - [ELF] Simplify ObjFile<ELFT>::parseLazy. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 26 21:12:35 PST 2022


Author: Fangrui Song
Date: 2022-11-26T21:12:31-08:00
New Revision: 233a8895cfba6612d8fc5abe76c862d23f51d52b

URL: https://github.com/llvm/llvm-project/commit/233a8895cfba6612d8fc5abe76c862d23f51d52b
DIFF: https://github.com/llvm/llvm-project/commit/233a8895cfba6612d8fc5abe76c862d23f51d52b.diff

LOG: [ELF] Simplify ObjFile<ELFT>::parseLazy. NFC

Added: 
    

Modified: 
    lld/ELF/InputFiles.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 4b7b8f93a1f6..55c46b600c4e 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -1775,21 +1775,18 @@ template <class ELFT> void ObjFile<ELFT>::parseLazy() {
   const ArrayRef<typename ELFT::Sym> eSyms = this->getELFSyms<ELFT>();
   numSymbols = eSyms.size();
   symbols = std::make_unique<Symbol *[]>(numSymbols);
-  for (size_t i = firstGlobal, end = eSyms.size(); i != end; ++i)
-    if (eSyms[i].st_shndx != SHN_UNDEF)
-      symbols[i] = symtab.insert(CHECK(eSyms[i].getName(stringTable), this));
 
-  // Replace existing symbols with LazyObject symbols.
-  //
   // resolve() may trigger this->extract() if an existing symbol is an undefined
   // symbol. If that happens, this function has served its purpose, and we can
   // exit from the loop early.
-  for (Symbol *sym : getGlobalSymbols())
-    if (sym) {
-      sym->resolve(LazyObject{*this});
-      if (!lazy)
-        return;
-    }
+  for (size_t i = firstGlobal, end = eSyms.size(); i != end; ++i) {
+    if (eSyms[i].st_shndx == SHN_UNDEF)
+      continue;
+    symbols[i] = symtab.insert(CHECK(eSyms[i].getName(stringTable), this));
+    symbols[i]->resolve(LazyObject{*this});
+    if (!lazy)
+      break;
+  }
 }
 
 bool InputFile::shouldExtractForCommon(StringRef name) {


        


More information about the llvm-commits mailing list