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>
21 lines
744 B
Plaintext
21 lines
744 B
Plaintext
/// Probe: `shl(256, x)` — LLVM `shl i256 x, 256` is UB; EVM defines SHL with
|
|
/// count >= 256 as 0. revive's `shift_left` adds a switch+phi guard; this
|
|
/// fixture stresses whether it survives O3 const-folding.
|
|
object "ShlOverflowProbe" {
|
|
code {
|
|
let size := datasize("ShlOverflowProbe_deployed")
|
|
codecopy(0, dataoffset("ShlOverflowProbe_deployed"), size)
|
|
return(0, size)
|
|
}
|
|
object "ShlOverflowProbe_deployed" {
|
|
code {
|
|
let tag := calldataload(0)
|
|
let value := calldataload(32)
|
|
// count = 256, obfuscated so revive can't fold pre-LLVM
|
|
let count := shl(8, 1)
|
|
mstore(0, xor(shl(count, value), tag))
|
|
return(0, 32)
|
|
}
|
|
}
|
|
}
|