tv plugin: don't print tgt if it's syntactic equal
MODIFY
tools/transform.cpp
tools/transform.cpp
@@ -1535,9 +1535,11 @@ void Transform::print(ostream &os, const TransformPrintOpts &opt) const {
os << '\n';
}
src.print(os, opt.print_fn_header);
+ if (!opt.skip_tgt) {
os << "=>\n";
tgt.print(os, opt.print_fn_header);
}
+}
ostream& operator<<(ostream &os, const Transform &t) {
t.print(os, {});

MODIFY
tools/transform.h
tools/transform.h
@@ -18,6 +18,7 @@ namespace tools {
struct TransformPrintOpts {
bool print_fn_header = true;
+ bool skip_tgt = false;
};
@@ -27,7 +28,7 @@ struct Transform {
IR::Predicate *precondition = nullptr;
void preprocess();
- void print(std::ostream &os, const TransformPrintOpts &opt) const;
+ void print(std::ostream &os, const TransformPrintOpts &opt = {}) const;
friend std::ostream& operator<<(std::ostream &os, const Transform &t);
};

MODIFY
tv/tv.cpp
tv/tv.cpp
@@ -72,7 +72,6 @@ struct FnInfo {
optional<smt::smt_initializer> smt_init;
optional<llvm_util::initializer> llvm_util_init;
-TransformPrintOpts print_opts;
unordered_map<string, FnInfo> fns;
unsigned initialized = 0;
bool showed_stats = false;
@@ -245,8 +244,11 @@ 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 (!opt_quiet) {
+ TransformPrintOpts print_opts;
+ print_opts.skip_tgt = true;
t.print(*out, print_opts);
+ }
*out << "Transformation seems to be correct! (syntactically equal)\n\n";
return;
}
@@ -306,7 +308,7 @@ struct TVLegacyPass final : public llvm::ModulePass {
t.preprocess();
TransformVerify verifier(t, false);
if (!opt_quiet)
- t.print(*out, print_opts);
+ t.print(*out);
{
auto types = verifier.getTypings();

tv plugin: don't print tgt if it's syntactic equal