Refactor SideEffects struct

This commit is contained in:
Harikrishnan Mulackal 2020-07-01 15:37:00 +05:30
parent 58bfe0b0d2
commit 3cbe65e4f3
24 changed files with 290 additions and 126 deletions

View File

@ -155,8 +155,10 @@ KnownState::StoreOperation KnownState::feedItem(AssemblyItem const& _item, bool
);
break;
default:
bool invMem = SemanticInformation::invalidatesMemory(_item.instruction());
bool invStor = SemanticInformation::invalidatesStorage(_item.instruction());
bool invMem =
SemanticInformation::memory(_item.instruction()) == SemanticInformation::Write;
bool invStor =
SemanticInformation::storage(_item.instruction()) == SemanticInformation::Write;
// We could be a bit more fine-grained here (CALL only invalidates part of
// memory, etc), but we do not for now.
if (invMem)
@ -420,4 +422,3 @@ KnownState::Id KnownState::tagUnion(set<u256> _tags)
return id;
}
}

View File

@ -233,7 +233,7 @@ bool SemanticInformation::movable(Instruction _instruction)
return true;
}
bool SemanticInformation::sideEffectFree(Instruction _instruction)
bool SemanticInformation::canBeRemoved(Instruction _instruction)
{
// These are not really functional.
assertThrow(!isDupInstruction(_instruction) && !isSwapInstruction(_instruction), AssemblyException, "");
@ -241,15 +241,15 @@ bool SemanticInformation::sideEffectFree(Instruction _instruction)
return !instructionInfo(_instruction).sideEffects;
}
bool SemanticInformation::sideEffectFreeIfNoMSize(Instruction _instruction)
bool SemanticInformation::canBeRemovedIfNoMSize(Instruction _instruction)
{
if (_instruction == Instruction::KECCAK256 || _instruction == Instruction::MLOAD)
return true;
else
return sideEffectFree(_instruction);
return canBeRemoved(_instruction);
}
bool SemanticInformation::invalidatesMemory(Instruction _instruction)
SemanticInformation::Effect SemanticInformation::memory(Instruction _instruction)
{
switch (_instruction)
{
@ -263,13 +263,47 @@ bool SemanticInformation::invalidatesMemory(Instruction _instruction)
case Instruction::CALLCODE:
case Instruction::DELEGATECALL:
case Instruction::STATICCALL:
return true;
return SemanticInformation::Write;
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:
return SemanticInformation::Read;
default:
return false;
return SemanticInformation::None;
}
}
bool SemanticInformation::invalidatesStorage(Instruction _instruction)
bool SemanticInformation::movableApartFromEffects(Instruction _instruction)
{
switch (_instruction)
{
case Instruction::EXTCODEHASH:
case Instruction::EXTCODESIZE:
case Instruction::RETURNDATASIZE:
case Instruction::BALANCE:
case Instruction::SELFBALANCE:
case Instruction::SLOAD:
case Instruction::KECCAK256:
case Instruction::MLOAD:
return true;
default:
return movable(_instruction);
}
}
SemanticInformation::Effect SemanticInformation::storage(Instruction _instruction)
{
switch (_instruction)
{
@ -279,9 +313,45 @@ bool SemanticInformation::invalidatesStorage(Instruction _instruction)
case Instruction::CREATE:
case Instruction::CREATE2:
case Instruction::SSTORE:
return true;
return SemanticInformation::Write;
case Instruction::SLOAD:
case Instruction::STATICCALL:
return SemanticInformation::Read;
default:
return false;
return SemanticInformation::None;
}
}
SemanticInformation::Effect SemanticInformation::otherState(Instruction _instruction)
{
switch (_instruction)
{
case Instruction::CALL:
case Instruction::CALLCODE:
case Instruction::DELEGATECALL:
case Instruction::CREATE:
case Instruction::CREATE2:
case Instruction::SELFDESTRUCT:
case Instruction::STATICCALL: // because it can affect returndatasize
// Strictly speaking, log0, .., log4 writes to the state, but the EVM cannot read it, so they
// are just marked as having 'other side effects.'
return SemanticInformation::Write;
case Instruction::EXTCODESIZE:
case Instruction::EXTCODEHASH:
case Instruction::RETURNDATASIZE:
case Instruction::BALANCE:
case Instruction::SELFBALANCE:
case Instruction::RETURNDATACOPY:
case Instruction::EXTCODECOPY:
// PC and GAS are specifically excluded here. Instructions such as CALLER, CALLVALUE,
// ADDRESS are excluded because they cannot change during execution.
return SemanticInformation::Read;
default:
return SemanticInformation::None;
}
}

