[lld] 9a9ec8e - [lld][WebAssembly] Remove redundant check for undefined global (NFC)

Heejin Ahn via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 5 15:11:48 PDT 2021


Author: Heejin Ahn
Date: 2021-10-05T15:11:27-07:00
New Revision: 9a9ec8e04b6b0b5124a4e77dbc0916b85f03f6ee

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

LOG: [lld][WebAssembly] Remove redundant check for undefined global (NFC)

Also does some refactoring.

Reviewed By: sbc100

Differential Revision: https://reviews.llvm.org/D111101

Added: 
    

Modified: 
    lld/wasm/Relocations.cpp

Removed: 
    


################################################################################
diff  --git a/lld/wasm/Relocations.cpp b/lld/wasm/Relocations.cpp
index a6128e2443fc..847ce87b4aa0 100644
--- a/lld/wasm/Relocations.cpp
+++ b/lld/wasm/Relocations.cpp
@@ -32,17 +32,13 @@ static bool requiresGOTAccess(const Symbol *sym) {
 }
 
 static bool allowUndefined(const Symbol* sym) {
-  // Undefined functions and globals with explicit import name are allowed to be
-  // undefined at link time.
-  if (auto *f = dyn_cast<UndefinedFunction>(sym))
-    if (f->importName || config->importUndefined)
-      return true;
-  if (auto *g = dyn_cast<UndefinedGlobal>(sym))
-    if (g->importName)
-      return true;
-  if (auto *g = dyn_cast<UndefinedGlobal>(sym))
-    if (g->importName)
-      return true;
+  // Symbols with explicit import names are always allowed to be undefined at
+  // link time.
+  if (sym->importName)
+    return true;
+  if (isa<UndefinedFunction>(sym) && config->importUndefined)
+    return true;
+
   return config->allowUndefinedSymbols.count(sym->getName()) != 0;
 }
 


        


More information about the llvm-commits mailing list