Skip to content

Hash-based loop identifiers#8816

Draft
tautschnig wants to merge 2 commits intodiffblue:developfrom
tautschnig:loop-hashing
Draft

Hash-based loop identifiers#8816
tautschnig wants to merge 2 commits intodiffblue:developfrom
tautschnig:loop-hashing

Conversation

@tautschnig
Copy link
Collaborator

compute_loop_hashes() uses AST fingerprinting based on loop structure. This yields loop identifiers that are stable across unrelated code changes.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@codecov
Copy link

codecov bot commented Mar 5, 2026

Codecov Report

❌ Patch coverage is 92.30769% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.04%. Comparing base (eaaf029) to head (01ce86c).

Files with missing lines Patch % Lines
src/goto-programs/loop_ids.cpp 37.50% 10 Missing ⚠️
src/goto-programs/unwindset.cpp 72.72% 6 Missing ⚠️
src/goto-diff/goto_diff_parse_options.cpp 0.00% 2 Missing ⚠️
src/cprover/cprover_parse_options.cpp 0.00% 1 Missing ⚠️
.../goto-instrument/goto_instrument_parse_options.cpp 0.00% 1 Missing ⚠️
src/goto-programs/goto_program.h 80.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8816      +/-   ##
===========================================
+ Coverage    80.01%   80.04%   +0.03%     
===========================================
  Files         1700     1701       +1     
  Lines       188338   188605     +267     
  Branches        73       73              
===========================================
+ Hits        150695   150973     +278     
+ Misses       37643    37632      -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

tautschnig and others added 2 commits March 6, 2026 12:32
Compute hash values with respect to string content, not just string
container indices (as irept::hash and irept::full_hash do).
compute_loop_hashes() uses AST fingerprinting based on loop structure.
This yields loop identifiers that are stable across unrelated code
changes, including the addition of do-while(0) pseudo-loops from C
macros. The hash normalizes variable names by replacing them with
canonical indices based on order of first appearance, so scope
renumbering does not affect the hash.

The hash is displayed alongside the ordinal loop number in --show-loops
output. Users can reference loops by hash in --unwindset using the
syntax function.hash_NNNN:limit, which is resolved to the ordinal loop
number internally. This enables CI scripts to use stable loop
identifiers that survive unrelated code changes.

The existing loop_id() function and loop_idt struct are unchanged to
preserve backward compatibility. A new loop_hash_id() method provides
the hash-based identifier.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.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.

1 participant