aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-05-28 20:43:46 +0800
committerchriseth <c@ethdev.com>2015-05-28 20:48:07 +0800
commitf3d95236517ee03176275aa41b44b181a9f1b46a (patch)
tree059bdbfa8cbf13d1c96873cfd53d737e0a4fcbd0 /libsolidity
parentcfaa99727a5f55759e1f78349737a9dc07735984 (diff)
downloaddexon-solidity-f3d95236517ee03176275aa41b44b181a9f1b46a.tar.gz
dexon-solidity-f3d95236517ee03176275aa41b44b181a9f1b46a.tar.zst
dexon-solidity-f3d95236517ee03176275aa41b44b181a9f1b46a.zip
Allow duplicate code removal for loops.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/SolidityOptimizer.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/libsolidity/SolidityOptimizer.cpp b/libsolidity/SolidityOptimizer.cpp
index 744fc48a..827d8833 100644
--- a/libsolidity/SolidityOptimizer.cpp
+++ b/libsolidity/SolidityOptimizer.cpp
@@ -1004,6 +1004,38 @@ BOOST_AUTO_TEST_CASE(block_deduplicator)
BOOST_CHECK_EQUAL(pushTags.size(), 2);
}
+BOOST_AUTO_TEST_CASE(block_deduplicator_loops)
+{
+ AssemblyItems input{
+ u256(0),
+ eth::Instruction::SLOAD,
+ AssemblyItem(PushTag, 1),
+ AssemblyItem(PushTag, 2),
+ eth::Instruction::JUMPI,
+ eth::Instruction::JUMP,
+ AssemblyItem(Tag, 1),
+ u256(5),
+ u256(6),
+ eth::Instruction::SSTORE,
+ AssemblyItem(PushTag, 1),
+ eth::Instruction::JUMP,
+ AssemblyItem(Tag, 2),
+ u256(5),
+ u256(6),
+ eth::Instruction::SSTORE,
+ AssemblyItem(PushTag, 2),
+ eth::Instruction::JUMP,
+ };
+ BlockDeduplicator dedup(input);
+ dedup.deduplicate();
+
+ set<u256> pushTags;
+ for (AssemblyItem const& item: input)
+ if (item.type() == PushTag)
+ pushTags.insert(item.data());
+ BOOST_CHECK_EQUAL(pushTags.size(), 1);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}