Skip to content

Commit b16e003

Browse files
committed
[debugging-the-compiler] Add to bisecting optimization passes a short example of how to use llvm's bisect tool to autobisect the optimizer.
1 parent 0366e61 commit b16e003

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

docs/DebuggingTheCompiler.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -548,10 +548,17 @@ it's quite easy to do this manually:
548548

549549
a. Add the compiler option ``-Xllvm -sil-opt-pass-count=<n>``, where ``<n>``
550550
is the number of optimizations to run.
551-
b. Bisect: find n where the executable crashes, but does not crash with n-1.
552-
Note that n can be quite large, e.g. > 100000 (just try
553-
n = 10, 100, 1000, 10000, etc. to find an upper bound).
554-
c. Add another option ``-Xllvm -sil-print-pass-name``. The output can be
551+
552+
b. Bisect: find n where the executable crashes, but does not crash
553+
with n-1. First just try n = 10, 100, 1000, 10000, etc. to find
554+
an upper bound). Then can either bisect the invocation by hand or
555+
place the invocation into a script and use
556+
``./llvm-project/llvm/utils/bisect`` to automatically bisect
557+
based on the scripts error code. Example invocation::
558+
559+
bisect --start=0 --end=10000 ./invoke_swift_passing_N.sh "%(count)s"
560+
561+
c. Once one finds ``n``, Add another option ``-Xllvm -sil-print-pass-name``. The output can be
555562
large, so it's best to redirect stderr to a file (``2> output``).
556563
In the output search for the last pass before ``stage Address Lowering``.
557564
It should be the ``Run #<n-1>``. This line tells you the name of the bad

0 commit comments

Comments
 (0)