Skip to content

Commit 59cee03

Browse files
authored
Generalize creduce-clang-crash.py script to look for cvise (#128592)
cvise reimplements creduce in Python and bundles clang-delta and other tools. In my experience, it is generally a more robust reduction tool that is better maintained. I renamed the script to make it tool-neutral, which also opens up the possibility that we teach it how to automatically transition over to llvm-reduce and opt/llc to handle LLVM backend crashes, but that is potential future work. Internally, the variable names still say "creduce". I kept using the verb "reduce" because "vise" is not a verb, but the external facing text has been updated.
1 parent 8beec9f commit 59cee03

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

clang/utils/creduce-clang-crash.py renamed to clang/utils/reduce-clang-crash.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/usr/bin/env python3
2-
"""Calls C-Reduce to create a minimal reproducer for clang crashes.
3-
Unknown arguments are treated at creduce options.
2+
"""Calls reduction tools to create minimal reproducers for clang crashes.
3+
4+
Unknown arguments are treated at cvise/creduce options.
45
56
Output files:
67
*.reduced.sh -- crash reproducer with minimal arguments
78
*.reduced.cpp -- the reduced file
8-
*.test.sh -- interestingness test for C-Reduce
9+
*.test.sh -- interestingness test for C-Vise
910
"""
1011

1112
from argparse import ArgumentParser, RawTextHelpFormatter
@@ -311,7 +312,7 @@ def try_remove_arg_by_index(self, args, index):
311312
return args, index + 1
312313

313314
def simplify_clang_args(self):
314-
"""Simplify clang arguments before running C-Reduce to reduce the time the
315+
"""Simplify clang arguments before running C-Vise to reduce the time the
315316
interestingness test takes to run.
316317
"""
317318
print("\nSimplifying the clang command...")
@@ -370,7 +371,7 @@ def simplify_clang_args(self):
370371
verbose_print("Simplified command:", quote_cmd(self.get_crash_cmd()))
371372

372373
def reduce_clang_args(self):
373-
"""Minimize the clang arguments after running C-Reduce, to get the smallest
374+
"""Minimize the clang arguments after running C-Vise, to get the smallest
374375
command that reproduces the crash on the reduced file.
375376
"""
376377
print("\nReducing the clang crash command...")
@@ -413,14 +414,14 @@ def run_creduce(self):
413414
full_creduce_cmd = (
414415
[creduce_cmd] + self.creduce_flags + [self.testfile, self.file_to_reduce]
415416
)
416-
print("\nRunning C-Reduce...")
417+
print("\nRunning C reduction tool...")
417418
verbose_print(quote_cmd(full_creduce_cmd))
418419
try:
419420
p = subprocess.Popen(full_creduce_cmd)
420421
p.communicate()
421422
except KeyboardInterrupt:
422423
# Hack to kill C-Reduce because it jumps into its own pgid
423-
print("\n\nctrl-c detected, killed creduce")
424+
print("\n\nctrl-c detected, killed reduction tool")
424425
p.kill()
425426

426427

@@ -453,14 +454,15 @@ def main():
453454
"--creduce",
454455
dest="creduce",
455456
type=str,
456-
help="The path to the `creduce` executable. "
457-
"Required if `creduce` is not in PATH environment.",
457+
help="The path to the `creduce` or `cvise` executable. "
458+
"Required if neither `creduce` nor `cvise` are on PATH.",
458459
)
459460
parser.add_argument("-v", "--verbose", action="store_true")
460461
args, creduce_flags = parser.parse_known_args()
461462
verbose = args.verbose
462463
llvm_bin = os.path.abspath(args.llvm_bin) if args.llvm_bin else None
463464
creduce_cmd = check_cmd("creduce", None, args.creduce)
465+
creduce_cmd = check_cmd("cvise", None, args.creduce)
464466
clang_cmd = check_cmd("clang", llvm_bin, args.clang)
465467

466468
crash_script = check_file(args.crash_script[0])

0 commit comments

Comments
 (0)