[WebAssembly] Move checking of InputSegment comdat group earlier

This should also fixe an unused varaible warning in the realeae
build.

llvm-svn: 322440
This commit is contained in:
Sam Clegg 2018-01-13 15:44:54 +00:00
parent 4158eff0f8
commit 7c11dbf5b0
2 changed files with 8 additions and 6 deletions

View File

@ -25,12 +25,18 @@ public:
void addInputSegment(InputSegment *Segment) {
Alignment = std::max(Alignment, Segment->getAlignment());
if (InputSegments.empty())
Comdat = Segment->getComdat();
else
assert(Comdat == Segment->getComdat());
InputSegments.push_back(Segment);
Size = llvm::alignTo(Size, Segment->getAlignment());
Segment->setOutputSegment(this, Size);
Size += Segment->getSize();
}
StringRef getComdat() const { return Comdat; }
uint32_t getSectionOffset() const { return SectionOffset; }
void setSectionOffset(uint32_t Offset) { SectionOffset = Offset; }
@ -47,6 +53,7 @@ public:
std::string Header;
private:
StringRef Comdat;
uint32_t SectionOffset = 0;
};

View File

@ -439,12 +439,7 @@ void Writer::createLinkingSection() {
ComdatEntry{WASM_COMDAT_FUNCTION, F->getOutputIndex()});
}
for (uint32_t I = 0; I < Segments.size(); ++I) {
const auto &InputSegments = Segments[I]->InputSegments;
if (InputSegments.empty())
continue;
StringRef Comdat = InputSegments[0]->getComdat();
for (const InputSegment *IS : InputSegments)
assert(IS->getComdat() == Comdat);
StringRef Comdat = Segments[I]->getComdat();
if (!Comdat.empty())
Comdats[Comdat].emplace_back(ComdatEntry{WASM_COMDAT_DATA, I});
}