Commit Graph

257 Commits

Author SHA1 Message Date
chriseth
6cb6fe35ef Make Yul optimizer not fail for wasm. 2019-06-17 18:42:47 +02:00
chriseth
c9e2d388b5
Merge pull request #6848 from ethereum/invertibleRelation
Implement references using InvertibleRelation as data structure.
2019-05-29 13:34:10 +02:00
chriseth
a3f721bbcc
Merge pull request #6583 from ethereum/reset_yulstringrepo
Reset YulStringRepository regularly
2019-05-28 14:20:53 +02:00
chriseth
2276b567b1
Merge pull request #6840 from ethereum/discoverMSize
Only remove msize-modifying instructions if msize is not used.
2019-05-28 13:16:55 +02:00
Bhargava Shastry
dbae0fa939 Reset Yul string repository before each compilation. 2019-05-28 13:12:39 +02:00
chriseth
d7b5ea6761 Allow msize optimization only if it is not present. 2019-05-28 12:54:32 +02:00
chriseth
afe887adc1 Split MovableChecker and introduce SideEffectsUpToMSize. 2019-05-28 12:54:32 +02:00
chriseth
cee1340113 Add mini-interpreter to check representation. 2019-05-28 11:35:07 +02:00
chriseth
1c16124a09 Constant optimiser for Yul. 2019-05-28 11:35:07 +02:00
chriseth
4407af53b5 Gas meter for Yul expressions. 2019-05-28 11:34:47 +02:00
chriseth
4061ad0a7b Implement references using InvertibleRelation as data structure. 2019-05-27 22:55:59 +02:00
chriseth
e5902c58a4
Merge pull request #6777 from sifmelcara/loop-cond-rewriter
[YulOpt] Implement ForLoopConditionIntoBody
2019-05-23 12:51:51 +02:00
chriseth
0f146ce55a Do not rematerialize recursively. 2019-05-23 12:03:39 +02:00
chriseth
1e3878121a Do not inline recursive functions. 2019-05-22 18:15:21 +02:00
mingchuan
a86b00e8d0
[YulOpt] Implement ForLoopConditionIntoBody 2019-05-22 21:32:18 +08:00
chriseth
1dc15d5864 Modify parser and optimizer. 2019-05-20 17:32:56 +02:00
chriseth
46d9df7574 Add EVM opcodes as builtins. 2019-05-20 16:46:31 +02:00
chriseth
8daa281d3d
Merge pull request #6776 from ethereum/equivalentFunctionHashes
Use block hashes in EquivalentFunctionDetector.
2019-05-20 14:35:39 +02:00
chriseth
4f3b7b232b
Merge pull request #6774 from ethereum/dialectRefactor
Dialect refactor
2019-05-17 14:00:09 +02:00
chriseth
4bdb981224 Make dialect const& and allocate single instances statically. 2019-05-17 12:54:24 +02:00
Daniel Kirchner
05c210772a Make use of make_vector where possible. 2019-05-17 10:08:53 +02:00
Daniel Kirchner
3c66a56e60 Use block hashes in EquivalentFunctionDetector. 2019-05-17 08:39:42 +02:00
chriseth
570db164c9 Make Dialect const. 2019-05-16 21:51:54 +02:00
chriseth
aa24e12054 Remove side-effect-free expressions, and not only movable expressions. 2019-05-16 12:30:05 +02:00
chriseth
e8a88b13e4 Introduce side-effect-free as relaxed version of movable. 2019-05-16 12:30:05 +02:00
Daniel Kirchner
a10501bb7d
Merge pull request #6725 from AndreyBronin/develop
GCC 9.1 build fix. error: redundant move in return statement
2019-05-15 11:37:20 +02:00
Andrey Bronin
4eb37fe631 fix warning in GCC 9.1: redundant move in return statement 2019-05-14 17:44:28 +03:00
chriseth
439a225cee Simplify single-run for loops to if statements. 2019-05-13 18:58:36 +02:00
chriseth
99e96c2d66 Refactor termination detection. 2019-05-13 18:58:36 +02:00
chriseth
d9831c8b96 Split structural simplifier. 2019-05-13 10:26:57 +02:00
chriseth
bf104f718f Increase code cost for branching statements. 2019-04-25 17:08:11 +02:00
chriseth
6292adbde6
Merge pull request #6580 from ethereum/doNotGenerateInstructionsAsNmes
Prevent instructions to be generated as names.
2019-04-24 22:07:05 +02:00
chriseth
0af8d758a5 Prevent instructions to be generated as names. 2019-04-24 14:35:21 +02:00
chriseth
aad4373da4 Disable redundent assign eliminator for deeply nested loops. 2019-04-23 09:50:25 +02:00
Mathias Baumann
3d061c83d7 IR: Generate inline asm blocks 2019-04-18 16:49:19 +02:00
fnatic
5b6ed7a97c
Removing scope rules for pre block in 'For Loops' 2019-04-17 05:58:40 +05:30
chriseth
fb06451f45 Add assertion that DeadCodeEliminator needs ForLoopInitRewriter. 2019-04-15 23:26:56 +02:00
mingchuan
d49733dfc3
Fix variable decl scope issue in DeadCodeEliminator
FoorLoopInitRewriter needs to be run before DeadCodeEliminator.
2019-04-10 19:00:29 +08:00
chriseth
d20b3c9f9f Function grouper is a requirement for the VarNameCleaner. 2019-04-05 13:41:38 +02:00
chriseth
887112b1b0 Fix SSA for multi-assignments. 2019-04-04 12:06:04 +02:00
Mathias Baumann
e20acf5d0a Yul Optimizer: Remove dead code 2019-04-01 17:16:04 +02:00
chriseth
529aca5cbd
Merge pull request #6407 from ethereum/changeNamespace
Remove "using namespace" from header and move Instruction to dev::eth.
2019-03-28 14:32:07 +01:00
chriseth
2308904f68 Remove "using namespace" from header and move Instruction to dev::eth. 2019-03-28 13:48:11 +01:00
chriseth
91f96c299e More logic about control flow with continue and about finalize. Remove BlockScope. 2019-03-27 22:16:31 +01:00
Christian Parpart
a1ec49409d Yul] RedundantAssignEliminator: Implements break/continue handling within ForLoop. 2019-03-26 17:36:43 +01:00
chriseth
8514c0bc60 Provide max iterations for stack compressor as parameter. 2019-03-20 15:07:05 +01:00
chriseth
aa9a2935ac Properly determine whether a variable can be eliminated or not. 2019-03-20 15:07:05 +01:00
chriseth
38cbf8d230 Pass "optimize stack allocation" flag down to the stack compressor. 2019-03-20 15:03:27 +01:00
Alex Beregszaszi
5245a66d91
Merge pull request #6318 from ethereum/signal-failure-and-such
Allow simplification patterns to signal failure
2019-03-20 03:38:51 +00:00
Alex Beregszaszi
f95388011b Allow simplification patterns to signal failure 2019-03-19 15:51:52 +01:00
Christian Parpart
89f1dbfbb6
[Yul] Refactors RedundantAssignEliminator for future changes wrt. break/continue statements. 2019-03-19 12:24:45 +01:00
Christian Parpart
57bcb8ba83
[yul] Ensures DataFlowAnalyzer works fine with break/continue statements just like without. 2019-03-14 16:18:45 +01:00
chriseth
62d8080a19 Update optimiser readme. 2019-03-12 22:02:09 +01:00
Christian Parpart
05e2d362c8 [Yul] Adds break/continue statements and some general tests for for-loop syntax. 2019-03-11 15:05:05 +01:00
chriseth
791fde953d First simplify switch with known constant expression. 2019-03-06 21:32:55 +01:00
chriseth
21115f8050 Fix visitation order bug for structural simplifier. 2019-03-06 19:34:07 +01:00
Mathias Baumann
21322dae29 YulOpt: Remove empty cases 2019-03-06 19:02:23 +01:00
Mathias Baumann
be52aa3181 YulOpt: Move if-branches into functions 2019-03-06 19:01:05 +01:00
Mathias Baumann
3ce7069766 YulOpt: Remove empty cases 2019-03-06 18:39:44 +01:00
Mathias Baumann
433175b19e YulOpt: Add comment about optimization 2019-03-06 18:39:44 +01:00
Mathias Baumann
db3bea7b56 Use reference for so we have to type less 2019-03-06 18:39:44 +01:00
chriseth
831353c590
Merge pull request #6172 from ethereum/runYulOptAsLongAsHelpful
[Yul] Run yul optimizer until it has no effect anymore.
2019-03-06 11:41:22 +01:00
chriseth
f35694f655 Run yul optimizer until it has no effect anymore. 2019-03-05 20:30:13 +01:00
Mathias Baumann
f6e09d6368 YulOpt: Extend StructuralSimplifier to work with all types 2019-03-05 18:39:27 +01:00
chriseth
3f784d6e00 Do not prepend function name to all variables when inlining. 2019-03-04 18:07:00 +01:00
Christian Parpart
609855546e Yul: Adds optimizer pass to make variable names suffix-canonical. 2019-03-04 17:26:56 +01:00
Mathias Baumann
c686a65876 Yul Optimizer: reduce switches with const arguments 2019-02-28 15:43:10 +01:00
chriseth
477c53a46f Fix expression simplifying by moving from SSAValueTracker to DataFlowAnalyzer as a base. 2019-02-27 16:14:39 +01:00
chriseth
8aeebf7fcd
Merge pull request #6071 from ethereum/moveEVMVersionToEVMDialect
Make EVM version part of EVM dialect.
2019-02-25 11:56:53 +01:00
chriseth
7f5b335b47 Make EVM version part of EVM dialect. 2019-02-21 21:59:46 +01:00
chriseth
91fb2d094d Clear state when entering new function. 2019-02-21 20:04:20 +01:00
Daniel Kirchner
8ca6715e18 More style checks. 2019-02-14 11:41:20 +01:00
chriseth
1a823f0bf8 Fix tabs/spaces. 2019-02-13 17:05:48 +01:00
chriseth
83083d2208 Stack compressor. 2019-02-11 15:48:29 +01:00
chriseth
5a34743d88 Allow optimizer steps to run on FunctionDefinition and group suite. 2019-02-11 15:48:29 +01:00
chriseth
b34e104173 Make dialect a shared pointer. 2019-02-11 15:48:29 +01:00
chriseth
11969cd760 Add some more explicit moves required in some compiler and boost version combinations. 2019-02-04 15:50:41 +01:00
Alex Beregszaszi
ee09d54525 Change FIXMEs into TODOs where appropriate 2019-01-29 00:35:23 +00:00
Alex Beregszaszi
2fc7928697
Merge pull request #5864 from ethereum/tuneOptOrder
Some optimizer tuning.
2019-01-28 13:50:09 +00:00
chriseth
12e2187661 Some tuning. 2019-01-24 23:06:01 +01:00
chriseth
1fc98b8133 Fix optimizer suite. 2019-01-24 20:42:32 +01:00
Daniel Kirchner
29f66b2674 Stabilize SSAReverser. 2019-01-17 21:05:32 +01:00
Daniel Kirchner
fd16585724 Undo second SSA transformation and add more tests. 2019-01-17 20:37:43 +01:00
Daniel Kirchner
6de2d92f20 Add SSAReverser to the yul optimiser. 2019-01-17 20:37:43 +01:00
Christian Parpart
065c3c87af
libyul: changing some AST members from shared_ptr<> to unique_ptr<>
* Some spaces look a little more verbose now, but that shouln't be a problem as it also should raise readability, too.
* This makes some use of return-value-optimizations also.
2019-01-16 14:58:59 +01:00
Daniel Kirchner
81f24f24e6 Add equivalent function combiner as Yul optimizer step. 2019-01-15 17:21:03 +01:00
Daniel Kirchner
4c8f8e9491 Disallow mismatching types in switch cases and detect duplicates by value for number literals. 2019-01-15 16:32:21 +01:00
Daniel Kirchner
5a99623fec Avoid explicit conversion from Block to Statement in CodeSize visit. 2019-01-11 12:52:24 +01:00
chriseth
d9c6773664 Adjust inlining thresholds. 2019-01-09 16:57:33 +01:00
chriseth
edda79eec5 Variables are free with regards to code size. 2019-01-09 16:57:33 +01:00
chriseth
5b8b016fae Use the block flattener. 2019-01-08 16:02:14 +01:00
chriseth
f5b24a38b8 Make function grouper idempotent. 2019-01-08 15:05:09 +01:00
chriseth
5b73c2ae3b Take special functions that require literals into account. 2019-01-07 17:23:38 +01:00
chriseth
9222eff08f Make the dialect available everywhere. 2019-01-07 16:41:03 +01:00
chriseth
2e9c70add0 Use rematerializer if variable is unreferenced or value is "cheap". 2019-01-07 14:03:32 +01:00
Christian Parpart
62fe57479e
make use of C++ = default constructor declarations as well as more non-static member initialization syntax. 2018-12-19 11:26:42 +01:00
chriseth
bf7d71d6b3
Merge pull request #5613 from ethereum/yulStringLiterals
[Yul] Use C++ user-defined literals for creating YulString constants.
2018-12-17 14:07:24 +01:00
chriseth
bc22a25a60 Remove VarDeclPropagator. 2018-12-13 16:51:10 +01:00
chriseth
6c6a53a439 Do not create unassigned variables. 2018-12-13 16:51:10 +01:00
chriseth
11209ec48a Add variable declaration initializer. 2018-12-13 16:49:04 +01:00
chriseth
b11d413720 Consider return variables to be zero initially. 2018-12-13 16:02:30 +01:00
chriseth
60a368244a Do not inline into already big functions. 2018-12-13 12:12:54 +01:00
Daniel Kirchner
5ac7620045 Use C++ user-defined literals for creating YulString constants. 2018-12-12 18:45:43 +01:00
chriseth
9557dd7e74 Support unassigned variables in the SSA value tracker and the data flow analyzer. 2018-12-12 18:06:28 +01:00
Daniel Kirchner
a18985800f Fix compilation for certain combinations of boost and gcc. 2018-12-12 07:51:23 +01:00
liangdzou
362648a450 Reuse stack slots in Yul to EVM code generation. 2018-12-10 14:28:56 +01:00
Daniel Kirchner
1eb60cbb39 Add structural simplifier as optimization step for Yul. 2018-12-06 18:37:35 +01:00
Mathias Baumann
d0204eef2f SSAValueTracker should only use nullptr for default values 2018-12-05 18:01:41 +01:00
chriseth
32c9da9419
Merge pull request #5593 from ethereum/issue-5384
Fix expression simplifier asserting on default values
2018-12-05 17:58:23 +01:00
Daniel Kirchner
538d707439 Relax dependency of FullInliner on FunctionHoister. 2018-12-05 11:53:31 +01:00
Mathias Baumann
54846ed0a7 Fix expression simplifier asserting on default values 2018-12-05 11:43:02 +01:00
Daniel Kirchner
1b8a013d4a Properly recurse in ForLoopInitRewriter 2018-12-04 13:36:25 +01:00
Christian Parpart
8dd0338d12 Remove superfluous libyul/ASTDataForward.h and include libyul/AsmDataForward directly instead. 2018-11-23 14:29:05 +01:00
Christian Parpart
ec47c8946b
Isolating libyul library API into its own namespace yul. 2018-11-23 14:29:00 +01:00
Christian Parpart
713d94476e Reorder some include files and group <libyul/>'s together (as much as possible) 2018-11-23 12:37:19 +01:00
Christian Parpart
0f4ed52a71
Rewrite header paths to adapt to recent git mv of libsolidity/inlineasm to libyul 2018-11-23 11:18:57 +01:00
Christian Parpart
d67322a186 Introduce namespace langutil in liblangutil directory.
Also:
- Use {}-style list initialisation for SourceLocation construction
- Introduce new system includes
- Changes the API of the Scanner to take source as value (with move) as opposed to as a reference
2018-11-21 19:13:44 +00:00
Christian Parpart
87821c53c3 Isolating files shared between Yul- and Solidity language frontend. 2018-11-21 18:58:12 +00:00
Alex Beregszaszi
c9ee30294c
Merge pull request #5444 from Mordax/issue-5168-rmvirtual
Removing redundant virtual from override function declaration
2018-11-21 15:16:08 +00:00
mordax
ea8b7d803e Removing redundant virtual from override function declaration
Remove trailing whitespace

