Skip to content
Open
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 src/compiler/evm_frontend/evm_mir_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2693,6 +2693,18 @@ EVMMirBuilder::handleMLoad(Operand AddrComponents) {

Operand Bytes32Op(MemPtr, EVMType::BYTES32);
Operand Result = convertBytes32ToU256Operand(Bytes32Op);

// Pin loaded values into local variables so the backend cannot reschedule
// the memory reads past later function calls (e.g. CODECOPY / MSTORE) that
// may modify the same memory region. Without this, an MLOAD result that
// stays on the EVM stack across a memory-writing opcode could observe the
// *new* contents instead of the value at the time of the MLOAD.
U256Inst Parts = extractU256Operand(Result);
for (int I = 0; I < static_cast<int>(EVM_ELEMENTS_COUNT); ++I) {
Parts[I] = protectUnsafeValue(Parts[I], I64Type);
}
Result = Operand(Parts, EVMType::UINT256);

#ifdef ZEN_ENABLE_EVM_GAS_REGISTER
reloadGasFromMemory();
#endif
Expand Down
Loading