mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add --experimental-via-ir option to solc
This commit is contained in:
parent
301d7ea39e
commit
e074582bf1
@ -5,6 +5,8 @@ Language Features:
|
||||
* Immutable variables with literal number values are considered pure.
|
||||
|
||||
Compiler Features:
|
||||
* Command Line Interface: New option ``--experimental-via-ir`` allows switching compilation process to go through
|
||||
the Yul intermediate representation. This is highly experimental and is used for development purposes.
|
||||
* Command Line Interface: Report error if file could not be read in ``--standard-json`` mode.
|
||||
* Command Line interface: Report proper error for each output file which could not be written. Previously an exception was thrown, and execution aborted, on the first error.
|
||||
* SMTChecker: Add division by zero checks in the CHC engine.
|
||||
|
@ -127,6 +127,7 @@ static string const g_strEVM = "evm";
|
||||
static string const g_strEVM15 = "evm15";
|
||||
static string const g_strEVMVersion = "evm-version";
|
||||
static string const g_strEwasm = "ewasm";
|
||||
static string const g_strExperimentalViaIR = "experimental-via-ir";
|
||||
static string const g_strGeneratedSources = "generated-sources";
|
||||
static string const g_strGeneratedSourcesRuntime = "generated-sources-runtime";
|
||||
static string const g_strGas = "gas";
|
||||
@ -211,6 +212,7 @@ static string const g_argYul = g_strYul;
|
||||
static string const g_argIR = g_strIR;
|
||||
static string const g_argIROptimized = g_strIROptimized;
|
||||
static string const g_argEwasm = g_strEwasm;
|
||||
static string const g_argExperimentalViaIR = g_strExperimentalViaIR;
|
||||
static string const g_argLibraries = g_strLibraries;
|
||||
static string const g_argLink = g_strLink;
|
||||
static string const g_argMachine = g_strMachine;
|
||||
@ -825,6 +827,10 @@ General Information)").c_str(),
|
||||
"Select desired EVM version. Either homestead, tangerineWhistle, spuriousDragon, "
|
||||
"byzantium, constantinople, petersburg, istanbul (default) or berlin."
|
||||
)
|
||||
(
|
||||
g_strExperimentalViaIR.c_str(),
|
||||
"Turn on experimental compilation mode via the IR (EXPERIMENTAL)."
|
||||
)
|
||||
(
|
||||
g_strRevertStrings.c_str(),
|
||||
po::value<string>()->value_name(boost::join(g_revertStringsArgs, ",")),
|
||||
@ -1456,6 +1462,8 @@ bool CommandLineInterface::processInput()
|
||||
|
||||
if (m_args.count(g_argLibraries))
|
||||
m_compiler->setLibraries(m_libraries);
|
||||
if (m_args.count(g_argExperimentalViaIR))
|
||||
m_compiler->setViaIR(true);
|
||||
m_compiler->setEVMVersion(m_evmVersion);
|
||||
m_compiler->setRevertStringBehaviour(m_revertStrings);
|
||||
// TODO: Perhaps we should not compile unless requested
|
||||
|
1
test/cmdlineTests/viair_subobjects/args
Normal file
1
test/cmdlineTests/viair_subobjects/args
Normal file
@ -0,0 +1 @@
|
||||
--ir-optimized --experimental-via-ir --optimize --bin --bin-runtime
|
5
test/cmdlineTests/viair_subobjects/err
Normal file
5
test/cmdlineTests/viair_subobjects/err
Normal file
@ -0,0 +1,5 @@
|
||||
Warning: Unused local variable.
|
||||
--> viair_subobjects/input.sol:7:9:
|
||||
|
|
||||
7 | C c = new C();
|
||||
| ^^^
|
9
test/cmdlineTests/viair_subobjects/input.sol
Normal file
9
test/cmdlineTests/viair_subobjects/input.sol
Normal file
@ -0,0 +1,9 @@
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity >=0.6.0;
|
||||
|
||||
contract C {}
|
||||
contract D {
|
||||
function f() public {
|
||||
C c = new C();
|
||||
}
|
||||
}
|
109
test/cmdlineTests/viair_subobjects/output
Normal file
109
test/cmdlineTests/viair_subobjects/output
Normal file
@ -0,0 +1,109 @@
|
||||
|
||||
======= viair_subobjects/input.sol:C =======
|
||||
Binary:
|
||||
60806040523415600f5760006000fd5b600a80601e600039806000f350fe608060405260006000fd
|
||||
Binary of the runtime part:
|
||||
|
||||
Optimized IR:
|
||||
/*******************************************************
|
||||
* WARNING *
|
||||
* Solidity to Yul compilation is still EXPERIMENTAL *
|
||||
* It can result in LOSS OF FUNDS or worse *
|
||||
* !USE AT YOUR OWN RISK! *
|
||||
*******************************************************/
|
||||
|
||||
object "C_2" {
|
||||
code {
|
||||
{
|
||||
mstore(64, 128)
|
||||
if callvalue() { revert(0, 0) }
|
||||
let _1 := datasize("C_2_deployed")
|
||||
codecopy(0, dataoffset("C_2_deployed"), _1)
|
||||
return(0, _1)
|
||||
}
|
||||
}
|
||||
object "C_2_deployed" {
|
||||
code {
|
||||
{
|
||||
mstore(64, 128)
|
||||
revert(0, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
======= viair_subobjects/input.sol:D =======
|
||||
Binary:
|
||||
608060405234156100105760006000fd5b60d380610020600039806000f350fe6080604052600436101515610074576000803560e01c6326121ff0141561007257341561002a578081fd5b806003193601121561003a578081fd5b6028806080016080811067ffffffffffffffff8211171561005757fe5b50806100ab60803980608083f05050806100708261007e565bf35b505b60006000fd6100a9565b6000604051905081810181811067ffffffffffffffff8211171561009e57fe5b80604052505b919050565bfe60806040523415600f5760006000fd5b600a80601e600039806000f350fe608060405260006000fd
|
||||
Binary of the runtime part:
|
||||
|
||||
Optimized IR:
|
||||
/*******************************************************
|
||||
* WARNING *
|
||||
* Solidity to Yul compilation is still EXPERIMENTAL *
|
||||
* It can result in LOSS OF FUNDS or worse *
|
||||
* !USE AT YOUR OWN RISK! *
|
||||
*******************************************************/
|
||||
|
||||
object "D_13" {
|
||||
code {
|
||||
{
|
||||
mstore(64, 128)
|
||||
if callvalue() { revert(0, 0) }
|
||||
let _1 := datasize("D_13_deployed")
|
||||
codecopy(0, dataoffset("D_13_deployed"), _1)
|
||||
return(0, _1)
|
||||
}
|
||||
}
|
||||
object "D_13_deployed" {
|
||||
code {
|
||||
{
|
||||
mstore(64, 128)
|
||||
if iszero(lt(calldatasize(), 4))
|
||||
{
|
||||
let _1 := 0
|
||||
if eq(0x26121ff0, shr(224, calldataload(_1)))
|
||||
{
|
||||
if callvalue() { revert(_1, _1) }
|
||||
if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) }
|
||||
let _2 := datasize("C_2")
|
||||
let _3 := add(128, _2)
|
||||
if or(gt(_3, 0xffffffffffffffff), lt(_3, 128)) { invalid() }
|
||||
datacopy(128, dataoffset("C_2"), _2)
|
||||
pop(create(_1, 128, _2))
|
||||
return(allocateMemory(_1), _1)
|
||||
}
|
||||
}
|
||||
revert(0, 0)
|
||||
}
|
||||
function allocateMemory(size) -> memPtr
|
||||
{
|
||||
memPtr := mload(64)
|
||||
let newFreePtr := add(memPtr, size)
|
||||
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { invalid() }
|
||||
mstore(64, newFreePtr)
|
||||
}
|
||||
}
|
||||
object "C_2" {
|
||||
code {
|
||||
{
|
||||
mstore(64, 128)
|
||||
if callvalue() { revert(0, 0) }
|
||||
let _1 := datasize("C_2_deployed")
|
||||
codecopy(0, dataoffset("C_2_deployed"), _1)
|
||||
return(0, _1)
|
||||
}
|
||||
}
|
||||
object "C_2_deployed" {
|
||||
code {
|
||||
{
|
||||
mstore(64, 128)
|
||||
revert(0, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user