View File

@ -36,6 +36,15 @@ class AssemblyItem;
*/
struct SemanticInformation
{
/// Corresponds to the effect that a YUL-builtin has on a generic data location (storage, memory
/// and other blockchain state).
enum Effect
{
None,
Read,
Write
};
/// @returns true if the given items starts a new block for common subexpression analysis.
/// @param _msizeImportant if false, consider an operation non-breaking if its only side-effect is that it modifies msize.
static bool breaksCSEAnalysisBlock(AssemblyItem const& _item, bool _msizeImportant);
@ -57,20 +66,23 @@ struct SemanticInformation
/// without altering the semantics. This means it cannot depend on storage or memory,
/// cannot have any side-effects, but it can depend on a call-constant state of the blockchain.
static bool movable(Instruction _instruction);
/// If true, the expressions in this code can be moved or copied (together with their arguments)
/// across control flow branches and instructions as long as these instructions' 'effects' do
/// not influence the 'effects' of the aforementioned expressions.
static bool movableApartFromEffects(Instruction _instruction);
/// @returns true if the instruction can be removed without changing the semantics.
/// This does not mean that it has to be deterministic or retrieve information from
/// somewhere else than purely the values of its arguments.
static bool sideEffectFree(Instruction _instruction);
static bool canBeRemoved(Instruction _instruction);
/// @returns true if the instruction can be removed without changing the semantics.
/// This does not mean that it has to be deterministic or retrieve information from
/// somewhere else than purely the values of its arguments.
/// If true, the instruction is still allowed to influence the value returned by the
/// msize instruction.
static bool sideEffectFreeIfNoMSize(Instruction _instruction);
/// @returns true if the given instruction modifies memory.
static bool invalidatesMemory(Instruction _instruction);
/// @returns true if the given instruction modifies storage (even indirectly).
static bool invalidatesStorage(Instruction _instruction);
static bool canBeRemovedIfNoMSize(Instruction _instruction);
static Effect memory(Instruction _instruction);
static Effect storage(Instruction _instruction);
static Effect otherState(Instruction _instruction);
static bool invalidInPureFunctions(Instruction _instruction);
static bool invalidInViewFunctions(Instruction _instruction);
};

View File

