Skip to content

Fix SCC dataflow worklist ordering - #1208

Merged
Frotty merged 1 commit into
masterfrom
fix-dataflow-scc-order
Jul 31, 2026
Merged

Fix SCC dataflow worklist ordering#1208
Frotty merged 1 commit into
masterfrom
fix-dataflow-scc-order

Conversation

@Frotty

@Frotty Frotty commented Jul 31, 2026

Copy link
Copy Markdown
Member

Summary

  • process statements within each strongly connected component in forward discovery order so dataflow facts propagate with the CFG
  • deduplicate queued statements and use constant-time SCC membership checks
  • report a source-located internal compiler error and skip only the affected analysis body if the convergence watchdog is ever reached
  • add a regression with sixteen mutated locals inside a loop

Root cause

The Gabow SCC implementation emits components in reverse topological order and emits the nodes inside each component in reverse discovery order. The executor corrected the component order but retained the reversed node order. For the reported 17-node loop SCC, valid dataflow analysis required 561 worklist iterations while the watchdog allowed only 389, producing a false non-convergence failure. Forward node order reduced the same analysis to 51 iterations.

Impact

Large loop bodies no longer incur near-quadratic backward propagation or fail the convergence heuristic. Any future watchdog failure is attached to the analyzed source body and does not abort validation of unrelated functions.

Validation

  • ./gradlew test --tests "tests.wurstscript.tests.FlowAnalysisTests.dataflowConvergesForManyMutatedLoopLocals"
  • ./gradlew test --tests "tests.wurstscript.tests.FlowAnalysisTests"
  • ./gradlew test — 1,455 tests, 0 failures, 0 errors

@Frotty
Frotty marked this pull request as ready for review July 31, 2026 08:59
@Frotty

Frotty commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: daca25c554

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Frotty
Frotty merged commit 0ada239 into master Jul 31, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant