Added a function SemanticInformation::readsMemory

Returns `true` if the instruction reads from memory. Different from `SemanticInformation::memory(..)
== SideEffects::Read` because some builtins read and write memory at the same time.
This commit is contained in:
hrkrshnn 2021-03-29 18:40:00 +02:00
parent 3c9a45987a
commit 46da64cd7e
2 changed files with 35 additions and 0 deletions

View File

@ -268,6 +268,37 @@ SemanticInformation::Effect SemanticInformation::memory(Instruction _instruction
}
}
bool SemanticInformation::readsMemory(Instruction const _instruction)
{
switch (_instruction)
{
// Instructions that only read from memory
case Instruction::CREATE:
case Instruction::CREATE2:
case Instruction::KECCAK256:
case Instruction::MLOAD:
case Instruction::MSIZE:
case Instruction::RETURN:
case Instruction::REVERT:
case Instruction::LOG0:
case Instruction::LOG1:
case Instruction::LOG2:
case Instruction::LOG3:
case Instruction::LOG4:
// Instructions that read and write from memory
case Instruction::CODECOPY:
case Instruction::CALL:
case Instruction::CALLCODE:
case Instruction::DELEGATECALL:
case Instruction::STATICCALL:
return true;
default:
return false;
}
}
bool SemanticInformation::movableApartFromEffects(Instruction _instruction)
{
switch (_instruction)

View File

@ -79,6 +79,10 @@ struct SemanticInformation
/// msize instruction.
static bool canBeRemovedIfNoMSize(Instruction _instruction);
static Effect memory(Instruction _instruction);
/// Returns `true` if the instruction reads from memory. Different from
/// `SemanticInformation::memory(..) == SideEffects::Read` because some builtins read and write
/// memory at the same time.
static bool readsMemory(Instruction const _instruction);
static Effect storage(Instruction _instruction);
static Effect otherState(Instruction _instruction);
static bool invalidInPureFunctions(Instruction _instruction);