Skip to content

Commit

Permalink
Merge branch 'pathImprovements' into 'main'
Browse files Browse the repository at this point in the history
Reduce posibility of problems caused by filenames/paths differences

See merge request repositories/verilator-infrastructure-bugpoint!25
  • Loading branch information
sgizler committed Oct 9, 2024
2 parents 8fff990 + 8b9d26b commit e3812a3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ sv-bugpoint <OUT_DIR> <CHECK_SCRIPT> <INPUT_SV>

The output directory will be populated with:
- `sv-bugpoint-minimized.sv` - minimized code that satisfies the assertion checked by the provided script,
- `sv-bugpoint-tmp.sv` - a copy of the previous file with a removal attempt applied, to be checked with the provided script,
- `tmp/<INPUT_SV>` - a copy of the previous file with a removal attempt applied, to be checked with the provided script,
- `sv-bugpoint-trace` - verbose, tab-delimited trace with stats and additional info about each removal attempt ([example](examples/caliptra_verilation_err/sv-bugpoint-trace)).
It can be turned into a concise, high-level summary with the [`sv-bugpoint-trace_summary script`](scripts/sv-bugpoint-trace_summary) ([example](examples/caliptra_verilation_err/sv-bugpoint-trace_summarized)).

Expand Down
4 changes: 2 additions & 2 deletions scripts/sv-bugpoint-strip-verilator-errmsg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
# SPDX-License-Identifier: Apache-2.0

# strip volatile metadata like filenames, filelines and redundant whitespace
# strip volatile metadata like paths, filelines and redundant whitespace
# from verilator errmsg so it can be reliably compared
sed 's/[/a-z0-9_-]*.sv//g' | sed 's/:[0-9]*//g' | sed 's/[0-9]* |//g' | sed 's/[\t\n ]\+/ /g'
sed 's/[./a-z0-9_-]*.sv//g' | sed 's/:[0-9]*//g' | sed 's/[0-9]* |//g' | sed 's/[\t\n ]\+/ /g'
12 changes: 12 additions & 0 deletions source/SvBugpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,24 @@ void initOutDir(bool force) {
exit(0);
}
}
mkdir(paths.tmpDir);
if (saveIntermediates)
mkdir(paths.intermediateDir);
// NOTE: not removing old files may be misleading (especially having an intermediate dir)
// Maybe add some kind of purge?
copyFile(paths.input, paths.output);
copyFile(paths.input, paths.tmpOutput);
AttemptStats::writeHeader();
}

void dryRun() {
auto info = AttemptStats("-", "dryRun");
if(!test(info)) {
std::cerr << "sv-bugpoint: '" << paths.checkScript << " " << paths.tmpOutput << "' exited with non-zero on dry run with unmodified input.\n";
exit(1);
}
}

void usage() {
std::cerr << "Usage: sv-bugpoint [options] outDir/ checkscript.sh input.sv\n";
std::cerr << "Options:\n";
Expand Down Expand Up @@ -143,5 +153,7 @@ int main(int argc, char** argv) {
dumpTrees();
}

dryRun();

minimize();
}
4 changes: 3 additions & 1 deletion source/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct Paths {
std::string checkScript;
std::string input;
std::string output;
std::string tmpDir;
std::string tmpOutput;
std::string trace;
std::string dumpSyntax;
Expand All @@ -29,7 +30,8 @@ struct Paths {
Paths(std::string outDir, std::string checkScript, std::string input)
: outDir(outDir), input(input), checkScript(checkScript) {
output = outDir + "/sv-bugpoint-minimized.sv";
tmpOutput = outDir + "/sv-bugpoint-tmp.sv";
tmpDir = outDir + "/tmp/";
tmpOutput = tmpDir + std::string(std::filesystem::path(input).filename());
trace = outDir + "/sv-bugpoint-trace";
dumpSyntax = outDir + "/sv-bugpoint-dump-syntax";
dumpAst = outDir + "/sv-bugpoint-dump-ast";
Expand Down

0 comments on commit e3812a3

Please sign in to comment.