-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Refactor compileViaYul
test setting
#15819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -73,9 +73,8 @@ SemanticTest::SemanticTest( | |||||||||||||||||||||||||||
m_enforceGasCost(_enforceGasCost), | ||||||||||||||||||||||||||||
m_enforceGasCostMinValue(std::move(_enforceGasCostMinValue)) | ||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||
static std::set<std::string> const compileViaYulAllowedValues{"also", "true", "false"}; | ||||||||||||||||||||||||||||
static std::set<std::string> const yulRunTriggers{"also", "true"}; | ||||||||||||||||||||||||||||
static std::set<std::string> const legacyRunTriggers{"also", "false", "default"}; | ||||||||||||||||||||||||||||
static std::set<CompileViaYul> const yulRunTriggers{CompileViaYul::Also, CompileViaYul::True}; | ||||||||||||||||||||||||||||
static std::set<CompileViaYul> const legacyRunTriggers{CompileViaYul::Also, CompileViaYul::False}; | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
m_requiresYulOptimizer = m_reader.enumSetting<RequiresYulOptimizer>( | ||||||||||||||||||||||||||||
"requiresYulOptimizer", | ||||||||||||||||||||||||||||
|
@@ -92,18 +91,33 @@ SemanticTest::SemanticTest( | |||||||||||||||||||||||||||
m_shouldRun = false; | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
auto const eofEnabled = solidity::test::CommonOptions::get().eofVersion().has_value(); | ||||||||||||||||||||||||||||
std::string compileViaYul = m_reader.stringSetting("compileViaYul", eofEnabled ? "true" : "also"); | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
if (compileViaYul == "false" && eofEnabled) | ||||||||||||||||||||||||||||
auto const compileViaYul = m_reader.enumSetting<CompileViaYul>( | ||||||||||||||||||||||||||||
"compileViaYul", | ||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||
{toString(CompileViaYul::False), CompileViaYul::False}, | ||||||||||||||||||||||||||||
{toString(CompileViaYul::True), CompileViaYul::True}, | ||||||||||||||||||||||||||||
{toString(CompileViaYul::Also), CompileViaYul::Also}, | ||||||||||||||||||||||||||||
{toString(CompileViaYul::OnlyOnEOF), CompileViaYul::OnlyOnEOF} | ||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||
eofEnabled ? toString(CompileViaYul::True) : toString(CompileViaYul::Also) | ||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
if (compileViaYul == CompileViaYul::OnlyOnEOF) | ||||||||||||||||||||||||||||
solUnimplemented("'compileViaYul: onlyOnEOF' is not yet supported in semantic tests."); | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
if (bytecodeFormat().contains(BytecodeFormat::EOFv1) && compileViaYul == CompileViaYul::False) | ||||||||||||||||||||||||||||
BOOST_THROW_EXCEPTION(std::runtime_error("Compilation to EOF requires using Yul IR")); | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
if (compileViaYul == CompileViaYul::False && eofEnabled) | ||||||||||||||||||||||||||||
m_shouldRun = false; | ||||||||||||||||||||||||||||
Comment on lines
+109
to
113
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
if (m_runWithABIEncoderV1Only && compileViaYul != "false") | ||||||||||||||||||||||||||||
if (m_runWithABIEncoderV1Only && compileViaYul != CompileViaYul::False) | ||||||||||||||||||||||||||||
BOOST_THROW_EXCEPTION(std::runtime_error( | ||||||||||||||||||||||||||||
"ABIEncoderV1Only tests cannot be run via yul, " | ||||||||||||||||||||||||||||
"so they need to also specify ``compileViaYul: false``" | ||||||||||||||||||||||||||||
)); | ||||||||||||||||||||||||||||
if (!util::contains(compileViaYulAllowedValues, compileViaYul)) | ||||||||||||||||||||||||||||
BOOST_THROW_EXCEPTION(std::runtime_error("Invalid compileViaYul value: " + compileViaYul + ".")); | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
m_testCaseWantsYulRun = util::contains(yulRunTriggers, compileViaYul); | ||||||||||||||||||||||||||||
m_testCaseWantsLegacyRun = util::contains(legacyRunTriggers, compileViaYul); | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -46,16 +46,22 @@ SyntaxTest::SyntaxTest( | |||||||||||||||||||||
CommonSyntaxTest(_filename, _evmVersion), | ||||||||||||||||||||||
m_minSeverity(_minSeverity) | ||||||||||||||||||||||
{ | ||||||||||||||||||||||
static std::set<std::string> const compileViaYulAllowedValues{"true", "false"}; | ||||||||||||||||||||||
|
||||||||||||||||||||||
auto const eofEnabled = solidity::test::CommonOptions::get().eofVersion().has_value(); | ||||||||||||||||||||||
m_compileViaYul = m_reader.enumSetting<CompileViaYul>( | ||||||||||||||||||||||
"compileViaYul", | ||||||||||||||||||||||
{ | ||||||||||||||||||||||
{toString(CompileViaYul::False), CompileViaYul::False}, | ||||||||||||||||||||||
{toString(CompileViaYul::True), CompileViaYul::True}, | ||||||||||||||||||||||
{toString(CompileViaYul::Also), CompileViaYul::Also}, | ||||||||||||||||||||||
{toString(CompileViaYul::OnlyOnEOF), CompileViaYul::OnlyOnEOF} | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
toString(CompileViaYul::OnlyOnEOF) | ||||||||||||||||||||||
); | ||||||||||||||||||||||
|
||||||||||||||||||||||
m_compileViaYul = m_reader.stringSetting("compileViaYul", eofEnabled ? "true" : "false"); | ||||||||||||||||||||||
if (!util::contains(compileViaYulAllowedValues, m_compileViaYul)) | ||||||||||||||||||||||
BOOST_THROW_EXCEPTION(std::runtime_error("Invalid compileViaYul value: " + m_compileViaYul + ".")); | ||||||||||||||||||||||
solUnimplementedAssert(m_compileViaYul != CompileViaYul::Also, | ||||||||||||||||||||||
"'compileViaYul: also' is not yet supported in syntax tests."); | ||||||||||||||||||||||
Comment on lines
+60
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One left from #15819 (comment):
Suggested change
|
||||||||||||||||||||||
|
||||||||||||||||||||||
if (m_compileViaYul == "false" && eofEnabled) | ||||||||||||||||||||||
m_shouldRun = false; | ||||||||||||||||||||||
if (bytecodeFormat().contains(BytecodeFormat::EOFv1) && m_compileViaYul == CompileViaYul::False) | ||||||||||||||||||||||
BOOST_THROW_EXCEPTION(std::runtime_error("Compilation to EOF requires using Yul IR")); | ||||||||||||||||||||||
Comment on lines
+63
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still needs an assert. While at it, let's also make the message a bit clearer. We should mention which settings it's about because the error won't point at a specific line in the test.
Suggested change
|
||||||||||||||||||||||
|
||||||||||||||||||||||
m_optimiseYul = m_reader.boolSetting("optimize-yul", true); | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
@@ -80,7 +86,9 @@ void SyntaxTest::setupCompiler(CompilerStack& _compiler) | |||||||||||||||||||||
OptimiserSettings::full() : | ||||||||||||||||||||||
OptimiserSettings::minimal() | ||||||||||||||||||||||
); | ||||||||||||||||||||||
_compiler.setViaIR(m_compileViaYul == "true"); | ||||||||||||||||||||||
|
||||||||||||||||||||||
auto const eofEnabled = solidity::test::CommonOptions::get().eofVersion().has_value(); | ||||||||||||||||||||||
_compiler.setViaIR(m_compileViaYul == CompileViaYul::True || (m_compileViaYul == CompileViaYul::OnlyOnEOF && eofEnabled)); | ||||||||||||||||||||||
_compiler.setMetadataFormat(CompilerStack::MetadataFormat::NoMetadata); | ||||||||||||||||||||||
_compiler.setMetadataHash(CompilerStack::MetadataHash::None); | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,7 @@ contract C { | |
|
||
// ==== | ||
// compileViaYul: false | ||
// bytecodeFormat: legacy | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Can you try to remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for |
||
// ---- | ||
// f1(bytes[1]): 0x20, 0x20, 0x3, hex"0102030000000000000000000000000000000000000000000000000000000000" -> 0x3, 0x1, 0x2, 0x3 | ||
// f2(bytes[1],bytes[1]): 0x40, 0xa0, 0x20, 0x3, hex"0102030000000000000000000000000000000000000000000000000000000000", 0x20, 0x2, hex"0102000000000000000000000000000000000000000000000000000000000000" -> 0x3, 0x1, 0x2, 0x3, 0x2, 0x1, 0x2 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,5 +23,6 @@ contract C { | |
} | ||
// ==== | ||
// compileViaYul: false | ||
// bytecodeFormat: legacy | ||
// ---- | ||
// t() -> FAILURE |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,6 @@ contract B is A { | |
} | ||
// ==== | ||
// compileViaYul: false | ||
// bytecodeFormat: legacy | ||
// ---- | ||
// x() -> 4 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,6 @@ contract C { | |
|
||
// ==== | ||
// compileViaYul: false | ||
// bytecodeFormat: legacy | ||
// ---- | ||
// f() -> 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify, this is what I meant by "same for the
legacy
run" in #15819 (comment):