Skip to content

Commit

Permalink
fixup! CheerpWasmWriter - Support for atomics
Browse files Browse the repository at this point in the history
  • Loading branch information
Maqrkk committed Feb 5, 2024
1 parent a4ed104 commit 1e0c724
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions llvm/lib/CheerpWriter/CheerpWasmWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3676,6 +3676,14 @@ bool CheerpWasmWriter::compileInlineInstruction(WasmBuffer& code, const Instruct
encodeInst(WasmThreadsU32U32Opcode::I64_ATOMIC_RMW_CMPXCHG, 0x3, offset, code);
else
llvm::report_fatal_error("Atomic cmpxchg only allowed on integers");
// Do not duplicate the result and render the comparison if this instruction has no uses.
// We do however have to push a garbage constant onto the stack, because
// compileInstructionAndSet will drop 2 times (since there are 2 registers for this).
if (I.use_empty())
{
encodeInst(WasmS32Opcode::I32_CONST, 0, code);
break;
}
// Now compile the second part of this two-register operation, the comparison between
// the original (loaded) value and the comparison value.
uint32_t idx = registerize.getRegisterId(&ai, 0, edgeContext);
Expand Down

0 comments on commit 1e0c724

Please sign in to comment.