[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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@348702 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/llvm/BinaryFormat/Wasm.h b/include/llvm/BinaryFormat/Wasm.h
index f1d6e04..dc1cfd8 100644
--- a/include/llvm/BinaryFormat/Wasm.h
+++ b/include/llvm/BinaryFormat/Wasm.h
@@ -331,14 +331,6 @@
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);
diff --git a/include/llvm/Object/Wasm.h b/include/llvm/Object/Wasm.h
index 3f3ad92..902f8a4 100644
--- a/include/llvm/Object/Wasm.h
+++ b/include/llvm/Object/Wasm.h
@@ -37,16 +37,16 @@
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;
diff --git a/lib/Object/WasmObjectFile.cpp b/lib/Object/WasmObjectFile.cpp
index e756007..895d45c 100644
--- a/lib/Object/WasmObjectFile.cpp
+++ b/lib/Object/WasmObjectFile.cpp
@@ -468,7 +468,7 @@
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 @@
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 @@
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 @@
} else {
wasm::WasmImport &Import = *ImportedEvents[Info.ElementIndex];
EventType = &Import.Event;
+ Signature = &Signatures[EventType->SigIndex];
Info.Name = Import.Field;
}
break;
@@ -589,8 +591,8 @@
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");
}