Skip to content

[WebAssembly] Support parsing .lto_set_conditional #126546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions llvm/lib/MC/WasmObjectWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1785,6 +1785,18 @@ uint64_t WasmObjectWriter::writeOneObject(MCAssembler &Asm,
WS.setIndex(InvalidIndex);
continue;
}
// In bitcode generated by split-LTO-unit mode in ThinLTO, these lines can
// appear:
// module asm ".lto_set_conditional symbolA,symbolA.[moduleId]"
// ...
// (Here [moduleId] will be replaced by a real module hash ID)
//
// Here the original symbol (symbolA here) has been renamed to the new name
// created by attaching its module ID, so the original symbol does not
// appear in the bitcode anymore, and thus not in DataLocations. We should
// ignore them.
if (WS.isData() && WS.isDefined() && !DataLocations.count(&WS))
continue;
LLVM_DEBUG(dbgs() << "adding to symtab: " << WS << "\n");

uint32_t Flags = 0;
Expand Down
8 changes: 8 additions & 0 deletions llvm/test/MC/WebAssembly/lto-set-conditional.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# RUN: llvm-mc -triple=wasm32-unknown-unknown

# Tests if `.lto_set_conditional` directives are parsed without crashing.
.lto_set_conditional a, a.new
.type a.new,@function
a.new:
.functype a.new () -> ()
end_function