Skip to content

Generalize creduce-clang-crash.py script to look for cvise #128592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2025

Conversation

rnk
Copy link
Collaborator

@rnk rnk commented Feb 24, 2025

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.

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.
@rnk rnk requested review from lnihlen and bricknerb February 24, 2025 22:54
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Feb 24, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 24, 2025

@llvm/pr-subscribers-clang

Author: Reid Kleckner (rnk)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/128592.diff

1 Files Affected:

  • (renamed) clang/utils/reduce-clang-crash.py (+11-9)
diff --git a/clang/utils/creduce-clang-crash.py b/clang/utils/reduce-clang-crash.py
similarity index 96%
rename from clang/utils/creduce-clang-crash.py
rename to clang/utils/reduce-clang-crash.py
index 180dfbeab224e..22e3dbb8f9b3f 100755
--- a/clang/utils/creduce-clang-crash.py
+++ b/clang/utils/reduce-clang-crash.py
@@ -1,11 +1,12 @@
 #!/usr/bin/env python3
-"""Calls C-Reduce to create a minimal reproducer for clang crashes.
-Unknown arguments are treated at creduce options.
+"""Calls reduction tools to create minimal reproducers for clang crashes.
+
+Unknown arguments are treated at cvise/creduce options.
 
 Output files:
   *.reduced.sh -- crash reproducer with minimal arguments
   *.reduced.cpp -- the reduced file
-  *.test.sh -- interestingness test for C-Reduce
+  *.test.sh -- interestingness test for C-Vise
 """
 
 from argparse import ArgumentParser, RawTextHelpFormatter
@@ -311,7 +312,7 @@ def try_remove_arg_by_index(self, args, index):
         return args, index + 1
 
     def simplify_clang_args(self):
-        """Simplify clang arguments before running C-Reduce to reduce the time the
+        """Simplify clang arguments before running C-Vise to reduce the time the
         interestingness test takes to run.
         """
         print("\nSimplifying the clang command...")
@@ -370,7 +371,7 @@ def simplify_clang_args(self):
         verbose_print("Simplified command:", quote_cmd(self.get_crash_cmd()))
 
     def reduce_clang_args(self):
-        """Minimize the clang arguments after running C-Reduce, to get the smallest
+        """Minimize the clang arguments after running C-Vise, to get the smallest
         command that reproduces the crash on the reduced file.
         """
         print("\nReducing the clang crash command...")
@@ -413,14 +414,14 @@ def run_creduce(self):
         full_creduce_cmd = (
             [creduce_cmd] + self.creduce_flags + [self.testfile, self.file_to_reduce]
         )
-        print("\nRunning C-Reduce...")
+        print("\nRunning C reduction tool...")
         verbose_print(quote_cmd(full_creduce_cmd))
         try:
             p = subprocess.Popen(full_creduce_cmd)
             p.communicate()
         except KeyboardInterrupt:
             # Hack to kill C-Reduce because it jumps into its own pgid
-            print("\n\nctrl-c detected, killed creduce")
+            print("\n\nctrl-c detected, killed reduction tool")
             p.kill()
 
 
@@ -453,14 +454,15 @@ def main():
         "--creduce",
         dest="creduce",
         type=str,
-        help="The path to the `creduce` executable. "
-        "Required if `creduce` is not in PATH environment.",
+        help="The path to the `creduce` or `cvise` executable. "
+        "Required if neither `creduce` nor `cvise` are on PATH.",
     )
     parser.add_argument("-v", "--verbose", action="store_true")
     args, creduce_flags = parser.parse_known_args()
     verbose = args.verbose
     llvm_bin = os.path.abspath(args.llvm_bin) if args.llvm_bin else None
     creduce_cmd = check_cmd("creduce", None, args.creduce)
+    creduce_cmd = check_cmd("cvise", None, args.creduce)
     clang_cmd = check_cmd("clang", llvm_bin, args.clang)
 
     crash_script = check_file(args.crash_script[0])

@rnk rnk merged commit 59cee03 into llvm:main Feb 25, 2025
13 checks passed
@bricknerb bricknerb requested a review from emaxx-google March 5, 2025 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants