Browse Source

Typos and docs.

cl-refactor
chriseth 10 years ago
parent
commit
e73b3068c4
  1. 5
      libevmcore/CommonSubexpressionEliminator.cpp
  2. 4
      libevmcore/ExpressionClasses.h
  3. 18
      test/SolidityOptimizer.cpp

5
libevmcore/CommonSubexpressionEliminator.cpp

@ -203,8 +203,9 @@ void CommonSubexpressionEliminator::storeInStorage(Id _slot, Id _value)
return; return;
m_sequenceNumber++; m_sequenceNumber++;
decltype(m_storageContent) storageContents; decltype(m_storageContent) storageContents;
// copy over values at points where we know that they are different from _slot or that we know // Copy over all values (i.e. retain knowledge about them) where we know that this store
// that the value is equal // operation will not destroy the knowledge. Specifically, we copy storage locations we know
// are different from _slot or locations where we know that the stored value is equal to _value.
for (auto const& storageItem: m_storageContent) for (auto const& storageItem: m_storageContent)
if (m_expressionClasses.knownToBeDifferent(storageItem.first, _slot) || storageItem.second == _value) if (m_expressionClasses.knownToBeDifferent(storageItem.first, _slot) || storageItem.second == _value)
storageContents.insert(storageItem); storageContents.insert(storageItem);

4
libevmcore/ExpressionClasses.h

@ -79,10 +79,10 @@ public:
/// Similar to @a knownToBeDifferent but require that abs(_a - b) >= 32. /// Similar to @a knownToBeDifferent but require that abs(_a - b) >= 32.
bool knownToBeDifferentBy32(Id _a, Id _b); bool knownToBeDifferentBy32(Id _a, Id _b);
/// @returns true if the value of the given class is known to be zero. /// @returns true if the value of the given class is known to be zero.
/// @note that this is not the negariot of knownNonZero /// @note that this is not the negation of knownNonZero
bool knownZero(Id _c); bool knownZero(Id _c);
/// @returns true if the value of the given class is known to be nonzero. /// @returns true if the value of the given class is known to be nonzero.
/// @note that this is not the negariot of knownZero /// @note that this is not the negation of knownZero
bool knownNonZero(Id _c); bool knownNonZero(Id _c);
/// @returns a pointer to the value if the given class is known to be a constant, /// @returns a pointer to the value if the given class is known to be a constant,
/// and a nullptr otherwise. /// and a nullptr otherwise.

18
test/SolidityOptimizer.cpp

@ -715,15 +715,15 @@ BOOST_AUTO_TEST_CASE(cse_sha3_twice_same_content_noninterfering_store_in_between
Instruction::DUP5, Instruction::DUP5,
Instruction::DUP2, Instruction::DUP2,
Instruction::MSTORE, // m[12] = DUP1 Instruction::MSTORE, // m[12] = DUP1
Instruction::DUP12, Instruction::DUP12,
u256(12 + 32), u256(12 + 32),
Instruction::MSTORE, // does not destoy memory knowledge Instruction::MSTORE, // does not destoy memory knowledge
Instruction::DUP13, Instruction::DUP13,
u256(128 - 32), u256(128 - 32),
Instruction::MSTORE, // does not destoy memory knowledge Instruction::MSTORE, // does not destoy memory knowledge
u256(0x20), u256(0x20),
u256(12), u256(12),
Instruction::SHA3 // sha3(m[12..(12+32)]) Instruction::SHA3 // sha3(m[12..(12+32)])
}; };
// if this changes too often, only count the number of SHA3 and MSTORE instructions // if this changes too often, only count the number of SHA3 and MSTORE instructions
AssemblyItems output = getCSE(input); AssemblyItems output = getCSE(input);

Loading…
Cancel
Save