Remove changelog change
2018-11-21 14:37:32 +00:00
Christian Parpart
f705a45d43
[Yul] Implements a pass to rewrite for-loop's pre block into the parent's Block. 2018-11-16 13:15:41 +01:00
chriseth
b1454433b2 Remove variables that go out of scope from data structure. 2018-11-12 23:00:37 +01:00
chriseth
faa7b61d76 Use map join algorithm for performance. 2018-11-12 23:00:37 +01:00
chriseth
fa44d20721 Remove side-effect-free statements. 2018-11-08 18:14:36 +01:00
chriseth
cd11f7cfac
Merge pull request #5325 from ethereum/fixDataFlow
[Yul] Fix data flow analyzer for function definitions.
2018-11-08 12:52:51 +01:00
chriseth
b801e61611
Merge pull request #5365 from ethereum/improveNameDispenser
[Yul] Use single counter for name dispenser for performance reasons.
2018-11-08 12:24:21 +01:00
chriseth
37766ee8e4 Add VarDeclPropagator to full suite and interactive optimizer. 2018-11-07 23:19:42 +01:00
chriseth
845899e305 Use single counter for name dispenser for performance reasons. 2018-11-07 23:09:33 +01:00
chriseth
b2b11eaa00 Fix data flow analyzer for function definitions. 2018-11-07 20:32:55 +01:00
chriseth
674e17c2a8 Performance: Replace string by special single-copy YulString class. 2018-11-07 19:30:27 +01:00
Christian Parpart
ab0de38f16
Eliminate byte-typedef and use uint8_t in all their places instead.
This change is made to (easily) be forward compatible with future C++
standards, in order to allow compiling the code with newer standards at
some point in the future.

