Skip to content

Commit 46ead2e

Browse files
committed
eof: Enable peephole optimizer for EOF.
1 parent ec28a62 commit 46ead2e

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed

Diff for: libevmasm/Assembly.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -843,8 +843,7 @@ std::map<u256, u256> const& Assembly::optimiseInternal(
843843
}
844844
}
845845

846-
// TODO: verify this for EOF.
847-
if (_settings.runPeephole && !m_eofVersion.has_value())
846+
if (_settings.runPeephole)
848847
{
849848
for (auto& codeSection: m_codeSections)
850849
{

Diff for: libevmasm/PeepholeOptimiser.cpp

+25-8
Original file line numberDiff line numberDiff line change
@@ -572,14 +572,31 @@ struct UnreachableCode
572572
auto end = _state.items.end();
573573
if (it == end)
574574
return false;
575-
if (
576-
it[0] != Instruction::JUMP &&
577-
it[0] != Instruction::RJUMP &&
578-
it[0] != Instruction::RETURN &&
579-
it[0] != Instruction::STOP &&
580-
it[0] != Instruction::INVALID &&
581-
it[0] != Instruction::SELFDESTRUCT &&
582-
it[0] != Instruction::REVERT
575+
if (it[0].type() == Operation)
576+
{
577+
// These instructions have their own AssemblyItemType
578+
solAssert(
579+
it[0] != Instruction::RJUMP &&
580+
it[0] != Instruction::RETURNCONTRACT &&
581+
it[0] != Instruction::JUMPF &&
582+
it[0] != Instruction::RETF
583+
);
584+
585+
if (
586+
it[0] != Instruction::JUMP &&
587+
it[0] != Instruction::RETURN &&
588+
it[0] != Instruction::STOP &&
589+
it[0] != Instruction::INVALID &&
590+
it[0] != Instruction::SELFDESTRUCT &&
591+
it[0] != Instruction::REVERT
592+
)
593+
return false;
594+
}
595+
else if (
596+
it[0].type() != RelativeJump &&
597+
it[0].type() != JumpF &&
598+
it[0].type() != RetF &&
599+
it[0].type() != ReturnContract
583600
)
584601
return false;
585602

Diff for: test/libyul/objectCompiler/eof/256_subcontainers.yul

+3-5
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)