[lld] r325418 - [WebAssembly] Remove unneeded classifer methods from Symbol class. NFC.

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 16 16:44:21 PST 2018


Author: sbc
Date: Fri Feb 16 16:44:21 2018
New Revision: 325418

URL: http://llvm.org/viewvc/llvm-project?rev=325418&view=rev
Log:
[WebAssembly] Remove unneeded classifer methods from Symbol class. NFC.

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

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

Modified:
    lld/trunk/wasm/SymbolTable.cpp
    lld/trunk/wasm/Symbols.cpp
    lld/trunk/wasm/Symbols.h
    lld/trunk/wasm/Writer.cpp

Modified: lld/trunk/wasm/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/SymbolTable.cpp?rev=325418&r1=325417&r2=325418&view=diff
==============================================================================
--- lld/trunk/wasm/SymbolTable.cpp (original)
+++ lld/trunk/wasm/SymbolTable.cpp Fri Feb 16 16:44:21 2018
@@ -86,9 +86,9 @@ static void checkSymbolTypes(const Symbo
 
   // 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;

Modified: lld/trunk/wasm/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Symbols.cpp?rev=325418&r1=325417&r2=325418&view=diff
==============================================================================
--- lld/trunk/wasm/Symbols.cpp (original)
+++ lld/trunk/wasm/Symbols.cpp Fri Feb 16 16:44:21 2018
@@ -100,7 +100,6 @@ void FunctionSymbol::setTableIndex(uint3
 }
 
 uint32_t DefinedGlobal::getVirtualAddress() const {
-  assert(isGlobal());
   DEBUG(dbgs() << "getVirtualAddress: " << getName() << "\n");
   return Chunk ? dyn_cast<InputSegment>(Chunk)->translateVA(VirtualAddress)
                : VirtualAddress;
@@ -108,7 +107,6 @@ uint32_t DefinedGlobal::getVirtualAddres
 
 void DefinedGlobal::setVirtualAddress(uint32_t Value) {
   DEBUG(dbgs() << "setVirtualAddress " << Name << " -> " << Value << "\n");
-  assert(isGlobal());
   VirtualAddress = Value;
 }
 

Modified: lld/trunk/wasm/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Symbols.h?rev=325418&r1=325417&r2=325418&view=diff
==============================================================================
--- lld/trunk/wasm/Symbols.h (original)
+++ lld/trunk/wasm/Symbols.h Fri Feb 16 16:44:21 2018
@@ -49,11 +49,6 @@ public:
     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;

Modified: lld/trunk/wasm/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Writer.cpp?rev=325418&r1=325417&r2=325418&view=diff
==============================================================================
--- lld/trunk/wasm/Writer.cpp (original)
+++ lld/trunk/wasm/Writer.cpp Fri Feb 16 16:44:21 2018
@@ -290,7 +290,7 @@ void Writer::createExportSection() {
     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 @@ void Writer::calculateExports() {
     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;




More information about the llvm-commits mailing list