@ -18,6 +18,7 @@
#pragma once
#include <algorithm>
#include <set>
namespace solidity::yul
@ -30,6 +31,20 @@ namespace solidity::yul
*/
struct SideEffects
{
/// Corresponds to the effect that a Yul-builtin has on a generic data location (storage, memory
/// and other blockchain state).
enum Effect
{
None,
Read,
Write
};
friend Effect operator+(Effect const& _a, Effect const& _b)
{
return static_cast<Effect>(std::max(static_cast<int>(_a), static_cast<int>(_b)));
}
/// If true, expressions in this code can be freely moved and copied without altering the
/// semantics.
/// At statement level, it means that functions containing this code can be
@ -38,22 +53,34 @@ struct SideEffects
/// This means it cannot depend on storage or memory, cannot have any side-effects,
/// but it can depend on state that is constant across an EVM-call.
bool movable = true;
/// If true, the expressions in this code can be moved or copied (together with their arguments)
/// across control flow branches and instructions as long as these instructions' 'effects' do
/// not influence the 'effects' of the aforementioned expressions.
bool movableApartFromEffects = true;
/// If true, the code can be removed without changing the semantics.
bool sideEffectFree = true;
bool canBeRemoved = true;
/// If true, the code can be removed without changing the semantics as long as
/// the whole program does not contain the msize instruction.
bool sideEffectFreeIfNoMSize = true;
/// If false, storage is guaranteed to be unchanged by the code under all
/// circumstances.
bool invalidatesStorage = false;
/// If false, memory is guaranteed to be unchanged by the code under all
/// circumstances.
bool invalidatesMemory = false;
bool canBeRemovedIfNoMSize = true;
/// If false, the code calls a for-loop or a recursive function, and therefore potentially loops
/// infinitely. All builtins are set to true by default, even `invalid()`.
bool cannotLoop = true;
/// Can write, read or have no effect on the blockchain state, when the value of `otherState` is
/// `Write`, `Read` or `None` respectively.
Effect otherState = None;
/// Can write, read or have no effect on storage, when the value of `storage` is `Write`, `Read`
/// or `None` respectively. When the value is `Write`, the expression can invalidate storage,
/// potentially indirectly through external calls.
Effect storage = None;
/// Can write, read or have no effect on memory, when the value of `memory` is `Write`, `Read`
/// or `None` respectively. Note that, when the value is `Read`, the expression can have an
/// effect on `msize()`.
Effect memory = None;
/// @returns the worst-case side effects.
static SideEffects worst()
{
return SideEffects{false, false, false, true, true};
return SideEffects{false, false, false, false, false, Write, Write, Write};
}
/// @returns the combined side effects of two pieces of code.
@ -61,10 +88,13 @@ struct SideEffects
{
return SideEffects{
movable && _other.movable,
sideEffectFree && _other.sideEffectFree,
sideEffectFreeIfNoMSize && _other.sideEffectFreeIfNoMSize,
invalidatesStorage || _other.invalidatesStorage,
invalidatesMemory || _other.invalidatesMemory
movableApartFromEffects && _other.movableApartFromEffects,
canBeRemoved && _other.canBeRemoved,
canBeRemovedIfNoMSize && _other.canBeRemovedIfNoMSize,
cannotLoop && _other.cannotLoop,
otherState + _other.otherState,
storage + _other.storage,
memory + _other.memory
};
}
@ -79,10 +109,13 @@ struct SideEffects
{
return
movable == _other.movable &&
sideEffectFree == _other.sideEffectFree &&
sideEffectFreeIfNoMSize == _other.sideEffectFreeIfNoMSize &&
invalidatesStorage == _other.invalidatesStorage &&
invalidatesMemory == _other.invalidatesMemory;
movableApartFromEffects == _other.movableApartFromEffects &&
canBeRemoved == _other.canBeRemoved &&
canBeRemovedIfNoMSize == _other.canBeRemovedIfNoMSize &&
cannotLoop == _other.cannotLoop &&
otherState == _other.otherState &&
storage == _other.storage &&
memory == _other.memory;
}
};

View File

