Fix Zig glue ownership helpers and capture collection#9685
Open
lukewilliamboswell wants to merge 4 commits into
Open
Fix Zig glue ownership helpers and capture collection#9685lukewilliamboswell wants to merge 4 commits into
lukewilliamboswell wants to merge 4 commits into
Conversation
Capture collection in Monotype lifting re-walked each callee body at every call site with only a recursion guard and no solved capture table, so a diamond-shaped call graph with shared callees re-derived the same free sets along every distinct call path. Build time on such graphs grew as 2^depth even though `roc check` completed normally. A function's free-local (capture) set is independent of any caller, so it is now computed once and cached in `free_sets`, and every call site consumes the cached set instead of re-walking the callee. Mutually recursive capturing functions are solved together as a strongly connected component via Tarjan with a least-fixed-point pass, so each member reaches its full transitive capture set rather than caching a partially explored one. Capture collection now scales with the number of function bodies and call edges instead of the number of call paths.
The LLVM inline-threshold experiment cranked PipelineTuningOptions.InlinerThreshold to 1000000 for all --opt=speed builds, which defeats LLVM's inliner cost model and inlines call graphs without bound. On a diamond call graph (each function calling the one below it twice) this expands to 2^depth inlined code in a single function, and the O3 passes (notably the SLP vectorizer) then spend exponential time on it. Restore the pipeline tuning to match upstream Zig's zig_llvm.cpp: drop the inliner threshold override, gate the remaining options on !is_debug, and keep loop vectorization disabled per llvm/llvm-project#186922 (a miscompilation present in the LLVM 21 we build against, fixed only on newer LLVM).
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
Testing