[lld] df6803d - [ELF] Symbols: remove isPlaceholder() test for Defined/CommonSymbol. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 28 10:39:40 PDT 2022


Author: Fangrui Song
Date: 2022-09-28T10:39:31-07:00
New Revision: df6803d94b4d21c24a07caf911cd9a20d0481abd

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

LOG: [ELF] Symbols: remove isPlaceholder() test for Defined/CommonSymbol. NFC

Added: 
    

Modified: 
    lld/ELF/Symbols.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index 787223bde20c2..741d8e74dfcae 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -386,11 +386,6 @@ void Symbol::mergeProperties(const Symbol &other) {
 void Symbol::resolve(const Symbol &other) {
   mergeProperties(other);
 
-  if (isPlaceholder()) {
-    replace(other);
-    return;
-  }
-
   switch (other.kind()) {
   case Symbol::UndefinedKind:
     resolveUndefined(cast<Undefined>(other));
@@ -418,7 +413,7 @@ void Symbol::resolveUndefined(const Undefined &other) {
   //
   // If this is a non-weak defined symbol in a discarded section, override the
   // existing undefined symbol for better error message later.
-  if ((isShared() && other.visibility() != STV_DEFAULT) ||
+  if (isPlaceholder() || (isShared() && other.visibility() != STV_DEFAULT) ||
       (isUndefined() && other.binding != STB_WEAK && other.discardedSecIdx)) {
     replace(other);
     return;
@@ -626,6 +621,11 @@ void Symbol::resolveDefined(const Defined &other) {
 }
 
 void Symbol::resolveLazy(const LazyObject &other) {
+  if (isPlaceholder()) {
+    replace(other);
+    return;
+  }
+
   // For common objects, we want to look for global or weak definitions that
   // should be extracted as the canonical definition instead.
   if (LLVM_UNLIKELY(isCommon()) && elf::config->fortranCommon &&
@@ -660,6 +660,10 @@ void Symbol::resolveLazy(const LazyObject &other) {
 }
 
 void Symbol::resolveShared(const SharedSymbol &other) {
+  if (isPlaceholder()) {
+    replace(other);
+    return;
+  }
   if (isCommon()) {
     // See the comment in resolveCommon() above.
     if (other.size > cast<CommonSymbol>(this)->size)


        


More information about the llvm-commits mailing list