* Removed the `using byte = uint8_t;` line from Common.h
* Mechanically change all uses of `byte` to `uint8_t`.

Tested with GCC 7.3 in C++11/14/17 modes :-)
2018-11-07 12:17:57 +01:00
chriseth
acf92930ba
Merge pull request #5247 from ethereum/yul-vardecl-propagation
Yul: Implements empty-var-decl-propagation
2018-10-28 20:46:34 +01:00
Christian Parpart
1264290d57 [Yul] ExpressionJoiner: code cleanup
* ensure public API is only containing `run(Block&)`, all the rest is private API / implementation details
* adding some comments to class data members to quicker understand their meaning
* eliminate unnecessary `operator()(If&)` as it's not changing default behaviour of `ASTModifier`
* simplify readability of `visit(Expression&)`'s impl, also moving assert's into "isLatestStatementVarDeclOf", as this one is already ensuring exactly that.
* ctor impl's use of ReferenceCounter use shortened.
* renamed and improved `isLatestStatementVarDeclOf` to better match its meaning (especially since it's only used once)
2018-10-26 13:53:37 +02:00
Christian Parpart
f08ab77249
Yul: Implements empty-var-decl-propagation 2018-10-26 13:13:57 +02:00
chriseth
f714b0dd7c
Merge pull request #5242 from ethereum/someChecks
Some well-formedness checks for the Yul AST.
2018-10-25 12:44:28 +02:00
chriseth
60f1d52f59 Full suite tests. 2018-10-24 18:02:08 +02:00
chriseth
b3911798b3 Redundant assign eliminator. 2018-10-24 13:24:25 +02:00
chriseth
19be6cd818 Some well-formedness checks for the Yul AST. 2018-10-22 15:52:26 +02:00
chriseth
c676b009e1
Merge pull request #5267 from ethereum/ssatransform
SSA transform - first step.
2018-10-19 11:10:08 +02:00
chriseth
7dffb0f3ee
Merge pull request #5270 from ethereum/inlineFlexible
Make full inliner more flexible.
2018-10-18 19:02:04 +02:00
chriseth
465845b7a7 SSA transform - first step. 2018-10-18 18:56:22 +02:00
chriseth
b2725aa913 Make full inliner more flexible. 2018-10-18 14:57:09 +02:00
chriseth
48749146da Fix a bug in CSE where a variable that was already out of scope was used. 2018-10-18 14:55:51 +02:00
chriseth
7609e2871e
Merge pull request #5240 from ethereum/limitDispenserSize
[Yul] Limit name length created by dispenser
2018-10-17 22:54:38 +02:00
chriseth
c6a6e9ac5d
Merge pull request #5232 from ethereum/inlineHeuristic
[Yul] Add simple inlining heuristic
2018-10-17 17:22:46 +02:00
chriseth
732d09cef1 Limit size of generated names and add convenience constructors. 2018-10-17 17:21:55 +02:00
chriseth
16c2a775fd Handle externally supplied variables correctly in disambiguator. 2018-10-17 14:12:11 +02:00
chriseth
5e01d767d0 Prevent externally used functions from being removed. 2018-10-17 14:12:10 +02:00
chriseth
9fb5feed05 Use metrics in the full inliner. 2018-10-17 14:11:20 +02:00
chriseth
2ab6430303 Inline each function separately. 2018-10-16 17:32:21 +02:00