Merge pull request #10263 from ethereum/fixTryCreateYul

Fix Yul codegen for try with create.
This commit is contained in:
chriseth 2020-11-11 20:10:54 +01:00 committed by GitHub
commit 44eb63fad0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 3 deletions

View File

@ -1367,10 +1367,13 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall)
datacopy(<memPos>, dataoffset("<object>"), datasize("<object>"))
<memEnd> := <abiEncode>(<memEnd><constructorParams>)
<?saltSet>
let <retVars> := create2(<value>, <memPos>, sub(<memEnd>, <memPos>), <salt>)
let <address> := create2(<value>, <memPos>, sub(<memEnd>, <memPos>), <salt>)
<!saltSet>
let <retVars> := create(<value>, <memPos>, sub(<memEnd>, <memPos>))
let <address> := create(<value>, <memPos>, sub(<memEnd>, <memPos>))
</saltSet>
<?isTryCall>
let <success> := iszero(iszero(<address>))
</isTryCall>
<releaseTemporaryMemory>()
)");
t("memPos", m_context.newYulVariable());
@ -1387,7 +1390,11 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall)
t("saltSet", functionType->saltSet());
if (functionType->saltSet())
t("salt", IRVariable(_functionCall.expression()).part("salt").name());
t("retVars", IRVariable(_functionCall).commaSeparatedList());
solAssert(IRVariable(_functionCall).stackSlots().size() == 1, "");
t("address", IRVariable(_functionCall).commaSeparatedList());
t("isTryCall", _functionCall.annotation().tryCall);
if (_functionCall.annotation().tryCall)
t("success", IRNames::trySuccessConditionVariable(_functionCall));
m_code << t.render();
break;

View File

@ -12,6 +12,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// EVMVersion: >=tangerineWhistle
// ----
// f() -> true

View File

@ -17,6 +17,7 @@ contract A {
}
}
// ====
// compileViaYul: also
// EVMVersion: >=constantinople
// ----
// different_salt() -> true

View File

@ -26,6 +26,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// EVMVersion: >=byzantium
// ----
// f() -> 0, 0, 96, 13, "test message."