Skip to content

Commit 29e8187

Browse files
committed
[Object][Wasm] Move WasmSymbolInfo directly into WasmSymbol (NFC)
1 parent 5d228ea commit 29e8187

File tree

5 files changed

+16
-21
lines changed

5 files changed

+16
-21
lines changed

lld/wasm/InputFiles.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -322,20 +322,20 @@ void ObjFile::addLegacyIndirectFunctionTableIfNeeded(
322322
return;
323323
}
324324

325-
auto *info = make<WasmSymbolInfo>();
326-
info->Name = tableImport->Field;
327-
info->Kind = WASM_SYMBOL_TYPE_TABLE;
328-
info->ImportModule = tableImport->Module;
329-
info->ImportName = tableImport->Field;
330-
info->Flags = WASM_SYMBOL_UNDEFINED;
331-
info->Flags |= WASM_SYMBOL_NO_STRIP;
332-
info->ElementIndex = 0;
333-
LLVM_DEBUG(dbgs() << "Synthesizing symbol for table import: " << info->Name
325+
WasmSymbolInfo info;
326+
info.Name = tableImport->Field;
327+
info.Kind = WASM_SYMBOL_TYPE_TABLE;
328+
info.ImportModule = tableImport->Module;
329+
info.ImportName = tableImport->Field;
330+
info.Flags = WASM_SYMBOL_UNDEFINED;
331+
info.Flags |= WASM_SYMBOL_NO_STRIP;
332+
info.ElementIndex = 0;
333+
LLVM_DEBUG(dbgs() << "Synthesizing symbol for table import: " << info.Name
334334
<< "\n");
335335
const WasmGlobalType *globalType = nullptr;
336336
const WasmSignature *signature = nullptr;
337337
auto *wasmSym =
338-
make<WasmSymbol>(*info, globalType, &tableImport->Table, signature);
338+
make<WasmSymbol>(std::move(info), globalType, &tableImport->Table, signature);
339339
Symbol *sym = createUndefined(*wasmSym, false);
340340
// We're only sure it's a TableSymbol if the createUndefined succeeded.
341341
if (errorCount())

llvm/include/llvm/BinaryFormat/Wasm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,6 @@ struct WasmLinkingData {
471471
uint32_t Version;
472472
std::vector<WasmInitFunc> InitFunctions;
473473
std::vector<StringRef> Comdats;
474-
std::vector<WasmSymbolInfo> SymbolTable;
475474
};
476475

477476
struct WasmSignature {

llvm/include/llvm/Object/Wasm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace object {
3434

3535
class WasmSymbol {
3636
public:
37-
WasmSymbol(const wasm::WasmSymbolInfo &Info,
37+
WasmSymbol(const wasm::WasmSymbolInfo &&Info,
3838
const wasm::WasmGlobalType *GlobalType,
3939
const wasm::WasmTableType *TableType,
4040
const wasm::WasmSignature *Signature)
@@ -43,7 +43,7 @@ class WasmSymbol {
4343
assert(!Signature || Signature->Kind != wasm::WasmSignature::Placeholder);
4444
}
4545

46-
const wasm::WasmSymbolInfo &Info;
46+
const wasm::WasmSymbolInfo Info;
4747
const wasm::WasmGlobalType *GlobalType;
4848
const wasm::WasmTableType *TableType;
4949
const wasm::WasmSignature *Signature;

llvm/lib/Object/WasmObjectFile.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -642,9 +642,7 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
642642
uint32_t Count = readVaruint32(Ctx);
643643
// Clear out any symbol information that was derived from the exports
644644
// section.
645-
LinkingData.SymbolTable.clear();
646645
Symbols.clear();
647-
LinkingData.SymbolTable.reserve(Count);
648646
Symbols.reserve(Count);
649647
StringSet<> SymbolNames;
650648

@@ -844,8 +842,7 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) {
844842
return make_error<GenericBinaryError>("duplicate symbol name " +
845843
Twine(Info.Name),
846844
object_error::parse_failed);
847-
LinkingData.SymbolTable.emplace_back(Info);
848-
Symbols.emplace_back(LinkingData.SymbolTable.back(), GlobalType, TableType,
845+
Symbols.emplace_back(std::move(Info), GlobalType, TableType,
849846
Signature);
850847
LLVM_DEBUG(dbgs() << "Adding symbol: " << Symbols.back() << "\n");
851848
}
@@ -1390,7 +1387,6 @@ Error WasmObjectFile::parseGlobalSection(ReadContext &Ctx) {
13901387
Error WasmObjectFile::parseExportSection(ReadContext &Ctx) {
13911388
uint32_t Count = readVaruint32(Ctx);
13921389
Exports.reserve(Count);
1393-
LinkingData.SymbolTable.reserve(Count);
13941390
Symbols.reserve(Count);
13951391
for (uint32_t I = 0; I < Count; I++) {
13961392
wasm::WasmExport Ex;
@@ -1455,8 +1451,7 @@ Error WasmObjectFile::parseExportSection(ReadContext &Ctx) {
14551451
}
14561452
Exports.push_back(Ex);
14571453
if (Ex.Kind != wasm::WASM_EXTERNAL_MEMORY) {
1458-
LinkingData.SymbolTable.emplace_back(Info);
1459-
Symbols.emplace_back(LinkingData.SymbolTable.back(), GlobalType,
1454+
Symbols.emplace_back(std::move(Info), GlobalType,
14601455
TableType, Signature);
14611456
LLVM_DEBUG(dbgs() << "Adding symbol: " << Symbols.back() << "\n");
14621457
}

llvm/tools/obj2yaml/wasm2yaml.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ WasmDumper::dumpCustomSection(const WasmSection &WasmSec) {
124124
}
125125

126126
uint32_t SymbolIndex = 0;
127-
for (const wasm::WasmSymbolInfo &Symbol : Obj.linkingData().SymbolTable) {
127+
for (const auto &Sym : Obj.symbols()) {
128+
const wasm::WasmSymbolInfo& Symbol = Obj.getWasmSymbol(Sym).Info;
128129
WasmYAML::SymbolInfo Info;
129130
Info.Index = SymbolIndex++;
130131
Info.Kind = static_cast<uint32_t>(Symbol.Kind);

0 commit comments

Comments
 (0)