Skip to content

Commit

Permalink
[MC] Simplify WasmObjectWriter
Browse files Browse the repository at this point in the history
and make it fit well with the future when MCFragment content is
out-of-line.
  • Loading branch information
MaskRay committed Dec 22, 2024
1 parent 6c42d0d commit 2cf3d05
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions llvm/lib/MC/WasmObjectWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,12 +734,9 @@ static void addData(SmallVectorImpl<char> &DataBytes,
DataBytes.insert(DataBytes.end(), Fill->getValueSize() * NumValues,
Fill->getValue());
} else if (auto *LEB = dyn_cast<MCLEBFragment>(&Frag)) {
const SmallVectorImpl<char> &Contents = LEB->getContents();
llvm::append_range(DataBytes, Contents);
llvm::append_range(DataBytes, LEB->getContents());
} else {
const auto &DataFrag = cast<MCDataFragment>(Frag);
const SmallVectorImpl<char> &Contents = DataFrag.getContents();
llvm::append_range(DataBytes, Contents);
llvm::append_range(DataBytes, cast<MCDataFragment>(Frag).getContents());
}
}

Expand Down Expand Up @@ -1896,14 +1893,7 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
report_fatal_error("invalid .init_array section priority");
}
const auto &DataFrag = cast<MCDataFragment>(Frag);
const SmallVectorImpl<char> &Contents = DataFrag.getContents();
for (const uint8_t *
P = (const uint8_t *)Contents.data(),
*End = (const uint8_t *)Contents.data() + Contents.size();
P != End; ++P) {
if (*P != 0)
report_fatal_error("non-symbolic data in .init_array section");
}
assert(llvm::all_of(DataFrag.getContents(), [](char C) { return !C; }));
for (const MCFixup &Fixup : DataFrag.getFixups()) {
assert(Fixup.getKind() ==
MCFixup::getKindForSize(is64Bit() ? 8 : 4, false));
Expand Down

0 comments on commit 2cf3d05

Please sign in to comment.