mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-10-27 14:09:54 +00:00
Fix optimization specific SREM edge case (#527)
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>
This commit is contained in:
1 parent
62a62770e3
commit
40e97d11eb
23 files changed
+1336
-21
No files matched your search
@@ -0,0 +1,20 @@
|
||||
/// 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user