[PATCH] D43422: [WebAssembly] Remove unneeded classifer methods from Symbol class. NFC.

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 16 16:37:58 PST 2018


sbc100 created this revision.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, dschuff, jfb.

We already have isa<> for this, and these methods were simply
duplicating those redundantly.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D43422

Files:
  wasm/SymbolTable.cpp
  wasm/Symbols.cpp
  wasm/Symbols.h
  wasm/Writer.cpp


Index: wasm/Writer.cpp
===================================================================
--- wasm/Writer.cpp
+++ wasm/Writer.cpp
@@ -290,7 +290,7 @@
     WasmExport Export;
     Export.Name = E.FieldName;
     Export.Index = E.Sym->getOutputIndex();
-    if (E.Sym->isFunction())
+    if (isa<FunctionSymbol>(E.Sym))
       Export.Kind = WASM_EXTERNAL_FUNCTION;
     else
       Export.Kind = WASM_EXTERNAL_GLOBAL;
@@ -660,7 +660,7 @@
     for (Symbol *Sym : File->getSymbols()) {
       if (!Sym->isDefined() || File != Sym->getFile())
         continue;
-      if (Sym->isGlobal())
+      if (isa<GlobalSymbol>(Sym))
         continue;
       if (!Sym->getChunk()->Live)
         continue;
Index: wasm/Symbols.h
===================================================================
--- wasm/Symbols.h
+++ wasm/Symbols.h
@@ -49,11 +49,6 @@
     return SymbolKind == UndefinedGlobalKind ||
            SymbolKind == UndefinedFunctionKind;
   }
-  bool isFunction() const {
-    return SymbolKind == DefinedFunctionKind ||
-           SymbolKind == UndefinedFunctionKind;
-  }
-  bool isGlobal() const { return !isFunction(); }
   bool isLocal() const;
   bool isWeak() const;
   bool isHidden() const;
Index: wasm/Symbols.cpp
===================================================================
--- wasm/Symbols.cpp
+++ wasm/Symbols.cpp
@@ -100,15 +100,13 @@
 }
 
 uint32_t DefinedGlobal::getVirtualAddress() const {
-  assert(isGlobal());
   DEBUG(dbgs() << "getVirtualAddress: " << getName() << "\n");
   return Chunk ? dyn_cast<InputSegment>(Chunk)->translateVA(VirtualAddress)
                : VirtualAddress;
 }
 
 void DefinedGlobal::setVirtualAddress(uint32_t Value) {
   DEBUG(dbgs() << "setVirtualAddress " << Name << " -> " << Value << "\n");
-  assert(isGlobal());
   VirtualAddress = Value;
 }
 
Index: wasm/SymbolTable.cpp
===================================================================
--- wasm/SymbolTable.cpp
+++ wasm/SymbolTable.cpp
@@ -86,9 +86,9 @@
 
   // First check the symbol types match (i.e. either both are function
   // symbols or both are data symbols).
-  if (Existing.isFunction() != NewIsFunction) {
+  if (isa<FunctionSymbol>(Existing) != NewIsFunction) {
     error("symbol type mismatch: " + Existing.getName() + "\n>>> defined as " +
-          (Existing.isFunction() ? "Function" : "Global") + " in " +
+          (isa<FunctionSymbol>(Existing) ? "Function" : "Global") + " in " +
           toString(Existing.getFile()) + "\n>>> defined as " +
           (NewIsFunction ? "Function" : "Global") + " in " + F.getName());
     return;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43422.134769.patch
Type: text/x-patch
Size: 2575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180217/8d5ff596/attachment.bin>


More information about the llvm-commits mailing list