Skip to content

Extract compute_slice_from_label from compute_failure_slices#1061

Merged
elazarg merged 2 commits intovbpf:mainfrom
mikeagun:compute-slice-from-label
Apr 17, 2026
Merged

Extract compute_slice_from_label from compute_failure_slices#1061
elazarg merged 2 commits intovbpf:mainfrom
mikeagun:compute-slice-from-label

Conversation

@mikeagun
Copy link
Copy Markdown
Contributor

@mikeagun mikeagun commented Mar 31, 2026

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

  • Refactor
    • Restructured failure-slice computation to improve code organization and decouple slice generation from global iteration logic.
    • Slice construction now properly initializes error information on a per-label basis.
    • Introduced new compute_slice_from_label() API method for computing individual failure slices with customizable parameters.

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>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 31, 2026

Walkthrough

Refactored compute_failure_slices to extract its backward-slicing logic into a new helper function compute_slice_from_label, which now accepts a target label and seed relevance. The public method delegates to this helper per error label. Updated slice initialization to derive .error from invariants[label].error when present, otherwise use empty VerificationError("").

Changes

Cohort / File(s) Summary
Public API Addition
src/result.hpp
Declared new public method compute_slice_from_label with parameters for program, label, seed relevance, and optional max_steps (default 200).
Backward-Slicing Refactoring
src/result.cpp
Extracted inlined backward-slicing logic from compute_failure_slices into new compute_slice_from_label helper. Refactored slice construction to initialize .error from invariants[label] instead of copying from loop. Adjusted variable renaming (parents_of_target) and loop-guard logic while preserving worklist deduplication and join-point expansion mechanics.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main refactoring: extracting a new compute_slice_from_label method from the existing compute_failure_slices implementation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between ce026ec and eb4e75a.

📒 Files selected for processing (2)
  • src/result.cpp
  • src/result.hpp

Comment thread src/result.cpp Outdated
Comment thread src/result.cpp
@mikeagun mikeagun mentioned this pull request Mar 31, 2026
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>
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.

2 participants