Skip to content

Commit

Permalink
Call DFCC only once
Browse files Browse the repository at this point in the history
  • Loading branch information
qinheping committed Oct 24, 2024
1 parent 0896568 commit 3e2e28e
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions kani-driver/src/call_goto_instrument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ impl KaniSession {
self.goto_sanity_check(output)?;
}

self.instrument_contracts(harness, output)?;

if self
.args
.common_args
.unstable_features
.contains(kani_metadata::UnstableFeature::LoopContracts)
{
self.instrument_loop_contracts(harness, output)?;
self.instrument_contracts_with_loop_contracts(harness, output)?;
} else {
self.instrument_contracts(harness, output)?;
}

if self.args.checks.undefined_function_on() {
Expand Down Expand Up @@ -193,8 +193,12 @@ impl KaniSession {
}

/// Apply annotated loop contracts.
pub fn instrument_loop_contracts(&self, harness: &HarnessMetadata, file: &Path) -> Result<()> {
let args: Vec<OsString> = vec![
pub fn instrument_contracts_with_loop_contracts(
&self,
harness: &HarnessMetadata,
file: &Path,
) -> Result<()> {
let mut args: Vec<OsString> = vec![
"--dfcc".into(),
(&harness.mangled_name).into(),
"--apply-loop-contracts".into(),
Expand All @@ -205,9 +209,21 @@ impl KaniSession {
// instead of simply rejecting function calls and statement expressions.
// See issue: diffblue/cbmc#8393
"--disable-loop-contracts-side-effect-check".into(),
file.into(),
file.into(),
];

if let Some(assigns) = harness.contract.as_ref() {
args.push("--enforce-contract".into());
args.push(assigns.contracted_function_name.as_str().into());

if let Some(tracker) = &assigns.recursion_tracker {
args.push("--nondet-static-exclude".into());
args.push(tracker.as_str().into());
}
}

args.push(file.into());
args.push(file.into());

self.call_goto_instrument(&args)
}

Expand Down

0 comments on commit 3e2e28e

Please sign in to comment.