@ -190,7 +190,7 @@ map<YulString, BuiltinFunctionForEVM> createBuiltins(langutil::EVMVersion _evmVe
"datacopy",
3,
0,
SideEffects{false, false, false, false, true},
SideEffects{false, true, false, false, true, SideEffects::None, SideEffects::None, SideEffects::Write},
{},
[](
FunctionCall const& _call,
@ -206,7 +206,7 @@ map<YulString, BuiltinFunctionForEVM> createBuiltins(langutil::EVMVersion _evmVe
"setimmutable",
2,
0,
SideEffects{false, false, false, false, true},
SideEffects{false, false, false, false, true, SideEffects::None, SideEffects::None, SideEffects::Write},
{LiteralKind::String, std::nullopt},
[](
FunctionCall const& _call,
@ -281,12 +281,20 @@ EVMDialect const& EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion _
SideEffects EVMDialect::sideEffectsOfInstruction(evmasm::Instruction _instruction)
{
auto translate = [](evmasm::SemanticInformation::Effect _e) -> SideEffects::Effect
{
return static_cast<SideEffects::Effect>(_e);
};
return SideEffects{
evmasm::SemanticInformation::movable(_instruction),
evmasm::SemanticInformation::sideEffectFree(_instruction),
evmasm::SemanticInformation::sideEffectFreeIfNoMSize(_instruction),
evmasm::SemanticInformation::invalidatesStorage(_instruction),
evmasm::SemanticInformation::invalidatesMemory(_instruction)
evmasm::SemanticInformation::movableApartFromEffects(_instruction),
evmasm::SemanticInformation::canBeRemoved(_instruction),
evmasm::SemanticInformation::canBeRemovedIfNoMSize(_instruction),
true, // cannotLoop
translate(evmasm::SemanticInformation::otherState(_instruction)),
translate(evmasm::SemanticInformation::storage(_instruction)),
translate(evmasm::SemanticInformation::memory(_instruction)),
};
}

View File

@ -86,27 +86,34 @@ WasmDialect::WasmDialect()
addFunction("i64.extend_i32_u", {i32}, {i64});
addFunction("i32.store", {i32, i32}, {}, false);
m_functions["i32.store"_yulstring].sideEffects.invalidatesStorage = false;
m_functions["i32.store"_yulstring].sideEffects.storage = SideEffects::None;
m_functions["i32.store"_yulstring].sideEffects.otherState = SideEffects::None;
addFunction("i64.store", {i32, i64}, {}, false);
m_functions["i64.store"_yulstring].sideEffects.invalidatesStorage = false;
// TODO: add i32.store16, i64.store8, i64.store16, i64.store32
m_functions["i64.store"_yulstring].sideEffects.storage = SideEffects::None;
m_functions["i64.store"_yulstring].sideEffects.otherState = SideEffects::None;
addFunction("i32.store8", {i32, i32}, {}, false);
m_functions["i32.store8"_yulstring].sideEffects.invalidatesStorage = false;
m_functions["i32.store8"_yulstring].sideEffects.storage = SideEffects::None;
m_functions["i32.store8"_yulstring].sideEffects.otherState = SideEffects::None;
addFunction("i64.store8", {i32, i64}, {}, false);
m_functions["i64.store8"_yulstring].sideEffects.invalidatesStorage = false;
m_functions["i64.store8"_yulstring].sideEffects.storage = SideEffects::None;
m_functions["i64.store8"_yulstring].sideEffects.otherState = SideEffects::None;
addFunction("i32.load", {i32}, {i32}, false);
m_functions["i32.load"_yulstring].sideEffects.invalidatesStorage = false;
m_functions["i32.load"_yulstring].sideEffects.invalidatesMemory = false;
m_functions["i32.load"_yulstring].sideEffects.sideEffectFree = true;
m_functions["i32.load"_yulstring].sideEffects.sideEffectFreeIfNoMSize = true;
m_functions["i32.load"_yulstring].sideEffects.canBeRemoved = true;
m_functions["i32.load"_yulstring].sideEffects.canBeRemovedIfNoMSize = true;
m_functions["i32.load"_yulstring].sideEffects.storage = SideEffects::None;
m_functions["i32.load"_yulstring].sideEffects.memory = SideEffects::Read;
m_functions["i32.load"_yulstring].sideEffects.otherState = SideEffects::None;
addFunction("i64.load", {i32}, {i64}, false);
m_functions["i64.load"_yulstring].sideEffects.invalidatesStorage = false;
m_functions["i64.load"_yulstring].sideEffects.invalidatesMemory = false;
m_functions["i64.load"_yulstring].sideEffects.sideEffectFree = true;
m_functions["i64.load"_yulstring].sideEffects.sideEffectFreeIfNoMSize = true;
// TODO: add i32.load8, i32.load16, i64.load8, i64.load16, i64.load32
m_functions["i64.load"_yulstring].sideEffects.canBeRemoved = true;
m_functions["i64.load"_yulstring].sideEffects.canBeRemovedIfNoMSize = true;
m_functions["i64.load"_yulstring].sideEffects.storage = SideEffects::None;
m_functions["i64.load"_yulstring].sideEffects.memory = SideEffects::Read;
m_functions["i64.load"_yulstring].sideEffects.otherState = SideEffects::None;
// Drop is actually overloaded for all types, but Yul does not support that.
// Because of that, we introduce "i32.drop" and "i64.drop".
@ -115,8 +122,9 @@ WasmDialect::WasmDialect()
addFunction("nop", {}, {});
addFunction("unreachable", {}, {}, false);
m_functions["unreachable"_yulstring].sideEffects.invalidatesStorage = false;
m_functions["unreachable"_yulstring].sideEffects.invalidatesMemory = false;
m_functions["unreachable"_yulstring].sideEffects.storage = SideEffects::None;
m_functions["unreachable"_yulstring].sideEffects.memory = SideEffects::None;
m_functions["unreachable"_yulstring].sideEffects.otherState = SideEffects::None;
m_functions["unreachable"_yulstring].controlFlowSideEffects.terminates = true;
m_functions["unreachable"_yulstring].controlFlowSideEffects.reverts = true;
@ -219,10 +227,24 @@ void WasmDialect::addEthereumExternals()
f.returns.emplace_back(YulString(p));
// TODO some of them are side effect free.
f.sideEffects = SideEffects::worst();
f.sideEffects.cannotLoop = true;
f.sideEffects.movableApartFromEffects = !ext.controlFlowSideEffects.terminates;
f.controlFlowSideEffects = ext.controlFlowSideEffects;
f.isMSize = false;
f.sideEffects.invalidatesStorage = (ext.name == "storageStore");
f.literalArguments.clear();
static set<string> const writesToStorage{
"storageStore",
"call",
"callcode",
"callDelegate",
"create"
};
static set<string> const readsStorage{"storageLoad", "callStatic"};
if (readsStorage.count(ext.name))
f.sideEffects.storage = SideEffects::Read;
else if (!writesToStorage.count(ext.name))
f.sideEffects.storage = SideEffects::None;
}
}
@ -241,6 +263,9 @@ void WasmDialect::addFunction(
yulAssert(_returns.size() <= 1, "The Wasm 1.0 specification only allows up to 1 return value.");
f.returns = std::move(_returns);
f.sideEffects = _movable ? SideEffects{} : SideEffects::worst();
f.sideEffects.cannotLoop = true;
// TODO This should be improved when LoopInvariantCodeMotion gets specialized for WASM
f.sideEffects.movableApartFromEffects = _movable;
f.isMSize = false;
f.literalArguments = std::move(_literalArguments);
}

View File

@ -106,8 +106,9 @@ map<YulString, SideEffects> SideEffectsPropagator::sideEffects(
for (auto const& function: _directCallGraph.functionsWithLoops + _directCallGraph.recursiveFunctions())
{
ret[function].movable = false;
ret[function].sideEffectFree = false;
ret[function].sideEffectFreeIfNoMSize = false;
ret[function].canBeRemoved = false;
ret[function].canBeRemovedIfNoMSize = false;
ret[function].cannotLoop = false;
}
for (auto const& call: _directCallGraph.functionCalls)

View File

@ -59,16 +59,17 @@ public:
void operator()(FunctionCall const& _functionCall) override;
bool movable() const { return m_sideEffects.movable; }
bool sideEffectFree(bool _allowMSizeModification = false) const
bool canBeRemoved(bool _allowMSizeModification = false) const
{
if (_allowMSizeModification)
return sideEffectFreeIfNoMSize();
return m_sideEffects.canBeRemovedIfNoMSize;
else
return m_sideEffects.sideEffectFree;
return m_sideEffects.canBeRemoved;
}
bool sideEffectFreeIfNoMSize() const { return m_sideEffects.sideEffectFreeIfNoMSize; }
bool invalidatesStorage() const { return m_sideEffects.invalidatesStorage; }
bool invalidatesMemory() const { return m_sideEffects.invalidatesMemory; }
bool cannotLoop() const { return m_sideEffects.cannotLoop; }
bool invalidatesStorage() const { return m_sideEffects.storage == SideEffects::Write; }
bool invalidatesMemory() const { return m_sideEffects.memory == SideEffects::Write; }
private:
Dialect const& m_dialect;

View File

@ -93,7 +93,7 @@ void UnusedPruner::operator()(Block& _block)
statement = Block{std::move(varDecl.location), {}};
else if (
SideEffectsCollector(m_dialect, *varDecl.value, m_functionSideEffects).
sideEffectFree(m_allowMSizeOptimization)
canBeRemoved(m_allowMSizeOptimization)
)
{
subtractReferences(ReferencesCounter::countReferences(*varDecl.value));
@ -112,7 +112,7 @@ void UnusedPruner::operator()(Block& _block)
ExpressionStatement& exprStmt = std::get<ExpressionStatement>(statement);
if (
SideEffectsCollector(m_dialect, exprStmt.expression, m_functionSideEffects).
sideEffectFree(m_allowMSizeOptimization)
canBeRemoved(m_allowMSizeOptimization)
)
{
subtractReferences(ReferencesCounter::countReferences(exprStmt.expression));

View File

@ -49,14 +49,27 @@ string toString(SideEffects const& _sideEffects)
vector<string> ret;
if (_sideEffects.movable)
ret.emplace_back("movable");
if (_sideEffects.sideEffectFree)
ret.emplace_back("sideEffectFree");
if (_sideEffects.sideEffectFreeIfNoMSize)
ret.emplace_back("sideEffectFreeIfNoMSize");
if (_sideEffects.invalidatesStorage)
ret.emplace_back("invalidatesStorage");
if (_sideEffects.invalidatesMemory)
ret.emplace_back("invalidatesMemory");
if (_sideEffects.movableApartFromEffects)
ret.emplace_back("movable apart from effects");
if (_sideEffects.canBeRemoved)
ret.emplace_back("can be removed");
if (_sideEffects.canBeRemovedIfNoMSize)
ret.emplace_back("can be removed if no msize");
if (!_sideEffects.cannotLoop)
ret.emplace_back("can loop");
if (_sideEffects.otherState == SideEffects::Write)
ret.emplace_back("writes other state");
else if (_sideEffects.otherState == SideEffects::Read)
ret.emplace_back("reads other state");
if (_sideEffects.storage == SideEffects::Write)
ret.emplace_back("writes storage");
else if (_sideEffects.storage == SideEffects::Read)
ret.emplace_back("reads storage");
if (_sideEffects.memory == SideEffects::Write)
ret.emplace_back("writes memory");
else if (_sideEffects.memory == SideEffects::Read)
ret.emplace_back("reads memory");
return joinHumanReadable(ret);
}
}

View File

@ -4,7 +4,7 @@
function c() { b() }
}
// ----
// : movable, sideEffectFree, sideEffectFreeIfNoMSize
// a:
// b:
// c:
// : movable, movable apart from effects, can be removed, can be removed if no msize
// a: movable apart from effects, can loop
// b: movable apart from effects, can loop
// c: movable apart from effects, can loop

View File

@ -3,6 +3,6 @@
function b() { a() }
}
// ----
// : movable, sideEffectFree, sideEffectFreeIfNoMSize
// a:
// b:
// : movable, movable apart from effects, can be removed, can be removed if no msize
// a: movable apart from effects, can loop
// b: movable apart from effects, can loop

View File

@ -1,4 +1,4 @@
{
}
// ----
// : movable, sideEffectFree, sideEffectFreeIfNoMSize
// : movable, movable apart from effects, can be removed, can be removed if no msize

View File

@ -2,4 +2,4 @@
sstore(0, 1)
}
// ----
// : invalidatesStorage
// : writes storage

