[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
Mon Mar 5 04:18:59 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL326691: [WebAssembly] Attach a name to globals similarly to function naming (authored by ncw, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44033?vs=136797&id=136970#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44033

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


Index: llvm/trunk/lib/Object/WasmObjectFile.cpp
===================================================================
--- llvm/trunk/lib/Object/WasmObjectFile.cpp
+++ llvm/trunk/lib/Object/WasmObjectFile.cpp
@@ -403,7 +403,7 @@
         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 @@
       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;
Index: llvm/trunk/include/llvm/BinaryFormat/Wasm.h
===================================================================
--- llvm/trunk/include/llvm/BinaryFormat/Wasm.h
+++ llvm/trunk/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.136970.patch
Type: text/x-patch
Size: 1949 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180305/b5e2c28b/attachment.bin>


More information about the llvm-commits mailing list