Fix Yul codegen for try with create.

This commit is contained in:
chriseth 2020-11-11 17:38:56 +01:00
parent be7b2c3725
commit 59da25056b
4 changed files with 13 additions and 3 deletions

View File

@ -1365,10 +1365,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());
@ -1385,7 +1388,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."