[llvm] r326691 - [WebAssembly] Attach a name to globals similarly to function naming
Nicholas Wilson via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 5 04:16:32 PST 2018
Author: ncw
Date: Mon Mar 5 04:16:32 2018
New Revision: 326691
URL: http://llvm.org/viewvc/llvm-project?rev=326691&view=rev
Log:
[WebAssembly] Attach a name to globals similarly to function naming
This allows LLD to print the name for an InputGlobal when encountering
an error.
Differential Revision: https://reviews.llvm.org/D44033
Modified:
llvm/trunk/include/llvm/BinaryFormat/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=326691&r1=326690&r2=326691&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BinaryFormat/Wasm.h (original)
+++ llvm/trunk/include/llvm/BinaryFormat/Wasm.h Mon Mar 5 04:16:32 2018
@@ -74,6 +74,7 @@ struct WasmGlobal {
uint32_t Index;
WasmGlobalType Type;
WasmInitExpr InitExpr;
+ StringRef Name; // from the "linking" or "names" section
};
struct WasmImport {
@@ -99,7 +100,7 @@ struct WasmFunction {
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
};
Modified: llvm/trunk/lib/Object/WasmObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/WasmObjectFile.cpp?rev=326691&r1=326690&r2=326691&view=diff
==============================================================================
--- llvm/trunk/lib/Object/WasmObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/WasmObjectFile.cpp Mon Mar 5 04:16:32 2018
@@ -403,7 +403,7 @@ Error WasmObjectFile::parseLinkingSectio
Info.Name = readString(Ptr);
unsigned FuncIndex = Info.ElementIndex - NumImportedFunctions;
FunctionType = &Signatures[FunctionTypes[FuncIndex]];
- auto &Function = Functions[FuncIndex];
+ wasm::WasmFunction &Function = Functions[FuncIndex];
if (Function.Name.empty()) {
// Use the symbol's name to set a name for the Function, but only if
// one hasn't already been set.
@@ -425,7 +425,13 @@ Error WasmObjectFile::parseLinkingSectio
if (IsDefined) {
Info.Name = readString(Ptr);
unsigned GlobalIndex = Info.ElementIndex - NumImportedGlobals;
- GlobalType = &Globals[GlobalIndex].Type;
+ wasm::WasmGlobal &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;
More information about the llvm-commits
mailing list