mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Remove IRGenerator::verifyCallGraphs and make generate() verify the graphs automatically
This commit is contained in:
parent
54eb34d6fd
commit
781f00771c
@ -119,28 +119,11 @@ pair<string, string> IRGenerator::run(
|
|||||||
return {warning + ir, warning + asmStack.print()};
|
return {warning + ir, warning + asmStack.print()};
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRGenerator::verifyCallGraphs(CallGraph const& _creationGraph, CallGraph const& _deployedGraph)
|
|
||||||
{
|
|
||||||
// m_creationFunctionList and m_deployedFunctionList are not used for any other purpose so
|
|
||||||
// we can just destroy them without bothering to make a copy.
|
|
||||||
|
|
||||||
verifyCallGraph(collectReachableCallables(_creationGraph), move(m_creationFunctionList));
|
|
||||||
m_creationFunctionList = {};
|
|
||||||
|
|
||||||
verifyCallGraph(collectReachableCallables(_deployedGraph), move(m_deployedFunctionList));
|
|
||||||
m_deployedFunctionList = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
string IRGenerator::generate(
|
string IRGenerator::generate(
|
||||||
ContractDefinition const& _contract,
|
ContractDefinition const& _contract,
|
||||||
map<ContractDefinition const*, string_view const> const& _otherYulSources
|
map<ContractDefinition const*, string_view const> const& _otherYulSources
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Remember to call verifyCallGraphs() (which clears the list of generated functions) if you
|
|
||||||
// want to reuse the generator.
|
|
||||||
solAssert(m_creationFunctionList.empty(), "");
|
|
||||||
solAssert(m_deployedFunctionList.empty(), "");
|
|
||||||
|
|
||||||
auto subObjectSources = [&_otherYulSources](std::set<ContractDefinition const*, ASTNode::CompareByID> const& subObjects) -> string
|
auto subObjectSources = [&_otherYulSources](std::set<ContractDefinition const*, ASTNode::CompareByID> const& subObjects) -> string
|
||||||
{
|
{
|
||||||
std::string subObjectsSources;
|
std::string subObjectsSources;
|
||||||
@ -202,7 +185,7 @@ string IRGenerator::generate(
|
|||||||
|
|
||||||
t("deploy", deployCode(_contract));
|
t("deploy", deployCode(_contract));
|
||||||
generateImplicitConstructors(_contract);
|
generateImplicitConstructors(_contract);
|
||||||
m_creationFunctionList = generateQueuedFunctions();
|
set<FunctionDefinition const*> creationFunctionList = generateQueuedFunctions();
|
||||||
InternalDispatchMap internalDispatchMap = generateInternalDispatchFunctions();
|
InternalDispatchMap internalDispatchMap = generateInternalDispatchFunctions();
|
||||||
|
|
||||||
t("functions", m_context.functionCollector().requestedFunctions());
|
t("functions", m_context.functionCollector().requestedFunctions());
|
||||||
@ -223,7 +206,7 @@ string IRGenerator::generate(
|
|||||||
t("DeployedObject", IRNames::deployedObject(_contract));
|
t("DeployedObject", IRNames::deployedObject(_contract));
|
||||||
t("library_address", IRNames::libraryAddressImmutable());
|
t("library_address", IRNames::libraryAddressImmutable());
|
||||||
t("dispatch", dispatchRoutine(_contract));
|
t("dispatch", dispatchRoutine(_contract));
|
||||||
m_deployedFunctionList = generateQueuedFunctions();
|
set<FunctionDefinition const*> deployedFunctionList = generateQueuedFunctions();
|
||||||
generateInternalDispatchFunctions();
|
generateInternalDispatchFunctions();
|
||||||
t("deployedFunctions", m_context.functionCollector().requestedFunctions());
|
t("deployedFunctions", m_context.functionCollector().requestedFunctions());
|
||||||
t("deployedSubObjects", subObjectSources(m_context.subObjectsCreated()));
|
t("deployedSubObjects", subObjectSources(m_context.subObjectsCreated()));
|
||||||
@ -232,6 +215,11 @@ string IRGenerator::generate(
|
|||||||
bool deployedInvolvesAssembly = m_context.inlineAssemblySeen();
|
bool deployedInvolvesAssembly = m_context.inlineAssemblySeen();
|
||||||
t("memoryInitDeployed", memoryInit(!deployedInvolvesAssembly));
|
t("memoryInitDeployed", memoryInit(!deployedInvolvesAssembly));
|
||||||
|
|
||||||
|
solAssert(_contract.annotation().creationCallGraph->get() != nullptr, "");
|
||||||
|
solAssert(_contract.annotation().deployedCallGraph->get() != nullptr, "");
|
||||||
|
verifyCallGraph(collectReachableCallables(**_contract.annotation().creationCallGraph), move(creationFunctionList));
|
||||||
|
verifyCallGraph(collectReachableCallables(**_contract.annotation().deployedCallGraph), move(deployedFunctionList));
|
||||||
|
|
||||||
return t.render();
|
return t.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,8 +57,6 @@ public:
|
|||||||
std::map<ContractDefinition const*, std::string_view const> const& _otherYulSources
|
std::map<ContractDefinition const*, std::string_view const> const& _otherYulSources
|
||||||
);
|
);
|
||||||
|
|
||||||
void verifyCallGraphs(CallGraph const& _creationGraph, CallGraph const& _deployedGraph);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string generate(
|
std::string generate(
|
||||||
ContractDefinition const& _contract,
|
ContractDefinition const& _contract,
|
||||||
@ -119,9 +117,6 @@ private:
|
|||||||
langutil::EVMVersion const m_evmVersion;
|
langutil::EVMVersion const m_evmVersion;
|
||||||
OptimiserSettings const m_optimiserSettings;
|
OptimiserSettings const m_optimiserSettings;
|
||||||
|
|
||||||
std::set<FunctionDefinition const*> m_creationFunctionList;
|
|
||||||
std::set<FunctionDefinition const*> m_deployedFunctionList;
|
|
||||||
|
|
||||||
IRGenerationContext m_context;
|
IRGenerationContext m_context;
|
||||||
YulUtilFunctions m_utils;
|
YulUtilFunctions m_utils;
|
||||||
};
|
};
|
||||||
|
@ -1298,11 +1298,6 @@ void CompilerStack::generateIR(ContractDefinition const& _contract)
|
|||||||
|
|
||||||
IRGenerator generator(m_evmVersion, m_revertStrings, m_optimiserSettings);
|
IRGenerator generator(m_evmVersion, m_revertStrings, m_optimiserSettings);
|
||||||
tie(compiledContract.yulIR, compiledContract.yulIROptimized) = generator.run(_contract, otherYulSources);
|
tie(compiledContract.yulIR, compiledContract.yulIROptimized) = generator.run(_contract, otherYulSources);
|
||||||
|
|
||||||
generator.verifyCallGraphs(
|
|
||||||
**compiledContract.contract->annotation().creationCallGraph,
|
|
||||||
**compiledContract.contract->annotation().deployedCallGraph
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompilerStack::generateEVMFromIR(ContractDefinition const& _contract)
|
void CompilerStack::generateEVMFromIR(ContractDefinition const& _contract)
|
||||||
|
Loading…
Reference in New Issue
Block a user