diff options
author | Balazs Benics <benicsbalazs@gmail.com> | 2025-01-06 18:08:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-06 18:08:12 +0100 |
commit | 55391f85acc7e7a14ea2ef3c1a4bd8f3df990426 (patch) | |
tree | b6731c2c0af045733cedaf27b771d7c1027f5072 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 5e0be962feb37b224590e91879f9ac4a1fcacb85 (diff) | |
download | llvm-55391f85acc7e7a14ea2ef3c1a4bd8f3df990426.zip llvm-55391f85acc7e7a14ea2ef3c1a4bd8f3df990426.tar.gz llvm-55391f85acc7e7a14ea2ef3c1a4bd8f3df990426.tar.bz2 |
[analyzer] Retry UNDEF Z3 queries 2 times by default (#120239)
If we have a refutation Z3 query timed out (UNDEF), allow a couple of
retries to improve stability of the query. By default allow 2 retries,
which will give us in maximum of 3 solve attempts per query.
Retries should help mitigating flaky Z3 queries.
See the details in the following RFC:
https://discourse.llvm.org/t/analyzer-rfc-retry-z3-crosscheck-queries-on-timeout/83711
Note that with each attempt, we spend more time per query.
Currently, we have a 15 seconds timeout per query - which are also in
effect for the retry attempts.
---
Why should this help?
In short, retrying queries should bring stability because if a query
runs long
it's more likely that it did so due to some runtime anomaly than it's on
the edge of succeeding. This is because most queries run quick, and the
queries that run long, usually run long by a fair amount.
Consequently, retries should improve the stability of the outcome of the
Z3 query.
In general, the retries shouldn't increase the overall analysis time
because it's really rare we hit the 0.1% of the cases when we would do
retries. But keep in mind that the retry attempts can add up if many
retries are allowed, or the individual query timeout is large.
CPP-5920
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 36dc45b..6e47b37 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1260,6 +1260,25 @@ static void initOption(AnalyzerOptions::ConfigTable &Config, << Name << "an unsigned"; } +static void initOption(AnalyzerOptions::ConfigTable &Config, + DiagnosticsEngine *Diags, + PositiveAnalyzerOption &OptionField, StringRef Name, + unsigned DefaultVal) { + auto Parsed = PositiveAnalyzerOption::create( + getStringOption(Config, Name, std::to_string(DefaultVal))); + if (Parsed.has_value()) { + OptionField = Parsed.value(); + return; + } + if (Diags && !Parsed.has_value()) + Diags->Report(diag::err_analyzer_config_invalid_input) + << Name << "a positive"; + + auto Default = PositiveAnalyzerOption::create(DefaultVal); + assert(Default.has_value()); + OptionField = Default.value(); +} + static void parseAnalyzerConfigs(AnalyzerOptions &AnOpts, DiagnosticsEngine *Diags) { // TODO: There's no need to store the entire configtable, it'd be plenty |