mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-10-20 18:56:17 +00:00
Existing test coverage didn't catch a signed remainder overflow semantics edge case behavior where at least one the operators is being constant folded by LLVM instead of solc. This PR fixes the SREM translation bug and adds missing test coverage for division ops with constants. Closes #524 --------- Signed-off-by: xermicus <cyrill@parity.io>
19 lines
565 B
Plaintext
19 lines
565 B
Plaintext
/// Probe: `shr(256, x)` — LLVM `lshr i256 x, 256` is UB; EVM defines SHR with
|
|
/// count >= 256 as 0.
|
|
object "ShrOverflowProbe" {
|
|
code {
|
|
let size := datasize("ShrOverflowProbe_deployed")
|
|
codecopy(0, dataoffset("ShrOverflowProbe_deployed"), size)
|
|
return(0, size)
|
|
}
|
|
object "ShrOverflowProbe_deployed" {
|
|
code {
|
|
let tag := calldataload(0)
|
|
let value := calldataload(32)
|
|
let count := shl(8, 1)
|
|
mstore(0, xor(shr(count, value), tag))
|
|
return(0, 32)
|
|
}
|
|
}
|
|
}
|