View File

@ -6,9 +6,9 @@
function i() { pop(msize()) }
}
// ----
// : movable, sideEffectFree, sideEffectFreeIfNoMSize
// a: invalidatesMemory
// f: invalidatesMemory
// g: invalidatesStorage
// h: sideEffectFreeIfNoMSize
// i: sideEffectFree, sideEffectFreeIfNoMSize
// : movable, movable apart from effects, can be removed, can be removed if no msize
// a: writes memory
// f: writes memory
// g: writes storage
// h: movable apart from effects, can be removed if no msize, reads memory
// i: can be removed, can be removed if no msize, reads memory

View File

@ -7,5 +7,5 @@
sstore(0, mload(0))
}
// ----
// : invalidatesStorage, invalidatesMemory
// foo: invalidatesMemory
// : can loop, writes storage, writes memory
// foo: can loop, writes memory

View File

@ -15,8 +15,8 @@
}
}
// ----
// : movable, sideEffectFree, sideEffectFreeIfNoMSize
// a: invalidatesStorage
// b: invalidatesStorage
// c: invalidatesStorage, invalidatesMemory
// d: movable, sideEffectFree, sideEffectFreeIfNoMSize
// : movable, movable apart from effects, can be removed, can be removed if no msize
// a: can loop, writes storage
// b: can loop, writes storage
// c: can loop, writes storage, writes memory
// d: movable, movable apart from effects, can be removed, can be removed if no msize

