From: Mikhail R. Gadelha Date: Wed, 25 Jul 2018 12:49:32 +0000 (+0000) Subject: [analyzer] Try to minimize the number of equivalent bug reports evaluated by the... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c7f89ad69d78425ebcc41dbbb93f52dc7b1b5546;p=platform%2Fupstream%2Fllvm.git [analyzer] Try to minimize the number of equivalent bug reports evaluated by the refutation manager Summary: This patch changes how the SMT bug refutation runs in an equivalent bug report class. Now, all other visitor are executed until they find a valid bug or mark all bugs as invalid. When the one valid bug is found (and crosscheck is enabled), the SMT refutation checks the satisfiability of this single bug. If the bug is still valid after checking with Z3, it is returned and a bug report is created. If the bug is found to be invalid, the next bug report in the equivalent class goes through the same process, until we find a valid bug or all bugs are marked as invalid. Massive speedups when verifying redis/src/rax.c, from 1500s to 10s. Reviewers: NoQ, george.karpenkov Reviewed By: george.karpenkov Subscribers: xazax.hun, szepet, a.sidorin Differential Revision: https://reviews.llvm.org/D49693 llvm-svn: 337920 --- diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index 096c8e7..f990eb6 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -2605,8 +2605,6 @@ std::pair> findValidReport( // Register refutation visitors first, if they mark the bug invalid no // further analysis is required R->addVisitor(llvm::make_unique()); - if (Opts.shouldCrosscheckWithZ3()) - R->addVisitor(llvm::make_unique()); // Register additional node visitors. R->addVisitor(llvm::make_unique()); @@ -2619,9 +2617,24 @@ std::pair> findValidReport( std::unique_ptr visitorNotes = generateVisitorsDiagnostics(R, ErrorNode, BRC); - if (R->isValid()) - return std::make_pair(R, std::move(visitorNotes)); + if (R->isValid()) { + if (Opts.shouldCrosscheckWithZ3()) { + // If crosscheck is enabled, remove all visitors, add the refutation + // visitor and check again + R->clearVisitors(); + R->addVisitor(llvm::make_unique()); + + // We don't overrite the notes inserted by other visitors because the + // refutation manager does not add any new note to the path + generateVisitorsDiagnostics(R, ErrorGraph.ErrorNode, BRC); + } + + // Check if the bug is still valid + if (R->isValid()) + return std::make_pair(R, std::move(visitorNotes)); + } } + return std::make_pair(nullptr, llvm::make_unique()); }