The proc-return passes ask only the calls that can reach a scope - #7398
Conversation
Two of an_phase_proc_returns' re-derivations -- a parameter bound from a now-poly array argument, and a block parameter bound from such a value -- asked an_call_targets_scope about every CallNode of the program for every scope with parameters (or every yielding scope for every call with a block), in each of up to 32 rounds: scopes times calls. On a 56k-line machine-generated program the phase took 10.6 s in promote mode. an_call_targets_scope can only answer yes for a call on the scope's own name, a call on a name some class aliases a method under, or `new` for an `initialize`. An index built once a round lists those calls for each scope name (and those scopes for each call name), in the order the full walk visits them, and the passes ask just them. The answers and the order of the updates are the same, so the generated C is unchanged; the phase now takes 0.2 s on that program.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughThe procedure return analysis builds a temporary index of calls and named scopes. The parameter-bound and yield-site passes use indexed candidates instead of scanning all calls or scopes. Existing checks still determine which candidates apply. ChangesProcedure return analysis indexing
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Refactor · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable issue is identified for this change. It is mergeable after normal checks. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #7397.
an_call_targets_scopecan only answer yes for a call on the scope's own name, a call on a name some class aliases a method under, ornewfor aninitialize. Sections (9) and (9b) ofan_phase_proc_returnsasked it for every call against every scope anyway.Change
src/analyze.conly. A small index (PRCallIdx), built once a round before (9) and freed after (9b):(9) visits, for each scope, the calls on its name merged with the aliased calls (and the
newcalls for aninitialize), in the original order, and still asksan_call_targets_scopeabout each. (9b) visits, for each call with a block, the scopes of its name (and theinitializes fornew) in ascending order, or every scope when the name is an alias name. The answers and the order of the updates are the same as before.Results
Time in
an_phase_proc_returnsfor the issue's generator, promote mode:The 56k-line machine-generated program from the issue: 10.6 s -> 0.22 s; a 52k-line one: 2.48 s -> 0.14 s; a 141k-line one: 11.35 s -> 0.40 s (promote mode, phase time, with four other slow analysis passes disabled for the measurement).
The generated C does not change
test/*.rb(5,746 programs) compiled withspinel -cin both--int-overflowmodes, on master (e5e8f79) and on this change, built in turn in the same checkout and fed the same relative paths: the generated C, stderr and exit status are identical for all 11,492 compilations except the 8 (4 programs, 2 modes each) that embedRUBY_DESCRIPTION, whose only difference is the revision string.Gate
The stamp line above names the
origin/masterthe clone had fetched when the gate finished (ab9b925); the tree the gate ran was based on 92510d6, as described below.make gatewas run on 92510d6 with this change merged together with other fixes from the same investigation (#7384, #7386, #7388, #7390, #7392 and others); the branch was then rebased onto ab9b925 without conflicts.Promote mode
SPINEL_INT_OVERFLOW=promote make teston the same combined branch:Tests: 5909 pass, 15 fail, 13 error. All 28 failing tests are among the 29 that master fails in promote mode at e5e8f79; none is new. The 29th (raise_rejects_invalid_arguments) no longer fails, which appears to come from master moving from e5e8f79 to 92510d6.Summary by CodeRabbit