Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
038cccf
verify: Note a counterexample's loop, confirm it by unrolling the loo…
SwayamInSync Oct 27, 2026
4f19294
verify: Add --confirm-bound, for the solver backends only.
SwayamInSync Oct 27, 2026
3552a2a
test: Failures after a loop, reachable, unreachable within the bound,…
SwayamInSync Oct 27, 2026
7539fcf
docs: Describe how a failure after a loop is noted and confirmed.
SwayamInSync Oct 27, 2026
eb69d2b
docs: Describe --confirm-bound and the notes of a failure.
SwayamInSync Oct 27, 2026
a4bca09
docs: A counterexample after a loop in the book.
SwayamInSync Oct 27, 2026
615eb6c
docs: List --confirm-bound in the book.
SwayamInSync Oct 27, 2026
79038ec
docs: Note counterexamples after a loop in the 0.2.0 release notes.
SwayamInSync Oct 27, 2026
1472ec7
docs: Design the notes and confirmation of a failure after a loop.
SwayamInSync Oct 27, 2026
018fa69
docs: Describe how a failure after a loop is confirmed by unrolling.
SwayamInSync Oct 27, 2026
5ee269f
verify: Report only the functions --function selects, verifying what …
SwayamInSync Oct 27, 2026
5875c24
verify: Add --function, a repeatable glob over function names.
SwayamInSync Oct 27, 2026
014b8c1
test: --function keeps a whole run's verdicts and verifies nothing el…
SwayamInSync Oct 27, 2026
d169b2a
docs: Describe --function.
SwayamInSync Oct 27, 2026
02abd63
docs: List --function in the book.
SwayamInSync Oct 27, 2026
5d03561
docs: Note --function in the 0.2.0 release notes.
SwayamInSync Oct 27, 2026
fac2e50
verify: Carry the failures a module reports after its first, each wit…
SwayamInSync Oct 27, 2026
68a5856
verify: Report up to --max-failures failing obligations of a module, …
SwayamInSync Oct 27, 2026
42ec762
verify: Print each failure a function reports with its notes, and con…
SwayamInSync Oct 27, 2026
f8bc531
verify: Add --max-failures.
SwayamInSync Oct 27, 2026
693c1b0
test: --max-failures reports each failing check that an execution pas…
SwayamInSync Oct 27, 2026
9736285
docs: Describe how --function schedules what the reported verdicts re…
SwayamInSync Oct 27, 2026
1553fe8
test: A failure after a loop is confirmed past the checks that fail b…
SwayamInSync Oct 27, 2026
08334b1
docs: Describe --max-failures.
SwayamInSync Oct 27, 2026
657de3f
docs: Describe the note on a check that fails only after an earlier one.
SwayamInSync Oct 27, 2026
0dcdef4
docs: List --max-failures in the book.
SwayamInSync Oct 27, 2026
0aa81ec
docs: Point to --max-failures and the note on an earlier failure in t…
SwayamInSync Oct 27, 2026
5309109
docs: Note --max-failures in the 0.2.0 release notes.
SwayamInSync Oct 27, 2026
4606ed3
verify: Add BackendTimes, where the backends of one function count th…
SwayamInSync Oct 27, 2026
ac67bd1
verify: Count the time of each counterexample check into the limits' …
SwayamInSync Oct 27, 2026
38aa1fe
verify: Count a backend's solving and induction time, and forward its…
SwayamInSync Oct 27, 2026
d480b8e
docs: Design how the failures after the first are reported.
SwayamInSync Oct 27, 2026
c7ea7db
verify: Give each Z3 query, and the passes nested in it, the backend'…
SwayamInSync Oct 27, 2026
75785f8
docs: Describe how the failures after the first are solved past the e…
SwayamInSync Oct 27, 2026
ec79bc9
verify: Give cvc5's counterexample checks the backend's time sink.
SwayamInSync Oct 27, 2026
af968e1
verify: Report where the run and each function spent their time, and …
SwayamInSync Oct 27, 2026
382bb84
verify: Add --time-report and --progress.
SwayamInSync Oct 27, 2026
6b09406
test: Add a checker of which phases of a time report took time.
SwayamInSync Oct 27, 2026
5ad3906
test: Add a failing function and a recursive spec for the time report…
SwayamInSync Oct 27, 2026
43c059e
test: --time-report shows the phases that took time, with times that …
SwayamInSync Oct 27, 2026
8334673
test: Every backend counts its counterexample checks for --time-report.
SwayamInSync Oct 27, 2026
9bbfb85
docs: Describe --time-report and the progress line.
SwayamInSync Oct 27, 2026
4e619c1
docs: List --time-report in the book.
SwayamInSync Oct 27, 2026
5fba9a6
docs: Note --time-report and the progress line in the 0.2.0 release n…
SwayamInSync Oct 27, 2026
bd27ee0
docs: Describe what --time-report measures where.
SwayamInSync Oct 27, 2026
9eb28c3
verify: Verify a definition whose trusted mark it only inherits from …
SwayamInSync Oct 27, 2026
f563bca
test: A trusted declaration's definition is verified, and a trusted d…
SwayamInSync Oct 27, 2026
87e2def
verify: Record each contracted function's contract as written.
SwayamInSync Oct 27, 2026
9e1dcaa
verify: Declare CrossFileRun, which settles the contracts of the file…
SwayamInSync Oct 27, 2026
7b6e2f5
verify: Settle a contract a file declares without a definition agains…
SwayamInSync Oct 27, 2026
03162aa
verify: Settle contracts across the files of one run.
SwayamInSync Oct 27, 2026
dc41ce8
test: Add a header declaring a contract for the cross-file tests.
SwayamInSync Oct 27, 2026
0d0cca6
test: Add the definition of the header's contract, right or wrong.
SwayamInSync Oct 27, 2026
a735afc
test: Add callers of the header's contract.
SwayamInSync Oct 27, 2026
a75cedc
test: Add a declaration that states another contract than the definit…
SwayamInSync Oct 27, 2026
d6faf0a
test: Add one of two files whose contracts rest on each other.
SwayamInSync Oct 27, 2026
85a6b98
test: Add the other of two files whose contracts rest on each other.
SwayamInSync Oct 27, 2026
d187b18
test: One run over several files settles the contracts they declare w…
SwayamInSync Oct 27, 2026
539b11c
docs: Describe trust on declarations and definitions, and contracts a…
SwayamInSync Oct 27, 2026
ec24d8a
docs: Describe a run over several files.
SwayamInSync Oct 27, 2026
6d5f849
docs: Note contracts across files in the limitations.
SwayamInSync Oct 27, 2026
c022adb
docs: Point to one run over several files in the book.
SwayamInSync Oct 27, 2026
1029ccb
docs: Note contracts across files in the 0.2.0 release notes.
SwayamInSync Oct 27, 2026
84f2704
docs: Design trust on definitions and the settlement of contracts acr…
SwayamInSync Oct 27, 2026
2e878af
docs: Describe how a run over several files holds and settles its files.
SwayamInSync Oct 27, 2026
311e05c
verify: Add -fverify-contracts-out, where a compilation records its c…
SwayamInSync Oct 27, 2026
ddefb15
verify: Hold the path of -fverify-contracts-out in the frontend options.
SwayamInSync Oct 27, 2026
f677e84
verify: Pass -fverify-contracts-out on to the compiler.
SwayamInSync Oct 27, 2026
2add478
verify: Record a compilation's contracts where -fverify-contracts-out…
SwayamInSync Oct 27, 2026
e2cd399
verify: Let the compile-time verifier record the contracts of its file.
SwayamInSync Oct 27, 2026
8335a3d
verify: Declare --contracts-out and the check of files verified apart.
SwayamInSync Oct 27, 2026
0977359
verify: Record a file's contracts for the check of files verified apa…
SwayamInSync Oct 27, 2026
f3465ab
verify: Add --contracts-out and --check-contracts.
SwayamInSync Oct 27, 2026
0ff770e
test: Files verified apart record their contracts, and the check sett…
SwayamInSync Oct 27, 2026
5bcad91
docs: Describe the check of contracts across files verified apart.
SwayamInSync Oct 27, 2026
14a1d38
docs: Describe --contracts-out and --check-contracts.
SwayamInSync Oct 27, 2026
d3415ad
docs: Note the check of files verified apart in the limitations.
SwayamInSync Oct 27, 2026
6bbf01c
docs: Note the contracts check in the 0.2.0 release notes.
SwayamInSync Oct 27, 2026
a0ec728
docs: Point to the contracts check in the book's modular calls.
SwayamInSync Oct 27, 2026
7aac589
docs: List --contracts-out and --check-contracts in the book.
SwayamInSync Oct 27, 2026
c1da9c7
docs: Design the check of contracts across files verified apart.
SwayamInSync Oct 27, 2026
8accc5a
docs: Describe how files verified apart record and check their contra…
SwayamInSync Oct 27, 2026
903ec8a
Merge branch 'fix/command-line' into fix/inductive-counterexamples
SwayamInSync Oct 27, 2026
bef9c2d
Merge branch 'fix/inductive-counterexamples' into fix/function-filter
SwayamInSync Oct 27, 2026
3e9ab16
Merge branch 'fix/function-filter' into fix/max-failures
SwayamInSync Oct 27, 2026
bd3a975
Merge branch 'fix/max-failures' into fix/time-report
SwayamInSync Oct 27, 2026
1dbfd3a
Merge branch 'fix/time-report' into fix/contracts-across-files
SwayamInSync Oct 27, 2026
6b083e7
Merge branch 'fix/contracts-across-files' into fix/contract-link-check
SwayamInSync Oct 27, 2026
bc31159
Merge branch 'fix/command-line' into fix/inductive-counterexamples
SwayamInSync Oct 27, 2026
464bd0c
Merge branch 'fix/inductive-counterexamples' into fix/function-filter
SwayamInSync Oct 27, 2026
0e45a5a
Merge branch 'fix/function-filter' into fix/max-failures
SwayamInSync Oct 27, 2026
4f25030
Merge branch 'fix/max-failures' into fix/time-report
SwayamInSync Oct 27, 2026
ef5bf52
Merge branch 'fix/time-report' into fix/contracts-across-files
SwayamInSync Oct 27, 2026
27e26d3
Merge branch 'fix/contracts-across-files' into fix/contract-link-check
SwayamInSync Oct 27, 2026
2fbabe0
Merge main into fix/time-report.
SwayamInSync Oct 27, 2026
c7d0d75
Merge fix/time-report into fix/contracts-across-files.
SwayamInSync Oct 27, 2026
99de93c
Merge fix/contracts-across-files into fix/contract-link-check.
SwayamInSync Oct 27, 2026
20a8d3f
verify: Stop looking for an execution that fails a check unrolling dr…
SwayamInSync Oct 28, 2026
7f3c99a
docs: Say a failed invariant or measure gets no unrolling search in t…
SwayamInSync Oct 28, 2026
fec06f1
Merge fix/inductive-counterexamples into fix/function-filter.
SwayamInSync Oct 28, 2026
9b94fdd
Merge fix/function-filter into fix/max-failures.
SwayamInSync Oct 28, 2026
2963f92
Merge fix/max-failures into fix/time-report.
SwayamInSync Oct 28, 2026
f4f704b
test: Check that a failed invariant's search for an execution ends at…
SwayamInSync Oct 28, 2026
6364e43
Merge fix/time-report into fix/contracts-across-files.
SwayamInSync Oct 28, 2026
e602293
Merge fix/contracts-across-files into fix/contract-link-check.
SwayamInSync Oct 28, 2026
7e9f394
test: Fail confirmation_invariants.cpp's invariant at a bound the sol…
SwayamInSync Oct 28, 2026
bd84613
Merge fix/time-report into fix/contracts-across-files.
SwayamInSync Oct 28, 2026
e4f98d1
Merge fix/contracts-across-files into fix/contract-link-check.
SwayamInSync Oct 28, 2026
ff671bd
Merge main into fix/inductive-counterexamples.
SwayamInSync Oct 28, 2026
ea6cae1
Merge fix/inductive-counterexamples into fix/function-filter.
SwayamInSync Oct 28, 2026
fe9c326
Merge fix/function-filter into fix/max-failures.
SwayamInSync Oct 28, 2026
764db19
Merge fix/max-failures into fix/time-report.
SwayamInSync Oct 28, 2026
1ec7aef
Merge fix/time-report into fix/contracts-across-files.
SwayamInSync Oct 28, 2026
14b2769
Merge fix/contracts-across-files into fix/contract-link-check.
SwayamInSync Oct 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clang/include/clang/Frontend/FrontendOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,10 @@ class FrontendOptions {
/// (in the format produced by -fdump-record-layouts).
std::string OverrideRecordLayoutsFile;

/// Where CppVerify writes the contracts this file verifies and those it
/// assumes from other files, for cpp-verify --check-contracts.
std::string VerifyContractsOut;

/// Auxiliary triple for CUDA/HIP/SYCL compilation.
std::string AuxTriple;

Expand Down
6 changes: 6 additions & 0 deletions clang/include/clang/Options/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -2531,6 +2531,12 @@ defm verify_contracts : BoolFOption<"verify-contracts",
// default once contracts are enabled, and -fno-verify turns compilation into a
// syntax/semantics-only "light check". It implies -fverify-contracts (handled in
// the driver) because it is meaningless without the contract language.
def fverify_contracts_out_EQ : Joined<["-"], "fverify-contracts-out=">,
Group<f_clang_Group>, Visibility<[ClangOption, CC1Option]>,
MetaVarName<"<file>">,
HelpText<"Write the contracts CppVerify verifies in this file and those it "
"assumes from other files, for cpp-verify --check-contracts">,
MarshallingInfoString<FrontendOpts<"VerifyContractsOut">>;
def fno_verify : Flag<["-"], "fno-verify">, Group<f_clang_Group>,
Visibility<[ClangOption, CC1Option]>,
HelpText<"Check contract syntax and semantics but skip CppVerify SMT verification "
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/CodeGen/CodeGenAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ bool BackendConsumer::LinkInModules(llvm::Module *M) {
void BackendConsumer::HandleTranslationUnit(ASTContext &C) {
std::optional<std::future<verify::CppVerifyAsyncResult>> VerifyFuture;
if (verify::shouldRunCppVerify(CI))
VerifyFuture = verify::startCppVerifyAsync(C);
VerifyFuture =
verify::startCppVerifyAsync(C, CI.getFrontendOpts().VerifyContractsOut);

{
llvm::TimeTraceScope TimeScope("Frontend");
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6698,6 +6698,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// -fno-verify skips the SMT step. It is meaningless without the contract
// language, so when neither -f/-fno-verify-contracts was given it implies
// -fverify-contracts, yielding a syntax/semantics-only "light check".
Args.AddLastArg(CmdArgs, options::OPT_fverify_contracts_out_EQ);
if (Args.hasArg(options::OPT_fno_verify)) {
CmdArgs.push_back("-fno-verify");
if (!Args.hasArg(options::OPT_fverify_contracts) &&
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Verify/Backend/CVC5Backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2727,6 +2727,7 @@ CVC5VerifyBackend::verifyQuery(const ObligationModule &Module,
// One check may not spend the whole query.
auto checkLimits = [&] {
CertifyLimits Limits;
Limits.Times = times();
Limits.Deadline = QueryDeadline;
const unsigned CapMs = CertifyTimeoutMs ? *CertifyTimeoutMs : TimeoutMs / 2;
if (CapMs > 0) {
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Verify/Backend/Certify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3744,6 +3744,7 @@ CertifyResult verify::certifyCounterexample(const ObligationModule &Module,
const LogicExpr &Query,
CandidateModel &Model,
const CertifyLimits &Limits) {
TimeInto Checking(Limits.Times ? &Limits.Times->Certification : nullptr);
CertifyResult Result;
auto Run = [&] {
Evaluator Definitions(Module, Model, Limits, View::Definitions);
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Verify/Backend/Certify.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ struct CertifyLimits {
/// Set when Deadline is the time one counterexample check may take, not
/// the query's: the message then says so.
std::optional<unsigned> CheckTimeoutMs;
/// Where the checks' time is counted, for --time-report.
BackendTimes *Times = nullptr;
};

/// A logical application at concrete arguments whose model value differs from
Expand Down
44 changes: 44 additions & 0 deletions clang/lib/Verify/Backend/Timing.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//===--- Timing.h - Where a function's verification spends its time -----===//
#ifndef LLVM_CLANG_VERIFY_BACKEND_TIMING_H
#define LLVM_CLANG_VERIFY_BACKEND_TIMING_H

#include <atomic>
#include <chrono>
#include <cstdint>

namespace clang {
namespace verify {

/// The time the backends of one function's verification spend, in
/// nanoseconds: solving is the wall time in VerifyBackend::verify, induction
/// the part of it spent on inductions, and certification the time of the
/// counterexample checks, summed over checks that may run at once.
struct BackendTimes {
std::atomic<uint64_t> Solving{0};
std::atomic<uint64_t> Induction{0};
std::atomic<uint64_t> Certification{0};
};

/// Adds the time from its construction to its destruction to a counter, if
/// there is one.
class TimeInto {
std::atomic<uint64_t> *Counter;
std::chrono::steady_clock::time_point Start;

public:
explicit TimeInto(std::atomic<uint64_t> *Counter)
: Counter(Counter), Start(std::chrono::steady_clock::now()) {}
TimeInto(const TimeInto &) = delete;
TimeInto &operator=(const TimeInto &) = delete;
~TimeInto() {
if (Counter)
Counter->fetch_add(std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::steady_clock::now() - Start)
.count());
}
};

} // namespace verify
} // namespace clang

#endif
19 changes: 19 additions & 0 deletions clang/lib/Verify/Backend/VerifyBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ class BMCVerifyBackend : public VerifyBackend {
/*ReuseVerifiedQueries=*/true)),
MaxUnrollBound(UnrollBound) {}
llvm::StringRef getName() const override { return "bmc"; }
void setTimes(std::shared_ptr<BackendTimes> T) override {
Z3->setTimes(T);
VerifyBackend::setTimes(std::move(T));
}
std::optional<unsigned>
queryTimeoutMs(const ObligationModule &Module) const override {
return Z3->queryTimeoutMs(Module);
Expand Down Expand Up @@ -232,6 +236,11 @@ class PortfolioVerifyBackend : public VerifyBackend {
MaxQueryNodes(Execution.MaxQueryNodes) {}

llvm::StringRef getName() const override { return "portfolio"; }
void setTimes(std::shared_ptr<BackendTimes> T) override {
Z3->setTimes(T);
CVC5->setTimes(T);
VerifyBackend::setTimes(std::move(T));
}
std::optional<unsigned>
queryTimeoutMs(const ObligationModule &Module) const override {
return Z3->queryTimeoutMs(Module);
Expand Down Expand Up @@ -499,6 +508,7 @@ void verify::requestInterrupt() { InterruptFlag.store(true); }
bool verify::interruptRequested() { return InterruptFlag.load(); }

VerifyResult VerifyBackend::verify(const ObligationModule &Module) {
TimeInto Solving(Times ? &Times->Solving : nullptr);
VerifyResult Result = verifyDirect(Module);
if (Module.Attempt != ModuleAttempt::Primary ||
Result.Status != VerifyStatus::Unresolved ||
Expand All @@ -522,6 +532,7 @@ VerifyResult VerifyBackend::verify(const ObligationModule &Module) {
}
setDeadline(Until);
llvm::scope_exit Restore([&] { setDeadline(Saved); });
TimeInto Inducting(Times ? &Times->Induction : nullptr);
std::vector<std::string> Tried;
for (const InductionScheme &Scheme : inductionSchemes(Module)) {
if (Until && std::chrono::steady_clock::now() >= *Until)
Expand Down Expand Up @@ -614,6 +625,9 @@ VerifyResult VerifyBackend::verifyDirect(const ObligationModule &Module) {
VerifyResult Result = verifyModule(Module);
if (Result.BackendName.empty())
Result.BackendName = getName().str();
for (VerifyResult &More : Result.MoreFailures)
if (More.BackendName.empty())
More.BackendName = Result.BackendName;
if (!Capabilities.ProducesVerificationVerdict &&
Result.Status != VerifyStatus::Exported &&
Result.Status != VerifyStatus::Unresolved) {
Expand Down Expand Up @@ -686,6 +700,11 @@ class RaceVerifyBackend : public VerifyBackend {
MaxQueryNodes(Execution.MaxQueryNodes) {}

llvm::StringRef getName() const override { return "race"; }
void setTimes(std::shared_ptr<BackendTimes> T) override {
Z3->setTimes(T);
CVC5->setTimes(T);
VerifyBackend::setTimes(std::move(T));
}
std::optional<unsigned>
queryTimeoutMs(const ObligationModule &Module) const override {
return Z3->queryTimeoutMs(Module);
Expand Down
13 changes: 13 additions & 0 deletions clang/lib/Verify/Backend/VerifyBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define LLVM_CLANG_VERIFY_BACKEND_VERIFYBACKEND_H

#include "Obligation.h"
#include "Timing.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ThreadPool.h"
#include <chrono>
Expand Down Expand Up @@ -146,6 +147,9 @@ struct VerifyResult {
std::string Message;
std::vector<VerifyModelValue> Model;
std::vector<VerifyTraceEvent> Trace;
/// The failing obligations after this one, in order, each with its own
/// counterexample, as many as the run's MaxFailures allows.
std::vector<VerifyResult> MoreFailures;
std::string ObligationId;
std::optional<ObligationKind> ObligationType;
/// For a certified counterexample: the value of every free variable of the
Expand Down Expand Up @@ -217,6 +221,10 @@ class VerifyBackend {
FunctionDeadline = D;
applyDeadline(D);
}
/// Counts the time this backend spends into \p T, for --time-report.
virtual void setTimes(std::shared_ptr<BackendTimes> T) {
Times = std::move(T);
}
/// Stops the work in progress, from any thread: queries running end
/// unresolved and no further one starts, until resume().
virtual void cancel() {}
Expand All @@ -232,9 +240,11 @@ class VerifyBackend {
/// Limits the queries that start from now on to \p D.
virtual void
applyDeadline(std::optional<std::chrono::steady_clock::time_point> D) {}
BackendTimes *times() const { return Times.get(); }

private:
std::optional<std::chrono::steady_clock::time_point> FunctionDeadline;
std::shared_ptr<BackendTimes> Times;
};

/// Race: Z3 and cvc5 at once, the first proof or certified counterexample
Expand Down Expand Up @@ -287,6 +297,9 @@ struct BackendExecutionOptions {
/// unresolved. Interactive fallback backends can consume those unresolved
/// obligations without spending a second whole-module timeout budget.
bool SkipWholeModuleRetry = false;
/// How many failing obligations of a module are reported, each with its
/// own counterexample; 0 reports every one.
unsigned MaxFailures = 1;
/// Solve the whole-module query once, at the full budget, and report it:
/// no per-obligation queries, refinement fallback, or induction. For small
/// auxiliary questions such as the vacuity checks.
Expand Down
Loading
Loading