mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add function to FunctionReturnLabelSlot and assert that functions are identical in comparison operators.
This commit is contained in:
parent
9f46fff467
commit
6037c4f26c
@ -24,6 +24,7 @@
|
|||||||
#include <libyul/AST.h>
|
#include <libyul/AST.h>
|
||||||
#include <libyul/AsmAnalysisInfo.h>
|
#include <libyul/AsmAnalysisInfo.h>
|
||||||
#include <libyul/Dialect.h>
|
#include <libyul/Dialect.h>
|
||||||
|
#include <libyul/Exceptions.h>
|
||||||
#include <libyul/Scope.h>
|
#include <libyul/Scope.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@ -54,8 +55,19 @@ struct FunctionCallReturnLabelSlot
|
|||||||
/// the function.
|
/// the function.
|
||||||
struct FunctionReturnLabelSlot
|
struct FunctionReturnLabelSlot
|
||||||
{
|
{
|
||||||
bool operator==(FunctionReturnLabelSlot const&) const { return true; }
|
std::reference_wrapper<Scope::Function const> function;
|
||||||
bool operator<(FunctionReturnLabelSlot const&) const { return false; }
|
bool operator==(FunctionReturnLabelSlot const& _rhs) const
|
||||||
|
{
|
||||||
|
// There can never be return label slots of different functions on stack simultaneously.
|
||||||
|
yulAssert(&function.get() == &_rhs.function.get(), "");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool operator<(FunctionReturnLabelSlot const& _rhs) const
|
||||||
|
{
|
||||||
|
// There can never be return label slots of different functions on stack simultaneously.
|
||||||
|
yulAssert(&function.get() == &_rhs.function.get(), "");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
static constexpr bool canBeFreelyGenerated = false;
|
static constexpr bool canBeFreelyGenerated = false;
|
||||||
};
|
};
|
||||||
/// A slot containing the current value of a particular variable.
|
/// A slot containing the current value of a particular variable.
|
||||||
|
@ -323,7 +323,7 @@ optional<Stack> StackLayoutGenerator::getExitLayoutOrStageDependencies(
|
|||||||
Stack stack = _functionReturn.info->returnVariables | ranges::views::transform([](auto const& _varSlot){
|
Stack stack = _functionReturn.info->returnVariables | ranges::views::transform([](auto const& _varSlot){
|
||||||
return StackSlot{_varSlot};
|
return StackSlot{_varSlot};
|
||||||
}) | ranges::to<Stack>;
|
}) | ranges::to<Stack>;
|
||||||
stack.emplace_back(FunctionReturnLabelSlot{});
|
stack.emplace_back(FunctionReturnLabelSlot{_functionReturn.info->function});
|
||||||
return stack;
|
return stack;
|
||||||
},
|
},
|
||||||
[&](CFG::BasicBlock::Terminated const&) -> std::optional<Stack>
|
[&](CFG::BasicBlock::Terminated const&) -> std::optional<Stack>
|
||||||
|
@ -117,7 +117,7 @@ public:
|
|||||||
m_stream << joinHumanReadable(_info.returnVariables | ranges::views::transform(variableSlotToString));
|
m_stream << joinHumanReadable(_info.returnVariables | ranges::views::transform(variableSlotToString));
|
||||||
}
|
}
|
||||||
m_stream << "\\l\\\n";
|
m_stream << "\\l\\\n";
|
||||||
Stack functionEntryStack = {FunctionReturnLabelSlot{}};
|
Stack functionEntryStack = {FunctionReturnLabelSlot{_info.function}};
|
||||||
functionEntryStack += _info.parameters | ranges::views::reverse;
|
functionEntryStack += _info.parameters | ranges::views::reverse;
|
||||||
m_stream << stackToString(functionEntryStack) << "\"];\n";
|
m_stream << stackToString(functionEntryStack) << "\"];\n";
|
||||||
m_stream << "FunctionEntry_" << _info.function.name.str() << " -> Block" << getBlockId(*_info.entry) << ";\n";
|
m_stream << "FunctionEntry_" << _info.function.name.str() << " -> Block" << getBlockId(*_info.entry) << ";\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user