diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 14b335016395..986ff29636e7 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -69,6 +69,7 @@ #include #include #include +#include #include #include @@ -99,6 +100,7 @@ using namespace solidity; using namespace solidity::langutil; using namespace solidity::frontend; using namespace solidity::stdlib; +using namespace solidity::yul; using namespace std::string_literals; using solidity::util::errinfo_comment; @@ -1672,6 +1674,15 @@ std::string CompilerStack::createMetadata(Contract const& _contract, bool _forIR details["yulDetails"]["stackAllocation"] = m_optimiserSettings.optimizeStackAllocation; details["yulDetails"]["optimizerSteps"] = m_optimiserSettings.yulOptimiserSteps + ":" + m_optimiserSettings.yulOptimiserCleanupSteps; } + else if + ( + OptimiserSuite::isEmptyOptimizerSequence(m_optimiserSettings.yulOptimiserSteps) && + OptimiserSuite::isEmptyOptimizerSequence(m_optimiserSettings.yulOptimiserCleanupSteps) + ) + { + details["yulDetails"] = Json::objectValue; + details["yulDetails"]["optimizerSteps"] = m_optimiserSettings.yulOptimiserSteps + ":" + m_optimiserSettings.yulOptimiserCleanupSteps; + } meta["settings"]["optimizer"]["details"] = std::move(details); } diff --git a/test/cmdlineTests/yul_optimizer_steps_without_optimize_empty_sequence/args b/test/cmdlineTests/yul_optimizer_steps_without_optimize_empty_sequence/args index ccf611ee15c7..fef6c6531e19 100644 --- a/test/cmdlineTests/yul_optimizer_steps_without_optimize_empty_sequence/args +++ b/test/cmdlineTests/yul_optimizer_steps_without_optimize_empty_sequence/args @@ -1 +1 @@ ---ir-optimized --yul-optimizations : +--ir-optimized --metadata --yul-optimizations : diff --git a/test/cmdlineTests/yul_optimizer_steps_without_optimize_empty_sequence/output b/test/cmdlineTests/yul_optimizer_steps_without_optimize_empty_sequence/output index 30cf398dbe36..9ee68107929a 100644 --- a/test/cmdlineTests/yul_optimizer_steps_without_optimize_empty_sequence/output +++ b/test/cmdlineTests/yul_optimizer_steps_without_optimize_empty_sequence/output @@ -1,3 +1,5 @@ + +======= yul_optimizer_steps_without_optimize_empty_sequence/input.sol:C ======= Optimized IR: /// @use-src 0:"yul_optimizer_steps_without_optimize_empty_sequence/input.sol" object "C_28" { @@ -126,3 +128,6 @@ object "C_28" { data ".metadata" hex"" } } + +Metadata: +{"compiler":{"version": ""},"language":"Solidity","output":{"abi":[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"foo","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"yul_optimizer_steps_without_optimize_empty_sequence/input.sol":"C"},"evmVersion":"shanghai","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"details":{"constantOptimizer":false,"cse":false,"deduplicate":false,"inliner":false,"jumpdestRemover":true,"orderLiterals":false,"peephole":true,"simpleCounterForLoopUncheckedIncrement":true,"yul":false,"yulDetails":{"optimizerSteps":":"}},"runs":200},"remappings":[]},"sources":{"yul_optimizer_steps_without_optimize_empty_sequence/input.sol":{"keccak256":"0x3fc910e345ce1ee62bfa6b0f66931ee632c08265b25b6139cfbbfe4d2f8d5dd8","license":"GPL-3.0","urls":["bzz-raw://e557e9ad2c2e420a669c06ae456b0b790d77d2d6d492cd8540e6b244388a5140","dweb:/ipfs/QmaNiZmC2Mo3YxGiehs1n3dVTjZwD7FguX7EUtpeshMVuR"]}},"version":1}