[clang] [clang][utils] Add auto mode to reduction script (PR #163282)
Arthur Eubanks via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 15 16:14:41 PDT 2025
================
@@ -424,11 +490,76 @@ def run_creduce(self):
print("\n\nctrl-c detected, killed reduction tool")
p.kill()
+ def run_llvm_reduce(self):
+ full_llvm_reduce_cmd = [
+ llvm_reduce_cmd,
+ f"--test={self.testfile}",
+ self.ir_file,
+ ]
+ print("\nRunning llvm-reduce tool...")
+ verbose_print(quote_cmd(full_llvm_reduce_cmd))
+ try:
+ p = subprocess.Popen(full_llvm_reduce_cmd)
+ p.communicate()
+ except KeyboardInterrupt:
+ # Hack to kill C-Reduce because it jumps into its own pgid
+ print("\n\nctrl-c detected, killed reduction tool")
+ p.kill()
+
+ def classify_crash(self) -> FailureType:
+ print("classifying crash ...")
+ if self.check_expected_output(args=self.clang_args + ["-fsyntax-only"]):
+ print("Found Frontend Crash")
+ return FailureType.FrontEnd
+
+ print("Found Middle/Backend failure")
+ args = self.clang_args + [
+ "-mllvm",
+ "--print-on-crash",
+ "-mllvm",
+ f"--print-on-crash-path={self.ir_file}",
+ "-mllvm",
+ "--print-module-scope",
+ ]
+
+ if not self.check_expected_output(args=args):
+ sys.exit("The interestingness test does not pass with '--print-on-crash'.")
+
+ # The output from --print-on-crash has an invalid first line (pass name).
+ remove_first_line(self.ir_file)
+
+ self.opt_level = extract_opt_level(self.clang_args) or "-O2"
+
+ if self.check_expected_output(
----------------
aeubanks wrote:
iiuc `opt` won't crash here because the IR we're passing it has already been through the optimization pipeline. we need to generate the IR with `-Xclang -disable-llvm-passes`
https://github.com/llvm/llvm-project/pull/163282
More information about the cfe-commits
mailing list