Improve raw_ptr::write#7646
Conversation
|
e2e-gas-usage
e2e-bytecode-size
o2-bytecode-size
o2-gas-usage
|
Merging this PR will degrade performance by 20.32%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing |
|
👍 |
## Description This PR is a necessary change for #7646. Some IR tests have a bug: their harness is expecting some passes to return `modified = true` even when the pass is not modifying anything. To make sure that #7646 is NOT changing the optimisation itself, but only fixing the `modified` flag, I am creating this PR. The idea is that #7646 snapshot tests will have only the flag changed, not their optimisation. ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers. --------- Co-authored-by: Igor Rončević <ironcev@hotmail.com>
5d5a052 to
7196d95
Compare
## Description This PR is another prelude to #7646. We discovered that `memcpyopt` does not work when we run it multiple times. The cause is that we bail the optimisation when a symbol has more than one write. This is correct, but we were only considering 'store'. Now we are correctly also considering all other ways to write into "symbols". ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers.
7196d95 to
d591444
Compare
|
@cursor BugBot run |
|
Here's a summary of the BugBot review I posted on PR #7646: No critical bugs found. The core algorithms (dominator tree refactoring, loop analysis, pass manager loop) are correct. I identified 3 issues:
I also noted a few minor observations: an unnecessary per-iteration allocation in |
BugBot ReviewI analyzed the full diff of this PR. Here are the findings: Bug 1 (Medium): Inconsistent iteration limits between
|
| # | Severity | Description |
|---|---|---|
| 1 | Medium | Iteration limit mismatch: run() = 10, run_with_print_verify() = 2 |
| 2 | Low | todo!() panic in instruction_print for non-instruction/non-constant values |
| 3 | Low | Inline heuristic <= 1 now accepts call count 0 (was == 1) |
No critical bugs found. The core algorithms (dominator tree, loop analysis, pass manager loop) are correct.
Fixed. They are now the same value.
This is intentional. This function is only used for debug and it is incomplete.
This is fine. A call count of 0 would never be inlined anyways. The "<=" is needed if the constant is greater than one.
Done.
Done
Intentional. This will be used later. |
8c9756f to
a269d74
Compare


Description
This PR is the first of a series trying to make
raw_ptr::writeoptimal. For now, we tackle the issue that it was not being inlined.The issue is that we only check for inlining at certain points, and some optimisations were being run after this check, ignoring the inlining even when it made sense.
The solution is to run the optimisation pipeline multiple times, a standard practice. For that, I had to fix other passes that were returning
truefor modified even when they do not change anything. This allows us to break the loop as early as possible.Compilation time impact remains to be checked, but we can remove the loop on debug builds if that presents itself as a problem.
Checklist
Breaking*orNew Featurelabels where relevant.