Rework max-stack analysis crate, address some limitations#2589
Conversation
I intend to do some rework of the max-stack analysis code, and would like to break out the max-stack analysis into its own crate to make testing this in isolation easier. As this code also depends on the `xtask::elf` module, I broke that out to avoid circular deps. This is the minimum change necessary to split things out before any refactoring.
No functional changes expected.
|
Issues I've found so far: At least some code does meaningfully have recursion cyclesAt least some code is missing proper symbol table metadatathe function gets filtered out because of this // The original |
hawkw
left a comment
There was a problem hiding this comment.
this is mostly style nitpicking because i didn't really understand the old code and i am not sure if i fully understand the new code either.
This is a more targeted, partial fix for #2588, and contains the most immediate relief from the larger refactoring in #2589. This catches the largest "novel" defect: ignoring of relative branches, and raises all the stack numbers to what the new analysis in #2589 shows. This is intended as a stop-gap to prevent seeing stack overflows in test benches. Split into two commits, one with manifest updates, and one with the stack analysis change.
42089bb to
50a9c90
Compare
labbott
left a comment
There was a problem hiding this comment.
I think this is a good approach, I'll take another pass later
|
@hawkw I will likely punt on switching over to |
|
For the sake of verification, I coerced a couple different generations of the stack analysis to output similar reports, and the easiest way to multi-file-diff (edit: and share it, locally I use largely: they change in the way we expect:
Commit 2->3 has some meaningful code changes (I tried to back these out, but it was annoying and I gave up), so there are some changed addresses, but 1->2 and 3->4 are relatively the same code, just with analysis changed. |
268945d to
5af9908
Compare
labbott
left a comment
There was a problem hiding this comment.
I think this is a really nice improvement
| //! 1. This approach does not handle recursion, as we have no way to annotate a | ||
| //! potential upper bound of recursive iterations. Currently, the code | ||
| //! counts the number of direct recursion instances detected (e.g. self-calls | ||
| //! of a function), and refuses to resolve call stacks with cycles. |
There was a problem hiding this comment.
Does this comment need to be updated to match our current approach with "blessed recursion"?
There was a problem hiding this comment.
Yes! Updated this comment.
Note: this builds on top of #2587, which broke out the relevant functions into a standalone crate.
This PR consists of four main parts:
The 4th part isn't strictly necessary, however while investigating and making myself familiar with how our current code works, it was useful to me to split things out so I could follow what was going on, and restructure the analysis to allow for some more interactive debugging/diffing. I personally think the code is a bit more accessible now, but that could be more personal preference than anything else.
The 1st and 3rd parts are achievable with a much smaller (a few lines) diff. If this PR is too difficult to review, happy to bail on this or at least defer it.
The 2nd part would be more difficult (but still possible) to achieve without the refactorings made in the 4th part, as the new call graph analysis lets us more easily keep track of which functions have been visiting when traversing the graph.
If we merge this PR, I'd consider the "urgent" part of #2588 resolved, though there are still some "known defects", and we might want to increase the baseline stack requirements to handle register stacking (this would bump most task stack sizes in most manifests by 104 bytes, and +36 for gimletlet).