[PATCH] D45021: [WebAssembly] Distinguish debug/symbol names in the Wasm structs. NFC

Nicholas Wilson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 29 05:57:01 PDT 2018


ncw created this revision.
ncw added reviewers: sbc100, sunfish.
Herald added subscribers: llvm-commits, aheejin, jgravelle-google, dschuff, jfb.

The need for this was flagged up in review for https://reviews.llvm.org/D44440; this change is needed for that review to land


Repository:
  rL LLVM

https://reviews.llvm.org/D45021

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


Index: lib/Object/WasmObjectFile.cpp
===================================================================
--- lib/Object/WasmObjectFile.cpp
+++ lib/Object/WasmObjectFile.cpp
@@ -278,11 +278,8 @@
           return make_error<GenericBinaryError>("Invalid name entry",
                                                 object_error::parse_failed);
         DebugNames.push_back(wasm::WasmFunctionName{Index, Name});
-        if (isDefinedFunctionIndex(Index)) {
-          // Override any existing name; the name specified by the "names"
-          // section is the Function's canonical name.
-          getDefinedFunction(Index).Name = Name;
-        }
+        if (isDefinedFunctionIndex(Index))
+          getDefinedFunction(Index).DebugName = Name;
       }
       break;
     }
@@ -404,10 +401,10 @@
         unsigned FuncIndex = Info.ElementIndex - NumImportedFunctions;
         FunctionType = &Signatures[FunctionTypes[FuncIndex]];
         wasm::WasmFunction &Function = Functions[FuncIndex];
-        if (Function.Name.empty()) {
+        if (Function.SymbolName.empty()) {
           // Use the symbol's name to set a name for the Function, but only if
           // one hasn't already been set.
-          Function.Name = Info.Name;
+          Function.SymbolName = Info.Name;
         }
       } else {
         wasm::WasmImport &Import = *ImportedFunctions[Info.ElementIndex];
@@ -432,10 +429,10 @@
         unsigned GlobalIndex = Info.ElementIndex - NumImportedGlobals;
         wasm::WasmGlobal &Global = Globals[GlobalIndex];
         GlobalType = &Global.Type;
-        if (Global.Name.empty()) {
+        if (Global.SymbolName.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;
+          Global.SymbolName = Info.Name;
         }
       } else {
         wasm::WasmImport &Import = *ImportedGlobals[Info.ElementIndex];
Index: include/llvm/BinaryFormat/Wasm.h
===================================================================
--- include/llvm/BinaryFormat/Wasm.h
+++ include/llvm/BinaryFormat/Wasm.h
@@ -74,7 +74,7 @@
   uint32_t Index;
   WasmGlobalType Type;
   WasmInitExpr InitExpr;
-  StringRef Name; // from the "linking" or "names" section
+  StringRef SymbolName; // from the "linking" section
 };
 
 struct WasmImport {
@@ -100,15 +100,16 @@
   ArrayRef<uint8_t> Body;
   uint32_t CodeSectionOffset;
   uint32_t Size;
-  StringRef Name; // from the "linking" or "names" section
+  StringRef SymbolName; // from the "linking" section
+  StringRef DebugName; // from the "name" section
   uint32_t Comdat; // from the "comdat info" section
 };
 
 struct WasmDataSegment {
   uint32_t MemoryIndex;
   WasmInitExpr Offset;
   ArrayRef<uint8_t> Content;
-  StringRef Name;
+  StringRef Name; // from the "segment info" section
   uint32_t Alignment;
   uint32_t Flags;
   uint32_t Comdat; // from the "comdat info" section
@@ -145,7 +146,7 @@
   uint8_t Kind;
   uint32_t Flags;
   union {
-    // For function or global symbols, the index in function of global index
+    // For function or global symbols, the index in function or global index
     // space.
     uint32_t ElementIndex;
     // For a data symbols, the address of the data relative to segment.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45021.140216.patch
Type: text/x-patch
Size: 3300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180329/c15efbc0/attachment.bin>


More information about the llvm-commits mailing list