Introduce side-effect-free as relaxed version of movable.

This commit is contained in:
chriseth
2019-05-16 12:30:05 +02:00
parent d172b9bf11
commit e8a88b13e4
8 changed files with 56 additions and 11 deletions
+21
View File
@@ -208,6 +208,27 @@ bool SemanticInformation::movable(Instruction _instruction)
return true;
}
bool SemanticInformation::sideEffectFree(Instruction _instruction)
{
// These are not really functional.
assertThrow(!isDupInstruction(_instruction) && !isSwapInstruction(_instruction), AssemblyException, "");
InstructionInfo info = instructionInfo(_instruction);
switch (_instruction)
{
// All the instructions that merely read memory are fine
// even though they are marked "sideEffects" in Instructions.cpp
case Instruction::KECCAK256:
case Instruction::MLOAD:
return true;
default:
break;
}
if (info.sideEffects)
return false;
return true;
}
bool SemanticInformation::invalidatesMemory(Instruction _instruction)
{
switch (_instruction)