[llvm] 792253a - [llvm][docs] Add example use of `llvm-reduce`. (#73237)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 29 12:16:25 PST 2023
Author: Francesco Petrogalli
Date: 2023-11-29T21:16:20+01:00
New Revision: 792253ae0ef3acf9e55f92de25e0bd47a8531d1a
URL: https://github.com/llvm/llvm-project/commit/792253ae0ef3acf9e55f92de25e0bd47a8531d1a
DIFF: https://github.com/llvm/llvm-project/commit/792253ae0ef3acf9e55f92de25e0bd47a8531d1a.diff
LOG: [llvm][docs] Add example use of `llvm-reduce`. (#73237)
The script is based on an example provided by Tim
Northover (https://github.com/TNorthover).
Added:
Modified:
llvm/docs/CommandGuide/llvm-reduce.rst
Removed:
################################################################################
diff --git a/llvm/docs/CommandGuide/llvm-reduce.rst b/llvm/docs/CommandGuide/llvm-reduce.rst
index cd49ceba2d6b6e8..d23d39b6126b6d0 100644
--- a/llvm/docs/CommandGuide/llvm-reduce.rst
+++ b/llvm/docs/CommandGuide/llvm-reduce.rst
@@ -105,4 +105,33 @@ EXIT STATUS
:program:`llvm-reduce` returns 0 under normal operation. It returns a non-zero
exit code if there were any errors.
+EXAMPLE
+-------
+:program:`llvm-reduce` can be used to simplify a test that causes a
+compiler crash.
+
+For example, let's assume that `opt` is crashing on the IR file
+`test.ll` with error message `Assertion failed at line 1234 of
+WhateverFile.cpp`, when running at `-O2`.
+
+The test case of `test.ll` can be reduced by invoking the following
+command:
+
+.. code-block:: bash
+
+ $(LLVM_BUILD_FOLDER)/bin/llvm-reduce --test=script.sh <path to>/test.ll
+
+The shell script passed to the option `test` consists of the
+following:
+
+.. code-block:: bash
+
+ $(LLVM_BUILD_FOLDER)/bin/opt -O2 -disable-output $1 \
+ |& grep "Assertion failed at line 1234 of WhateverFile.cpp"
+
+(In this script, `grep` exits with 0 if it finds the string and that
+becomes the whole script's status.)
+
+This example can be generalized to other tools that process IR files,
+for example `llc`.
More information about the llvm-commits
mailing list