Skip to content

Commit

Permalink
Make the -quiet flag skip counter-example printing (#1163)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmciver authored Jan 26, 2025
1 parent 0dcc0ba commit 2246767
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions llvm_util/cmd_args_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ config::smt_benchmark_dir = opt_smt_bench_dir;
smt::solver_print_queries(opt_smt_verbose);
smt::solver_tactic_verbose(opt_tactic_verbose);
config::debug = opt_debug;
config::quiet = opt_quiet;
config::max_offset_bits = opt_max_offset_in_bits;
config::max_sizet_bits = opt_max_sizet_in_bits;

Expand Down
9 changes: 5 additions & 4 deletions llvm_util/compare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "llvm_util/llvm_optimizer.h"
#include "smt/smt.h"
#include "tools/transform.h"
#include "util/config.h"

#include <sstream>
#include <utility>
Expand Down Expand Up @@ -96,7 +97,7 @@ Results verify(llvm::Function &F1, llvm::Function &F2,
} // namespace

bool Verifier::compareFunctions(llvm::Function &F1, llvm::Function &F2) {
auto r = verify(F1, F2, TLI, smt_init, out, !quiet, always_verify);
auto r = verify(F1, F2, TLI, smt_init, out, !config::quiet, always_verify);
if (r.status == Results::ERROR) {
out << "ERROR: " << r.error;
++num_errors;
Expand Down Expand Up @@ -134,7 +135,7 @@ bool Verifier::compareFunctions(llvm::Function &F1, llvm::Function &F2) {

case Results::UNSOUND:
out << "Transformation doesn't verify!\n\n";
if (!quiet)
if (!config::quiet)
out << r.errs << endl;
++num_unsound;
return false;
Expand All @@ -160,13 +161,13 @@ bool Verifier::compareFunctions(llvm::Function &F1, llvm::Function &F2) {

case Results::FAILED_TO_PROVE:
out << "Failed to verify the reverse transformation\n\n";
if (!quiet)
if (!config::quiet)
out << r.errs << endl;
return true;

case Results::UNSOUND:
out << "Reverse transformation doesn't verify!\n\n";
if (!quiet)
if (!config::quiet)
out << r.errs << endl;
return false;
}
Expand Down
1 change: 0 additions & 1 deletion llvm_util/compare.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ struct Verifier {
unsigned num_unsound = 0;
unsigned num_failed = 0;
unsigned num_errors = 0;
bool quiet = false;
bool always_verify = false;
bool print_dot = false;
bool bidirectional = false;
Expand Down
10 changes: 5 additions & 5 deletions tools/alive-exec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ optional<StateValue> exec(llvm::Function &F,
return {};
}

if (!opt_quiet)
if (!config::quiet)
Func->print(cout << "\n----------------------------------------\n");

{
Expand Down Expand Up @@ -99,7 +99,7 @@ optional<StateValue> exec(llvm::Function &F,
auto It = curr_bb->instrs().begin();
Solver solver(true);

if (!opt_quiet)
if (!config::quiet)
cout << "Executing " << curr_bb->getName() << '\n';

while (true) {
Expand All @@ -120,7 +120,7 @@ optional<StateValue> exec(llvm::Function &F,
if (dynamic_cast<const Return*>(&next_instr)) {
assert(r.isSat());
auto ret = eval(r, state.returnVal().val);
if (!opt_quiet)
if (!config::quiet)
cout << "Returned " << ret << '\n';
return ret;
}
Expand All @@ -137,7 +137,7 @@ optional<StateValue> exec(llvm::Function &F,
return {};

if (r.isSat()) {
if (!opt_quiet)
if (!config::quiet)
cout << " >> Jump to " << dst.getName() << "\n\n";
curr_bb = &dst;
state.startBB(dst);
Expand Down Expand Up @@ -166,7 +166,7 @@ optional<StateValue> exec(llvm::Function &F,
return {};
}

if (!opt_quiet) {
if (!config::quiet) {
cout << name;
if (name[0] == '%') {
auto v = eval(r, val.val);
Expand Down
1 change: 0 additions & 1 deletion tools/alive-tv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ and "tgt5" will unused.
llvm_util::initializer llvm_util_init(*out, DL);
smt::smt_initializer smt_init;
Verifier verifier(TLI, smt_init, *out);
verifier.quiet = opt_quiet;
verifier.always_verify = opt_always_verify;
verifier.print_dot = opt_print_dot;
verifier.bidirectional = opt_bidirectional;
Expand Down
1 change: 0 additions & 1 deletion tools/quick-fuzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,6 @@ reduced using llvm-reduce.
llvm_util::initializer llvm_util_init(*out, DL);
smt::smt_initializer smt_init;
Verifier verifier(TLI, smt_init, *out);
verifier.quiet = opt_quiet;
verifier.always_verify = opt_always_verify;
verifier.print_dot = opt_print_dot;
verifier.bidirectional = opt_bidirectional;
Expand Down
6 changes: 6 additions & 0 deletions tools/transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ static bool error(Errors &errs, State &src_state, State &tgt_state,
}
}

// Return early if instance reporting is not requested.
if (config::quiet) {
errs.add(msg, true);
return false;
}

// minimize the model
optional<Result> newr;

Expand Down
4 changes: 2 additions & 2 deletions tv/tv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ struct TVLegacyPass final : public llvm::ModulePass {
if (!opt_always_verify) {
// Compare Alive2 IR and skip if syntactically equal
if (src_tostr == tgt_tostr) {
if (!opt_quiet) {
if (!config::quiet) {
TransformPrintOpts print_opts;
print_opts.skip_tgt = true;
t.print(*out, print_opts);
Expand Down Expand Up @@ -311,7 +311,7 @@ struct TVLegacyPass final : public llvm::ModulePass {
smt_init->reset();
t.preprocess();
TransformVerify verifier(t, false);
if (!opt_quiet)
if (!config::quiet)
t.print(*out);

{
Expand Down
1 change: 1 addition & 0 deletions util/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ bool tgt_is_asm = false;
bool fail_if_src_is_ub = false;
bool disallow_ub_exploitation = false;
bool debug = false;
bool quiet = false;
unsigned src_unroll_cnt = 0;
unsigned tgt_unroll_cnt = 0;
unsigned max_offset_bits = 64;
Expand Down
2 changes: 2 additions & 0 deletions util/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ extern bool disallow_ub_exploitation;

extern bool debug;

extern bool quiet;

extern unsigned src_unroll_cnt;

extern unsigned tgt_unroll_cnt;
Expand Down

0 comments on commit 2246767

Please sign in to comment.