diff options
author | chriseth <chris@ethereum.org> | 2018-01-17 19:05:43 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-10-17 20:12:10 +0800 |
commit | 5e01d767d02d064a064a67dcf95ee299c46f741f (patch) | |
tree | 055a2533fa92111b85203eff0f1f1e8c63e38492 /libyul/optimiser/UnusedPruner.cpp | |
parent | ba1588828f45b242bc09899e4f307f7fda9c5ab6 (diff) | |
download | dexon-solidity-5e01d767d02d064a064a67dcf95ee299c46f741f.tar dexon-solidity-5e01d767d02d064a064a67dcf95ee299c46f741f.tar.gz dexon-solidity-5e01d767d02d064a064a67dcf95ee299c46f741f.tar.bz2 dexon-solidity-5e01d767d02d064a064a67dcf95ee299c46f741f.tar.lz dexon-solidity-5e01d767d02d064a064a67dcf95ee299c46f741f.tar.xz dexon-solidity-5e01d767d02d064a064a67dcf95ee299c46f741f.tar.zst dexon-solidity-5e01d767d02d064a064a67dcf95ee299c46f741f.zip |
Prevent externally used functions from being removed.
Diffstat (limited to 'libyul/optimiser/UnusedPruner.cpp')
-rw-r--r-- | libyul/optimiser/UnusedPruner.cpp | 8 |
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; |