Skip to content

Commit c8b45a4

Browse files
committed
bugpoint: add runner option
1 parent f71c2dc commit c8b45a4

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

manual/command-reference-manual.tex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,9 @@ \section{bugpoint -- minimize testcases}
656656

657657
-updates
658658
try to remove process updates from syncs.
659+
660+
-runner "<prefix>"
661+
child process wrapping command, e.g., "timeout 30", or valgrind.
659662
\end{lstlisting}
660663

661664
\section{cd -- a shortcut for 'select -module <name>'}

passes/cmds/bugpoint.cc

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,20 @@ struct BugpointPass : public Pass {
8787
log(" -updates\n");
8888
log(" try to remove process updates from syncs.\n");
8989
log("\n");
90+
log(" -runner \"<prefix>\"\n");
91+
log(" child process wrapping command, e.g., \"timeout 30\", or valgrind.\n");
92+
log("\n");
9093
}
9194

92-
bool run_yosys(RTLIL::Design *design, string yosys_cmd, string yosys_arg)
95+
bool run_yosys(RTLIL::Design *design, string runner, string yosys_cmd, string yosys_arg)
9396
{
9497
design->sort();
9598

9699
std::ofstream f("bugpoint-case.il");
97100
RTLIL_BACKEND::dump_design(f, design, /*only_selected=*/false, /*flag_m=*/true, /*flag_n=*/false);
98101
f.close();
99102

100-
string yosys_cmdline = stringf("%s -qq -L bugpoint-case.log %s bugpoint-case.il", yosys_cmd.c_str(), yosys_arg.c_str());
103+
string yosys_cmdline = stringf("%s %s -qq -L bugpoint-case.log %s bugpoint-case.il", runner.c_str(), yosys_cmd.c_str(), yosys_arg.c_str());
101104
return run_command(yosys_cmdline) == 0;
102105
}
103106

@@ -394,7 +397,7 @@ struct BugpointPass : public Pass {
394397

395398
void execute(std::vector<std::string> args, RTLIL::Design *design) override
396399
{
397-
string yosys_cmd = "yosys", yosys_arg, grep;
400+
string yosys_cmd = "yosys", yosys_arg, grep, runner;
398401
bool fast = false, clean = false;
399402
bool modules = false, ports = false, cells = false, connections = false, processes = false, assigns = false, updates = false, wires = false, has_part = false;
400403

@@ -472,6 +475,14 @@ struct BugpointPass : public Pass {
472475
has_part = true;
473476
continue;
474477
}
478+
if (args[argidx] == "-runner" && argidx + 1 < args.size()) {
479+
runner = args[++argidx];
480+
if (runner.size() && runner.at(0) == '"') {
481+
log_assert(runner.back() == '"');
482+
runner = runner.substr(1, runner.size() - 2);
483+
}
484+
continue;
485+
}
475486
break;
476487
}
477488
extra_args(args, argidx, design);
@@ -495,7 +506,7 @@ struct BugpointPass : public Pass {
495506
log_cmd_error("This command only operates on fully selected designs!\n");
496507

497508
RTLIL::Design *crashing_design = clean_design(design, clean);
498-
if (run_yosys(crashing_design, yosys_cmd, yosys_arg))
509+
if (run_yosys(crashing_design, runner, yosys_cmd, yosys_arg))
499510
log_cmd_error("The provided script file or command and Yosys binary do not crash on this design!\n");
500511
if (!check_logfile(grep))
501512
log_cmd_error("The provided grep string is not found in the log file!\n");
@@ -512,12 +523,12 @@ struct BugpointPass : public Pass {
512523
if (clean)
513524
{
514525
RTLIL::Design *testcase = clean_design(simplified);
515-
crashes = !run_yosys(testcase, yosys_cmd, yosys_arg);
526+
crashes = !run_yosys(testcase, runner, yosys_cmd, yosys_arg);
516527
delete testcase;
517528
}
518529
else
519530
{
520-
crashes = !run_yosys(simplified, yosys_cmd, yosys_arg);
531+
crashes = !run_yosys(simplified, runner, yosys_cmd, yosys_arg);
521532
}
522533

523534
if (crashes && check_logfile(grep))

0 commit comments

Comments
 (0)