View File

@ -5,8 +5,8 @@
function h() { invalid() }
}
// ----
// : movable, sideEffectFree, sideEffectFreeIfNoMSize
// a: sideEffectFree, sideEffectFreeIfNoMSize
// f: sideEffectFree, sideEffectFreeIfNoMSize
// : movable, movable apart from effects, can be removed, can be removed if no msize
// a: can be removed, can be removed if no msize
// f: can be removed, can be removed if no msize
// g:
// h:

View File

@ -2,5 +2,5 @@
function a() { a() }
}
// ----
// : movable, sideEffectFree, sideEffectFreeIfNoMSize
// a:
// : movable, movable apart from effects, can be removed, can be removed if no msize
// a: movable apart from effects, can loop

View File

@ -6,9 +6,9 @@
function i() { let z := mload(0) }
}
// ----
// : movable, sideEffectFree, sideEffectFreeIfNoMSize
// a: movable, sideEffectFree, sideEffectFreeIfNoMSize
// f: invalidatesMemory
// g: invalidatesStorage
// h: sideEffectFree, sideEffectFreeIfNoMSize
// i: sideEffectFreeIfNoMSize
// : movable, movable apart from effects, can be removed, can be removed if no msize
// a: movable, movable apart from effects, can be removed, can be removed if no msize
// f: writes memory
// g: writes storage
// h: can be removed, can be removed if no msize, reads memory
// i: movable apart from effects, can be removed if no msize, reads memory

