-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add peephole optimizer for final AST tuning.
We use this to remove two statement constructs that the main optimizer may leave behind: 1. `default<void>()` 2. `(*self).__error = __error; __error = (*self).__error;` The second case is a quite specific situation that eventually, once we have CFG/DFG tracking, the main optimizer should be able to cover more generically. However, for now, it's just not nice to always have these blocks in the generated C++ code, so adding this special case seems useful. Couples notes on (2): - Per #1592, case 2 may also have overhead. Closes #1592. - Technically, this optimization isn't always correct: subsequent code could assume that `(*self).__error` is set, whereas after removal it's not (or not to the expected value). However, `__error` is strictly-internal state, and we know that we don't use it any different, so this seems ok until we have more general optimizer logic.
- Loading branch information
Showing
19 changed files
with
299 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
tests/Baseline/hilti.optimization.peephole-default-void/opt.hlt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. | ||
module Test { | ||
|
||
|
||
public function void foo() { | ||
} | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
tests/Baseline/hilti.optimization.peephole-error-push-pop/opt.hlt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. | ||
module Test { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.