diff options
Diffstat (limited to 'libyul/optimiser')
-rw-r--r-- | libyul/optimiser/UnusedPruner.cpp | 8 | ||||
-rw-r--r-- | libyul/optimiser/UnusedPruner.h | 4 |
2 files changed, 7 insertions, 5 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; diff --git a/libyul/optimiser/UnusedPruner.h b/libyul/optimiser/UnusedPruner.h index 327921ea..30617ff3 100644 --- a/libyul/optimiser/UnusedPruner.h +++ b/libyul/optimiser/UnusedPruner.h @@ -44,7 +44,7 @@ namespace yul class UnusedPruner: public ASTModifier { public: - explicit UnusedPruner(Block& _ast); + explicit UnusedPruner(Block& _ast, std::set<std::string> const& _externallyUsedFunctions = std::set<std::string>()); using ASTModifier::operator(); virtual void operator()(Block& _block) override; @@ -53,7 +53,7 @@ public: bool shouldRunAgain() const { return m_shouldRunAgain; } // Run the pruner until the code does not change anymore. - static void runUntilStabilised(Block& _ast); + static void runUntilStabilised(Block& _ast, std::set<std::string> const& _externallyUsedFunctions = std::set<std::string>()); private: bool used(std::string const& _name) const; |