perf: cache successor params to avoid O(P×A) cloning in arg demotion#7556
perf: cache successor params to avoid O(P×A) cloning in arg demotion#7556Fibonacci747 wants to merge 1 commit intoFuelLabs:masterfrom
Conversation
|
Thanks for the contribution! Before we can merge this, we need @Fibonacci747 to sign the Fuel Labs Contributor License Agreement. |
PR SummaryLow Risk Overview This reduces redundant Written by Cursor Bugbot for commit fa01b95. This will update automatically on new commits. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| for (arg_idx, _arg_val, arg_var) in &arg_vars { | ||
| // Get the value which is being passed to the block at this index. | ||
| let arg_val = pred.get_succ_params(context, &block)[*arg_idx]; | ||
| let arg_val = params[*arg_idx]; |
There was a problem hiding this comment.
Cached params causes silent no-op replacement for duplicate values
Medium Severity
When the same Value is passed at multiple demotable argument positions from the same predecessor (e.g., br block(V, V)), caching get_succ_params before the inner loop causes incorrect behavior. The first iteration's replace_values replaces ALL occurrences of V in the terminator with get_local_val_0. On the next iteration, replace_values with {V → get_local_val_1} becomes a silent no-op since V no longer exists in the terminator. The result is the terminator passing the wrong GetLocal pointer for subsequent duplicate positions.


demote_block_signaturecalledget_succ_params()inside a nested loop over predecessors and demotable arguments. Each call cloned the entire arguments vector just to access a single element by index. With P predecessors, A demotable args, and N total args, this resulted in P×A×N unnecessary Value copies instead of P×N.Moved
get_succ_params()call outside the inner loop and cache the result, reducing vector cloning from O(P×A) to O(P) per block.