diff options
author | Nicholas Wilson <nicholas@nicholaswilson.me.uk> | 2018-03-14 15:44:45 +0000 |
---|---|---|
committer | Nicholas Wilson <nicholas@nicholaswilson.me.uk> | 2018-03-14 15:44:45 +0000 |
commit | 027b9357a8f23fdf9b0ab013ff27eaf9ec080961 (patch) | |
tree | bc31d1145f551ae972d0b2875b3b30cb8482a442 /llvm/tools/obj2yaml/wasm2yaml.cpp | |
parent | bf1638daa81cca23073649ec57b21f94c8a57533 (diff) | |
download | llvm-027b9357a8f23fdf9b0ab013ff27eaf9ec080961.zip llvm-027b9357a8f23fdf9b0ab013ff27eaf9ec080961.tar.gz llvm-027b9357a8f23fdf9b0ab013ff27eaf9ec080961.tar.bz2 |
[WebAssembly] Identify COMDATs by index rather than string. NFC
This will enable an optimisation in LLD.
Differential Revision: https://reviews.llvm.org/D44343
llvm-svn: 327522
Diffstat (limited to 'llvm/tools/obj2yaml/wasm2yaml.cpp')
-rw-r--r-- | llvm/tools/obj2yaml/wasm2yaml.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/llvm/tools/obj2yaml/wasm2yaml.cpp b/llvm/tools/obj2yaml/wasm2yaml.cpp index 1abd7b8..29bf9b5 100644 --- a/llvm/tools/obj2yaml/wasm2yaml.cpp +++ b/llvm/tools/obj2yaml/wasm2yaml.cpp @@ -62,15 +62,12 @@ std::unique_ptr<WasmYAML::CustomSection> WasmDumper::dumpCustomSection(const Was CustomSec = std::move(NameSec); } else if (WasmSec.Name == "linking") { std::unique_ptr<WasmYAML::LinkingSection> LinkingSec = make_unique<WasmYAML::LinkingSection>(); - std::map<StringRef,size_t> ComdatIndexes; - for (StringRef ComdatName : Obj.comdats()) { - ComdatIndexes[ComdatName] = LinkingSec->Comdats.size(); + ArrayRef<StringRef> Comdats = Obj.linkingData().Comdats; + for (StringRef ComdatName : Comdats) LinkingSec->Comdats.emplace_back(WasmYAML::Comdat{ComdatName, {}}); - } for (auto &Func : Obj.functions()) { - if (!Func.Comdat.empty()) { - auto &Comdat = LinkingSec->Comdats[ComdatIndexes[Func.Comdat]]; - Comdat.Entries.emplace_back( + if (Func.Comdat != UINT32_MAX) { + LinkingSec->Comdats[Func.Comdat].Entries.emplace_back( WasmYAML::ComdatEntry{wasm::WASM_COMDAT_FUNCTION, Func.Index}); } } @@ -84,9 +81,8 @@ std::unique_ptr<WasmYAML::CustomSection> WasmDumper::dumpCustomSection(const Was SegmentInfo.Flags = Segment.Data.Flags; LinkingSec->SegmentInfos.push_back(SegmentInfo); } - if (!Segment.Data.Comdat.empty()) { - auto &Comdat = LinkingSec->Comdats[ComdatIndexes[Segment.Data.Comdat]]; - Comdat.Entries.emplace_back( + if (Segment.Data.Comdat != UINT32_MAX) { + LinkingSec->Comdats[Segment.Data.Comdat].Entries.emplace_back( WasmYAML::ComdatEntry{wasm::WASM_COMDAT_DATA, SegmentIndex}); } SegmentIndex++; |