File tree Expand file tree Collapse file tree 2 files changed +45
-1
lines changed
test/libyul/yulOptimizerTests/fakeStackLimitEvader Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,12 @@ void StackToMemoryMover::operator()(FunctionDefinition& _functionDefinition)
158
158
{},
159
159
move (_functionDefinition.body )
160
160
});
161
+ // Generate new names for the arguments to maintain disambiguation.
162
+ std::map<YulString, YulString> newArgumentNames;
163
+ for (TypedName const & _var: stackParameters)
164
+ newArgumentNames[_var.name ] = m_context.dispenser .newName (_var.name );
165
+ for (auto & parameter: _functionDefinition.parameters )
166
+ parameter.name = util::valueOrDefault (newArgumentNames, parameter.name , parameter.name );
161
167
// Replace original function by a call to the new function and an assignment to the return variable from memory.
162
168
_functionDefinition.body = Block{_functionDefinition.debugData , move (memoryVariableInits)};
163
169
_functionDefinition.body .statements .emplace_back (ExpressionStatement{
@@ -166,7 +172,7 @@ void StackToMemoryMover::operator()(FunctionDefinition& _functionDefinition)
166
172
_functionDefinition.debugData ,
167
173
Identifier{_functionDefinition.debugData , newFunctionName},
168
174
stackParameters | ranges::views::transform ([&](TypedName const & _arg) {
169
- return Expression{Identifier{_arg.debugData , _arg.name }};
175
+ return Expression{Identifier{_arg.debugData , newArgumentNames. at ( _arg.name ) }};
170
176
}) | ranges::to<vector<Expression>>
171
177
}
172
178
});
Original file line number Diff line number Diff line change
1
+ {
2
+ {
3
+ mstore (0x40 , memoryguard (0x80 ))
4
+ sstore (0 , f (1 ,2 ,3 ))
5
+ }
6
+ function f (a, b, c) -> $b1 {
7
+ if calldataload (add (sub (a,b),c)) {
8
+ $b1 := 0
9
+ leave
10
+ }
11
+ $b1 := 1
12
+ }
13
+
14
+ }
15
+ // ----
16
+ // step: fakeStackLimitEvader
17
+ //
18
+ // {
19
+ // {
20
+ // mstore(0x40, memoryguard(0xa0))
21
+ // sstore(0, f(1, 2, 3))
22
+ // }
23
+ // function f(a_2, b_3, c_4) -> $b1
24
+ // {
25
+ // mstore(0x80, 0)
26
+ // f_1(a_2, b_3, c_4)
27
+ // $b1 := mload(0x80)
28
+ // }
29
+ // function f_1(a, b, c)
30
+ // {
31
+ // if calldataload(add(sub(a, b), c))
32
+ // {
33
+ // mstore(0x80, 0)
34
+ // leave
35
+ // }
36
+ // mstore(0x80, 1)
37
+ // }
38
+ // }
You can’t perform that action at this time.
0 commit comments