Skip to content

DFCC: match write set arguments to parameters when inferring loop assigns - #9578

Open
tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:kiro/dfcc-infer-write-set-args
Open

tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:kiro/dfcc-infer-write-set-args

Conversation

@tautschnig

Copy link
Copy Markdown
Collaborator

Since #9452, DFCC adds the write set as the first parameter of each function it instruments, and as the first argument of the calls in an instrumented body of the functions it instruments. It does so one function at a time, while inferring the assigns clauses of the loops of each function on a copy of its body with all calls inlined. Inlining binds arguments to parameters in order, and then reaches calls whose arguments do not match the callee's parameters:

  • an instrumented body passes the write set to a function that is not instrumented yet: each argument binds to the parameter before its own;
  • a body that is not instrumented yet calls a function that is: each argument binds to the parameter after its own. Upstream's placeholders covered the second case for the calls in the copy itself only. Either case aborts the inliner when an argument cannot be converted to the type of the parameter it binds to (the invariant in goto_inlinet::parameter_assignments), and otherwise infers the writes of a callee from the wrong arguments.

write_set_argumentst now makes the calls match, in the copy and, until the inference is done, in the bodies of the functions that inlining reaches from it: it adds a nil argument for a write set parameter without an argument, and removes a write set argument without a parameter. The functions of the cprover_contracts library, whose first parameter is a write set of their own, keep their arguments.

Which case arises depends on the order in which DFCC instruments the functions, which is the order of the identifiers' numbers in the string table. The tests loop_assigns_inference-instrumented-caller and -callee hit each case; both abort on develop. Their loops read x, which makes x a candidate target of the inference.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a 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.

…igns

Since diffblue#9452, DFCC adds the write set as the first parameter of each
function it instruments, and as the first argument of the calls in an
instrumented body of the functions it instruments. It does so one
function at a time, while inferring the assigns clauses of the loops of
each function on a copy of its body with all calls inlined. Inlining binds
arguments to parameters in order, and then reaches calls whose arguments
do not match the callee's parameters:
- an instrumented body passes the write set to a function that is not
  instrumented yet: each argument binds to the parameter before its own;
- a body that is not instrumented yet calls a function that is: each
  argument binds to the parameter after its own.
Upstream's placeholders covered the second case for the calls in the copy
itself only. Either case aborts the inliner when an argument cannot be
converted to the type of the parameter it binds to (the invariant in
goto_inlinet::parameter_assignments), and otherwise infers the writes of
a callee from the wrong arguments.

write_set_argumentst now makes the calls match, in the copy and, until
the inference is done, in the bodies of the functions that inlining
reaches from it: it adds a nil argument for a write set parameter without
an argument, and removes a write set argument without a parameter. The
functions of the cprover_contracts library, whose first parameter is a
write set of their own, keep their arguments.

Which case arises depends on the order in which DFCC instruments the
functions, which is the order of the identifiers' numbers in the string
table. The tests loop_assigns_inference-instrumented-caller and
-callee hit each case; both abort on develop. Their loops read x, which
makes x a candidate target of the inference.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 25, 2026 23:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.87500% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.30%. Comparing base (4265f46) to head (ee2d8fa).
⚠️ Report is 8 commits behind head on develop.

Files with missing lines Patch % Lines
...ntracts/dynamic-frames/dfcc_infer_loop_assigns.cpp 96.82% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #9578   +/-   ##
========================================
  Coverage    81.29%   81.30%           
========================================
  Files         1725     1725           
  Lines       191680   191729   +49     
  Branches        73       73           
========================================
+ Hits        155832   155886   +54     
+ Misses       35848    35843    -5     

☔ View full report in Codecov by Harness.
📢 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.

@kroening kroening added the Code Contracts Function and loop contracts label Nov 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Code Contracts Function and loop contracts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants