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

Differential Revision: https://reviews.llvm.org/D45021

llvm-svn: 330448
This commit is contained in:
Nicholas Wilson 2018-04-20 17:07:24 +00:00
parent 4306f2086f
commit ef90ff36da
2 changed files with 11 additions and 19 deletions

View File

@ -74,7 +74,7 @@ struct WasmGlobal {
uint32_t Index; uint32_t Index;
WasmGlobalType Type; WasmGlobalType Type;
WasmInitExpr InitExpr; WasmInitExpr InitExpr;
StringRef Name; // from the "linking" or "names" section StringRef SymbolName; // from the "linking" section
}; };
struct WasmImport { struct WasmImport {
@ -100,7 +100,8 @@ struct WasmFunction {
ArrayRef<uint8_t> Body; ArrayRef<uint8_t> Body;
uint32_t CodeSectionOffset; uint32_t CodeSectionOffset;
uint32_t Size; 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 uint32_t Comdat; // from the "comdat info" section
}; };
@ -108,7 +109,7 @@ struct WasmDataSegment {
uint32_t MemoryIndex; uint32_t MemoryIndex;
WasmInitExpr Offset; WasmInitExpr Offset;
ArrayRef<uint8_t> Content; ArrayRef<uint8_t> Content;
StringRef Name; StringRef Name; // from the "segment info" section
uint32_t Alignment; uint32_t Alignment;
uint32_t Flags; uint32_t Flags;
uint32_t Comdat; // from the "comdat info" section uint32_t Comdat; // from the "comdat info" section
@ -145,7 +146,7 @@ struct WasmSymbolInfo {
uint8_t Kind; uint8_t Kind;
uint32_t Flags; uint32_t Flags;
union { 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. // space.
uint32_t ElementIndex; uint32_t ElementIndex;
// For a data symbols, the address of the data relative to segment. // For a data symbols, the address of the data relative to segment.

View File

@ -283,11 +283,8 @@ Error WasmObjectFile::parseNameSection(const uint8_t *Ptr, const uint8_t *End) {
return make_error<GenericBinaryError>("Invalid name entry", return make_error<GenericBinaryError>("Invalid name entry",
object_error::parse_failed); object_error::parse_failed);
DebugNames.push_back(wasm::WasmFunctionName{Index, Name}); DebugNames.push_back(wasm::WasmFunctionName{Index, Name});
if (isDefinedFunctionIndex(Index)) { if (isDefinedFunctionIndex(Index))
// Override any existing name; the name specified by the "names" getDefinedFunction(Index).DebugName = Name;
// section is the Function's canonical name.
getDefinedFunction(Index).Name = Name;
}
} }
break; break;
} }
@ -409,11 +406,8 @@ Error WasmObjectFile::parseLinkingSectionSymtab(const uint8_t *&Ptr,
unsigned FuncIndex = Info.ElementIndex - NumImportedFunctions; unsigned FuncIndex = Info.ElementIndex - NumImportedFunctions;
FunctionType = &Signatures[FunctionTypes[FuncIndex]]; FunctionType = &Signatures[FunctionTypes[FuncIndex]];
wasm::WasmFunction &Function = Functions[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 Function.SymbolName = Info.Name;
// one hasn't already been set.
Function.Name = Info.Name;
}
} else { } else {
wasm::WasmImport &Import = *ImportedFunctions[Info.ElementIndex]; wasm::WasmImport &Import = *ImportedFunctions[Info.ElementIndex];
FunctionType = &Signatures[Import.SigIndex]; FunctionType = &Signatures[Import.SigIndex];
@ -437,11 +431,8 @@ Error WasmObjectFile::parseLinkingSectionSymtab(const uint8_t *&Ptr,
unsigned GlobalIndex = Info.ElementIndex - NumImportedGlobals; unsigned GlobalIndex = Info.ElementIndex - NumImportedGlobals;
wasm::WasmGlobal &Global = Globals[GlobalIndex]; wasm::WasmGlobal &Global = Globals[GlobalIndex];
GlobalType = &Global.Type; 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 Global.SymbolName = Info.Name;
// one hasn't already been set.
Global.Name = Info.Name;
}
} else { } else {
wasm::WasmImport &Import = *ImportedGlobals[Info.ElementIndex]; wasm::WasmImport &Import = *ImportedGlobals[Info.ElementIndex];
Info.Name = Import.Field; Info.Name = Import.Field;