mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #5368 from ethereum/noCleanupUnsigned
[Codegen] Do not perform cleanup on unsigned integers when loading from calldata.
This commit is contained in:
commit
92ebf66067
@ -5,6 +5,7 @@ Language Features:
|
|||||||
|
|
||||||
Compiler Features:
|
Compiler Features:
|
||||||
* Build System: LLL is not built anymore by default. Must configure it with CMake as `-DLLL=ON`.
|
* Build System: LLL is not built anymore by default. Must configure it with CMake as `-DLLL=ON`.
|
||||||
|
* Code generator: Do not perform redundant double cleanup on unsigned integers when loading from calldata.
|
||||||
|
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
@ -1236,6 +1236,7 @@ unsigned CompilerUtils::loadFromMemoryHelper(Type const& _type, bool _fromCallda
|
|||||||
}
|
}
|
||||||
solAssert(numBytes <= 32, "Static memory load of more than 32 bytes requested.");
|
solAssert(numBytes <= 32, "Static memory load of more than 32 bytes requested.");
|
||||||
m_context << (_fromCalldata ? Instruction::CALLDATALOAD : Instruction::MLOAD);
|
m_context << (_fromCalldata ? Instruction::CALLDATALOAD : Instruction::MLOAD);
|
||||||
|
bool cleanupNeeded = true;
|
||||||
if (isExternalFunctionType)
|
if (isExternalFunctionType)
|
||||||
splitExternalFunctionType(true);
|
splitExternalFunctionType(true);
|
||||||
else if (numBytes != 32)
|
else if (numBytes != 32)
|
||||||
@ -1245,10 +1246,16 @@ unsigned CompilerUtils::loadFromMemoryHelper(Type const& _type, bool _fromCallda
|
|||||||
int shiftFactor = (32 - numBytes) * 8;
|
int shiftFactor = (32 - numBytes) * 8;
|
||||||
rightShiftNumberOnStack(shiftFactor);
|
rightShiftNumberOnStack(shiftFactor);
|
||||||
if (leftAligned)
|
if (leftAligned)
|
||||||
|
{
|
||||||
leftShiftNumberOnStack(shiftFactor);
|
leftShiftNumberOnStack(shiftFactor);
|
||||||
|
cleanupNeeded = false;
|
||||||
|
}
|
||||||
|
else if (IntegerType const* intType = dynamic_cast<IntegerType const*>(&_type))
|
||||||
|
if (!intType->isSigned())
|
||||||
|
cleanupNeeded = false;
|
||||||
}
|
}
|
||||||
if (_fromCalldata)
|
if (_fromCalldata)
|
||||||
convertType(_type, _type, true, false, true);
|
convertType(_type, _type, cleanupNeeded, false, true);
|
||||||
|
|
||||||
return numBytes;
|
return numBytes;
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ BOOST_AUTO_TEST_CASE(location_test)
|
|||||||
AssemblyItems items = compileContract(sourceCode);
|
AssemblyItems items = compileContract(sourceCode);
|
||||||
bool hasShifts = dev::test::Options::get().evmVersion().hasBitwiseShifting();
|
bool hasShifts = dev::test::Options::get().evmVersion().hasBitwiseShifting();
|
||||||
vector<SourceLocation> locations =
|
vector<SourceLocation> locations =
|
||||||
vector<SourceLocation>(hasShifts ? 23 : 24, SourceLocation(2, 82, make_shared<string>(""))) +
|
vector<SourceLocation>(hasShifts ? 21 : 22, SourceLocation(2, 82, make_shared<string>(""))) +
|
||||||
vector<SourceLocation>(2, SourceLocation(20, 79, make_shared<string>(""))) +
|
vector<SourceLocation>(2, SourceLocation(20, 79, make_shared<string>(""))) +
|
||||||
vector<SourceLocation>(1, SourceLocation(8, 17, make_shared<string>("--CODEGEN--"))) +
|
vector<SourceLocation>(1, SourceLocation(8, 17, make_shared<string>("--CODEGEN--"))) +
|
||||||
vector<SourceLocation>(3, SourceLocation(5, 7, make_shared<string>("--CODEGEN--"))) +
|
vector<SourceLocation>(3, SourceLocation(5, 7, make_shared<string>("--CODEGEN--"))) +
|
||||||
|
Loading…
Reference in New Issue
Block a user