Index: lib/MC/WasmObjectWriter.cpp =================================================================== --- lib/MC/WasmObjectWriter.cpp +++ lib/MC/WasmObjectWriter.cpp @@ -194,15 +194,6 @@ #endif class WasmObjectWriter : public MCObjectWriter { - /// Helper struct for containing some precomputed information on symbols. - struct WasmSymbolData { - const MCSymbolWasm *Symbol; - StringRef Name; - - // Support lexicographic sorting. - bool operator<(const WasmSymbolData &RHS) const { return Name < RHS.Name; } - }; - /// The target specific Wasm writer instance. std::unique_ptr TargetObjectWriter; @@ -1121,6 +1112,7 @@ if (cast(Sec).getSectionName().startswith(".init_array")) continue; + uint32_t SegmentIndex = DataSegments.size(); DataSize = alignTo(DataSize, Section.getAlignment()); DataSegments.emplace_back(); WasmDataSegment &Segment = DataSegments.back(); @@ -1135,8 +1127,7 @@ if (const MCSymbolWasm *C = Section.getGroup()) { Comdats[C->getName()].emplace_back( - WasmComdatEntry{wasm::WASM_COMDAT_DATA, - static_cast(DataSegments.size()) - 1}); + WasmComdatEntry{wasm::WASM_COMDAT_DATA, SegmentIndex}); } } @@ -1149,8 +1140,9 @@ const auto &WS = static_cast(S); DEBUG(dbgs() << "MCSymbol: '" << S << "'" - << " isDefined=" << S.isDefined() << " isExternal=" - << S.isExternal() << " isTemporary=" << S.isTemporary() + << " isDefined=" << S.isDefined() + << " isExternal=" << S.isExternal() + << " isTemporary=" << S.isTemporary() << " isFunction=" << WS.isFunction() << " isWeak=" << WS.isWeak() << " isHidden=" << WS.isHidden() @@ -1292,7 +1284,8 @@ uint32_t SymbolIndex = SymbolIndices[WS]; uint32_t TableIndex = TableElems.size() + kInitialTableOffset; if (TableIndices.try_emplace(WS, TableIndex).second) { - DEBUG(dbgs() << " -> adding to table: " << TableElems.size() << "\n"); + DEBUG(dbgs() << " -> adding " << WS->getName() << " to table: " << + TableElems.size() << "\n"); TableElems.push_back(SymbolIndex); } };