[PATCH] D44033: [WebAssembly] Attach a name to globals similarly to function naming
Nicholas Wilson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 2 10:44:15 PST 2018
ncw created this revision.
ncw added a reviewer: sbc100.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, dschuff, jfb.
This allows LLD to print the name for an InputGlobal when encountering an error.
---
NB. This PR specifies globals in the "name" section - but I don't think we need that now, and it's not "official" yet anyway: https://github.com/WebAssembly/design/pull/1064
Repository:
rL LLVM
https://reviews.llvm.org/D44033
Files:
include/llvm/BinaryFormat/Wasm.h
lib/Object/WasmObjectFile.cpp
Index: lib/Object/WasmObjectFile.cpp
===================================================================
--- lib/Object/WasmObjectFile.cpp
+++ lib/Object/WasmObjectFile.cpp
@@ -425,7 +425,13 @@
if (IsDefined) {
Info.Name = readString(Ptr);
unsigned GlobalIndex = Info.ElementIndex - NumImportedGlobals;
- GlobalType = &Globals[GlobalIndex].Type;
+ auto &Global = Globals[GlobalIndex];
+ GlobalType = &Global.Type;
+ if (Global.Name.empty()) {
+ // Use the symbol's name to set a name for the Global, but only if
+ // one hasn't already been set.
+ Global.Name = Info.Name;
+ }
} else {
wasm::WasmImport &Import = *ImportedGlobals[Info.ElementIndex];
Info.Name = Import.Field;
Index: include/llvm/BinaryFormat/Wasm.h
===================================================================
--- include/llvm/BinaryFormat/Wasm.h
+++ include/llvm/BinaryFormat/Wasm.h
@@ -74,6 +74,7 @@
uint32_t Index;
WasmGlobalType Type;
WasmInitExpr InitExpr;
+ StringRef Name; // from the "linking" or "names" section
};
struct WasmImport {
@@ -99,7 +100,7 @@
ArrayRef<uint8_t> Body;
uint32_t CodeSectionOffset;
uint32_t Size;
- StringRef Name; // from the "names" section
+ StringRef Name; // from the "linking" or "names" section
StringRef Comdat; // from the "comdat info" section
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44033.136797.patch
Type: text/x-patch
Size: 1407 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180302/6c764412/attachment.bin>
More information about the llvm-commits
mailing list