transpile: rewrite relooper to be iterative to avoid stack overflow on large CFGs - #1995
Open
Hellboy28D wants to merge 1 commit into
Open
transpile: rewrite relooper to be iterative to avoid stack overflow on large CFGs#1995Hellboy28D wants to merge 1 commit into
Hellboy28D wants to merge 1 commit into
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The relooper in
c2rust-transpileused a recursive algorithm for control-flowreconstruction. On functions with very large/deep CFGs (e.g. thousands of
sequential basic blocks, as in the BLAKE-256 example in #1821), this could
exhaust the stack and crash the transpiler.
This PR rewrites the relooper to work iteratively, using an explicit
dominator computation instead of recursion, so structured control-flow
reconstruction no longer depends on stack depth proportional to CFG size.
Changes
c2rust-transpile/src/cfg/relooper.rswith an iterative oneTesting
cargo test -p c2rust-transpile relooper— all 7 new dominator tests passbyte-identical to the output produced by upstream
master, confirming therewrite preserves translation semantics
increased
ulimit -sNotes
Happy to adjust the approach or add more tests based on maintainer feedback.