Extract compute_slice_from_label from compute_failure_slices#1061
Extract compute_slice_from_label from compute_failure_slices#1061
Conversation
Refactor backward slicing to expose a general-purpose compute_slice_from_label() method on AnalysisResult that accepts an arbitrary label and seed relevance. The existing compute_failure_slices() now delegates to it, iterating error labels and extracting initial relevance from assertions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Michael Agun <danielagun@microsoft.com>
WalkthroughRefactored Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/result.cpp`:
- Around line 632-640: The fallback currently repopulates
initial_relevance.registers from all assertions when either no failing assertion
was found or when the failing assertion has no register deps, which prevents
compute_slice_from_label() from receiving an empty seed (used to enter
conservative mode); change the logic so that aggregation from
extract_assertion_registers(assertion) only happens when !found_failing, and if
found_failing is true but initial_relevance.registers is empty, leave the seed
empty (do not insert any registers), preserving the conservative empty-seed
behavior.
- Around line 537-545: The per-label relevance is being overwritten when
revisiting a label; instead of assigning slice_labels[current_label] =
relevant_before (in both the instruction_contributes branch and the "No deps
available" branch where relevant_before = relevant_after), merge the new
relevance with any existing relevance for that label. Change these writes to
union/merge operations that combine existing slice_labels[current_label] with
relevant_before (using the same union semantics as visited), so additional
registers/stack slots from later visits are not lost; keep using the same
symbols: instruction_contributes, relevant_before, relevant_after, slice_labels,
and visited.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: d98cc6e2-4bfe-43ac-97ad-e7003de4a933
📒 Files selected for processing (2)
src/result.cppsrc/result.hpp
Merge per-label relevance instead of overwriting when a label is revisited from a different successor, preserving registers and stack offsets from earlier visits. Only fall back to aggregating all assertion registers when the failing assertion was not identified. When it was found but has no register deps, leave the seed empty so compute_slice_from_label enters conservative mode. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Michael Agun <danielagun@microsoft.com>
Refactor backward slicing to expose a general-purpose compute_slice_from_label() method on AnalysisResult. It accepts an arbitrary label and seed relevance set, making backward slicing available for any program point — not just failure labels.
The existing compute_failure_slices() now delegates to it, iterating error labels and extracting initial relevance from assertions. The slicing algorithm is unchanged.
Files changed: src/result.hpp, src/result.cpp
Summary by CodeRabbit
Release Notes
compute_slice_from_label()API method for computing individual failure slices with customizable parameters.