View File

@ -4,7 +4,7 @@
function g() { sstore(0, 1) }
}
// ----
// : movable, sideEffectFree, sideEffectFreeIfNoMSize
// a: invalidatesStorage, invalidatesMemory
// f: invalidatesStorage, invalidatesMemory
// g: invalidatesStorage
// : movable, movable apart from effects, can be removed, can be removed if no msize
// a: writes other state, writes storage, writes memory
// f: writes other state, writes storage, writes memory
// g: writes storage

View File

@ -5,8 +5,8 @@
function h() { pop(sload(0))}
}
// ----
// : movable, sideEffectFree, sideEffectFreeIfNoMSize
// a: invalidatesStorage
// f: invalidatesStorage
// g: invalidatesStorage, invalidatesMemory
// h: sideEffectFree, sideEffectFreeIfNoMSize
// : movable, movable apart from effects, can be removed, can be removed if no msize
// a: writes storage
// f: writes storage
// g: writes other state, writes storage, writes memory
// h: movable apart from effects, can be removed, can be removed if no msize, reads storage

View File

@ -31,10 +31,10 @@
}
}
// ----
// : invalidatesStorage, invalidatesMemory
// f: sideEffectFreeIfNoMSize
// g: invalidatesStorage, invalidatesMemory
// h: invalidatesStorage, invalidatesMemory
// i: invalidatesStorage
// r: movable, sideEffectFree, sideEffectFreeIfNoMSize
// t: invalidatesMemory
// : writes storage, writes memory
// f: movable apart from effects, can be removed if no msize, reads memory
// g: writes storage, writes memory
// h: writes storage, writes memory
// i: writes storage
// r: movable, movable apart from effects, can be removed, can be removed if no msize
// t: writes memory

View File

@ -4,6 +4,6 @@
pop(f())
}
// ----
// :
// f:
// g:
// : movable apart from effects, can loop
// f: movable apart from effects, can loop
// g: movable apart from effects, can loop