[lld] d9d656e - [ELF] resolve LazySymbol: remove a branch in the fast path

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 1 23:07:44 PST 2024


Author: Fangrui Song
Date: 2024-12-01T23:07:38-08:00
New Revision: d9d656edd4d6d7ca1be5c2f2e0cca4d1ef773dd5

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

LOG: [ELF] resolve LazySymbol: remove a branch in the fast path

Added: 
    

Modified: 
    lld/ELF/Symbols.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index 444ed5e69d362b..2c7b59f32cf308 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -619,20 +619,18 @@ void Symbol::resolve(Ctx &ctx, const LazySymbol &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()) && ctx.arg.fortranCommon &&
-      other.file->shouldExtractForCommon(getName())) {
-    ctx.backwardReferences.erase(this);
-    other.overwrite(*this);
-    other.extract(ctx);
-    return;
-  }
-
-  if (!isUndefined()) {
-    // See the comment in resolveUndefined().
-    if (isDefined())
+  if (LLVM_UNLIKELY(!isUndefined())) {
+    // See the comment in resolve(Ctx &, const Undefined &).
+    if (isDefined()) {
+      ctx.backwardReferences.erase(this);
+    } else if (isCommon() && ctx.arg.fortranCommon &&
+               other.file->shouldExtractForCommon(getName())) {
+      // For common objects, we want to look for global or weak definitions that
+      // should be extracted as the canonical definition instead.
       ctx.backwardReferences.erase(this);
+      other.overwrite(*this);
+      other.extract(ctx);
+    }
     return;
   }
 


        


More information about the llvm-commits mailing list