[llvm] r348702 - [WebAssembly] Make WasmSymbol's signature usable for events (NFC)

Heejin Ahn via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 7 22:16:14 PST 2018


Author: aheejin
Date: Fri Dec  7 22:16:13 2018
New Revision: 348702

URL: http://llvm.org/viewvc/llvm-project?rev=348702&view=rev
Log:
[WebAssembly] Make WasmSymbol's signature usable for events (NFC)

Summary:
WasmSignature used to use its `WasmSignature` member variable only for
function types, but now it also can be used for events as well.

Reviewers: sbc100

Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits

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

Modified:
    llvm/trunk/include/llvm/BinaryFormat/Wasm.h
    llvm/trunk/include/llvm/Object/Wasm.h
    llvm/trunk/lib/Object/WasmObjectFile.cpp

Modified: llvm/trunk/include/llvm/BinaryFormat/Wasm.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BinaryFormat/Wasm.h?rev=348702&r1=348701&r2=348702&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BinaryFormat/Wasm.h (original)
+++ llvm/trunk/include/llvm/BinaryFormat/Wasm.h Fri Dec  7 22:16:13 2018
@@ -331,14 +331,6 @@ inline bool operator!=(const WasmGlobalT
   return !(LHS == RHS);
 }
 
-inline bool operator==(const WasmEventType &LHS, const WasmEventType &RHS) {
-  return LHS.Attribute == RHS.Attribute && LHS.SigIndex == RHS.SigIndex;
-}
-
-inline bool operator!=(const WasmEventType &LHS, const WasmEventType &RHS) {
-  return !(LHS == RHS);
-}
-
 std::string toString(wasm::WasmSymbolType type);
 std::string relocTypetoString(uint32_t type);
 

Modified: llvm/trunk/include/llvm/Object/Wasm.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/Wasm.h?rev=348702&r1=348701&r2=348702&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/Wasm.h (original)
+++ llvm/trunk/include/llvm/Object/Wasm.h Fri Dec  7 22:16:13 2018
@@ -37,16 +37,16 @@ namespace object {
 class WasmSymbol {
 public:
   WasmSymbol(const wasm::WasmSymbolInfo &Info,
-             const wasm::WasmSignature *FunctionType,
              const wasm::WasmGlobalType *GlobalType,
-             const wasm::WasmEventType *EventType)
-      : Info(Info), FunctionType(FunctionType), GlobalType(GlobalType),
-        EventType(EventType) {}
+             const wasm::WasmEventType *EventType,
+             const wasm::WasmSignature *Signature)
+      : Info(Info), GlobalType(GlobalType), EventType(EventType),
+        Signature(Signature) {}
 
   const wasm::WasmSymbolInfo &Info;
-  const wasm::WasmSignature *FunctionType;
   const wasm::WasmGlobalType *GlobalType;
   const wasm::WasmEventType *EventType;
+  const wasm::WasmSignature *Signature;
 
   bool isTypeFunction() const {
     return Info.Kind == wasm::WASM_SYMBOL_TYPE_FUNCTION;

Modified: llvm/trunk/lib/Object/WasmObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/WasmObjectFile.cpp?rev=348702&r1=348701&r2=348702&view=diff
==============================================================================
--- llvm/trunk/lib/Object/WasmObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/WasmObjectFile.cpp Fri Dec  7 22:16:13 2018
@@ -468,7 +468,7 @@ Error WasmObjectFile::parseLinkingSectio
 
   while (Count--) {
     wasm::WasmSymbolInfo Info;
-    const wasm::WasmSignature *FunctionType = nullptr;
+    const wasm::WasmSignature *Signature = nullptr;
     const wasm::WasmGlobalType *GlobalType = nullptr;
     const wasm::WasmEventType *EventType = nullptr;
 
@@ -486,13 +486,13 @@ Error WasmObjectFile::parseLinkingSectio
       if (IsDefined) {
         Info.Name = readString(Ctx);
         unsigned FuncIndex = Info.ElementIndex - NumImportedFunctions;
-        FunctionType = &Signatures[FunctionTypes[FuncIndex]];
+        Signature = &Signatures[FunctionTypes[FuncIndex]];
         wasm::WasmFunction &Function = Functions[FuncIndex];
         if (Function.SymbolName.empty())
           Function.SymbolName = Info.Name;
       } else {
         wasm::WasmImport &Import = *ImportedFunctions[Info.ElementIndex];
-        FunctionType = &Signatures[Import.SigIndex];
+        Signature = &Signatures[Import.SigIndex];
         Info.Name = Import.Field;
         Info.Module = Import.Module;
       }
@@ -565,6 +565,7 @@ Error WasmObjectFile::parseLinkingSectio
         Info.Name = readString(Ctx);
         unsigned EventIndex = Info.ElementIndex - NumImportedEvents;
         wasm::WasmEvent &Event = Events[EventIndex];
+        Signature = &Signatures[Event.Type.SigIndex];
         EventType = &Event.Type;
         if (Event.SymbolName.empty())
           Event.SymbolName = Info.Name;
@@ -572,6 +573,7 @@ Error WasmObjectFile::parseLinkingSectio
       } else {
         wasm::WasmImport &Import = *ImportedEvents[Info.ElementIndex];
         EventType = &Import.Event;
+        Signature = &Signatures[EventType->SigIndex];
         Info.Name = Import.Field;
       }
       break;
@@ -589,8 +591,8 @@ Error WasmObjectFile::parseLinkingSectio
                                                 Twine(Info.Name),
                                             object_error::parse_failed);
     LinkingData.SymbolTable.emplace_back(Info);
-    Symbols.emplace_back(LinkingData.SymbolTable.back(), FunctionType,
-                         GlobalType, EventType);
+    Symbols.emplace_back(LinkingData.SymbolTable.back(), GlobalType, EventType,
+                         Signature);
     LLVM_DEBUG(dbgs() << "Adding symbol: " << Symbols.back() << "\n");
   }
 




More information about the llvm-commits mailing list