Open ekpyron opened 1 year ago
Actually, there is a less-invasive, yet messier, variant of the above:
We could leave the Yul AST data structures untouched, but translate all identifiers, excluding builtins, to _1, _2, ...
in the beginning of optimization, while still keeping above mapping to original names for a back-translation.
Note: this issue is meant to lay out a solution that will take a good amount of refactoring merely for consideration and may not be what we end up doing.
We keep running into issues like https://github.com/ethereum/solidity/issues/14494 with the Yul optimizer. The symptom is differences in bytecode between one compilation of a contract and another compilation with additional, but unrelated source files. In these cases the compiler-generated metadata is identical, which is supposed to guarantee identical compiler output. However, this guarantee is violated.
There are potential causes already in IR code generation, this issue means to address causes in the Yul optimizer.
YulString
comparison does not coincide with lexicographic string comparison (although even the latter would only result in monotonic comparison if left-padded with zeroes).The following would be an option to evade this issue once and for all, while potentially allowing to increase the optimizer performance in the process (however, the actual expected improvement is hard to estimate and may not be significant):
Note: the template argument will be inherited by all Yul AST nodes.
Complications: