[PATCH] D43710: [WebAssembly] Use more specific type and simplify code.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 23 18:29:28 PST 2018
ruiu created this revision.
ruiu added a reviewer: sbc100.
Herald added subscribers: sunfish, aheejin, jgravelle-google, dschuff, jfb.
Instead of {Function,Global,Data}Symbol, use Defined{Function,Global,Data}
because undefined symbol should never reach this function.
https://reviews.llvm.org/D43710
Files:
lld/wasm/Writer.cpp
Index: lld/wasm/Writer.cpp
===================================================================
--- lld/wasm/Writer.cpp
+++ lld/wasm/Writer.cpp
@@ -290,22 +290,20 @@
}
unsigned FakeGlobalIndex = NumImportedGlobals + InputGlobals.size();
+
for (const Symbol *Sym : ExportedSymbols) {
- DEBUG(dbgs() << "Export: " << Sym->getName() << "\n");
+ StringRef Name = Sym->getName();
WasmExport Export;
- Export.Name = Sym->getName();
- if (isa<FunctionSymbol>(Sym)) {
- Export.Index = Sym->getOutputIndex();
- Export.Kind = WASM_EXTERNAL_FUNCTION;
- } else if (isa<GlobalSymbol>(Sym)) {
- Export.Index = Sym->getOutputIndex();
- Export.Kind = WASM_EXTERNAL_GLOBAL;
- } else if (isa<DataSymbol>(Sym)) {
- Export.Index = FakeGlobalIndex++;
- Export.Kind = WASM_EXTERNAL_GLOBAL;
- } else {
+ DEBUG(dbgs() << "Export: " << Name << "\n");
+
+ if (isa<DefinedFunction>(Sym))
+ Export = {Name, WASM_EXTERNAL_FUNCTION, Sym->getOutputIndex()};
+ else if (isa<DefinedGlobal>(Sym))
+ Export = {Name, WASM_EXTERNAL_GLOBAL, Sym->getOutputIndex()};
+ else if (isa<DefinedData>(Sym))
+ Export = {Name, WASM_EXTERNAL_GLOBAL, FakeGlobalIndex++};
+ else
llvm_unreachable("unexpected symbol type");
- }
writeExport(OS, Export);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43710.135761.patch
Type: text/x-patch
Size: 1320 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180224/71352184/attachment.bin>
More information about the llvm-commits
mailing list