aboutsummaryrefslogtreecommitdiffstats
path: root/libyul/optimiser/UnusedPruner.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-10-17 23:05:49 +0800
committerGitHub <noreply@github.com>2018-10-17 23:05:49 +0800
commitf2f72ff7eea9a461ae8c71a13428e499c8b91025 (patch)
tree02c46d9f13ff85b5a2ad3d124054bdfc71af4791 /libyul/optimiser/UnusedPruner.cpp
parent6b7d182658988f22ba23cc3852510864881515e2 (diff)
parent16c2a775fd532c301eae3abecc8d68c5c421a9a0 (diff)
downloaddexon-solidity-f2f72ff7eea9a461ae8c71a13428e499c8b91025.tar.gz
dexon-solidity-f2f72ff7eea9a461ae8c71a13428e499c8b91025.tar.zst
dexon-solidity-f2f72ff7eea9a461ae8c71a13428e499c8b91025.zip
Merge pull request #5227 from ethereum/doNotRemoveExternallyUsedFunction
Prevent externally used functions from being removed.
Diffstat (limited to 'libyul/optimiser/UnusedPruner.cpp')
-rw-r--r--libyul/optimiser/UnusedPruner.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/libyul/optimiser/UnusedPruner.cpp b/libyul/optimiser/UnusedPruner.cpp
index 74b6bee4..37a74553 100644
--- a/libyul/optimiser/UnusedPruner.cpp
+++ b/libyul/optimiser/UnusedPruner.cpp
@@ -33,12 +33,14 @@ using namespace std;
using namespace dev;
using namespace dev::yul;
-UnusedPruner::UnusedPruner(Block& _ast)
+UnusedPruner::UnusedPruner(Block& _ast, set<string> const& _externallyUsedFunctions)
{
ReferencesCounter counter;
counter(_ast);
m_references = counter.references();
+ for (auto const& f: _externallyUsedFunctions)
+ ++m_references[f];
}
void UnusedPruner::operator()(Block& _block)
@@ -89,11 +91,11 @@ void UnusedPruner::operator()(Block& _block)
ASTModifier::operator()(_block);
}
-void UnusedPruner::runUntilStabilised(Block& _ast)
+void UnusedPruner::runUntilStabilised(Block& _ast, set<string> const& _externallyUsedFunctions)
{
while (true)
{
- UnusedPruner pruner(_ast);
+ UnusedPruner pruner(_ast, _externallyUsedFunctions);
pruner(_ast);
if (!pruner.shouldRunAgain())
return;