@@ -6,26 +6,26 @@ Introduction - Got bugs?
66========================
77
88
9- If you're working with LLVM and run into a bug, we definitely want to know
9+ If you're working with LLVM and encounter a bug, we definitely want to know
1010about it. This document describes what you can do to increase the odds of
1111getting it fixed quickly.
1212
1313🔒 If you believe that the bug is security related, please follow :ref: `report-security-issue `. 🔒
1414
15- Basically you have to do two things at a minimum. First, decide whether the
15+ Basically, you have to do two things at a minimum. First, decide whether the
1616bug `crashes the compiler `_ or if the compiler is `miscompiling `_ the program
1717(i.e., the compiler successfully produces an executable, but it doesn't run
1818right). Based on what type of bug it is, follow the instructions in the
1919linked section to narrow down the bug so that the person who fixes it will be
2020able to find the problem more easily.
2121
22- Once you have a reduced test- case, go to `the LLVM Bug Tracking System
22+ Once you have a reduced test case, go to `the LLVM Bug Tracking System
2323<https://github.com/llvm/llvm-project/issues> `_ and fill out the form with the
2424necessary details (note that you don't need to pick a label, just use if you're
2525not sure). The bug description should contain the following information:
2626
2727* All information necessary to reproduce the problem.
28- * The reduced test- case that triggers the bug.
28+ * The reduced test case that triggers the bug.
2929* The location where you obtained LLVM (if not from our Git
3030 repository).
3131
@@ -39,10 +39,10 @@ Crashing Bugs
3939More often than not, bugs in the compiler cause it to crash---often due to
4040an assertion failure of some sort. The most important piece of the puzzle
4141is to figure out if it is crashing in the Clang front-end or if it is one of
42- the LLVM libraries (e.g. the optimizer or code generator) that has
42+ the LLVM libraries (e.g., the optimizer or code generator) that has
4343problems.
4444
45- To figure out which component is crashing (the front-end, middle-end
45+ To identify the crashing component (the front-end, middle-end
4646optimizer, or backend code generator), run the ``clang `` command line as you
4747were when the crash occurred, but with the following extra command line
4848options:
@@ -53,7 +53,7 @@ options:
5353 <frontend-crash>`.
5454
5555* ``-emit-llvm ``: If ``clang `` crashes with this option (which disables
56- the code generator), you found a middle-end optimizer bug. Jump ahead to
56+ the code generator), you've found a middle-end optimizer bug. Jump ahead to
5757 :ref: `middle-end bugs <middleend-crash >`.
5858
5959* Otherwise, you have a backend code generator crash. Jump ahead to :ref: `code
@@ -102,19 +102,19 @@ functions. Then run:
102102 If this doesn't crash, please follow the instructions for a :ref: `front-end
103103bug <frontend-crash>`.
104104
105- If this does crash, then you should be able to debug this with the following
105+ If this does crash, then you can debug this with the following
106106:doc: `bugpoint <Bugpoint >` command:
107107
108108.. code-block :: bash
109109
110110 bugpoint foo.bc -O3
111111
112- Run this, then file a bug with the instructions and reduced .bc
112+ Run this, then file a bug with the instructions and reduced `` .bc ``
113113files that bugpoint emits.
114114
115115If bugpoint doesn't reproduce the crash,
116116:doc: `llvm-reduce <CommandGuide/llvm-reduce >` is an alternative way to reduce
117- LLVM IR. Create a script that repros the crash and run:
117+ LLVM IR. Create a script that reproduces the crash and run:
118118
119119.. code-block :: bash
120120
@@ -137,26 +137,26 @@ Backend code generator bugs
137137---------------------------
138138
139139If you find a bug that crashes clang in the code generator, compile your
140- source file to a .bc file by passing "``-emit-llvm -c -o foo.bc ``" to
141- clang (in addition to the options you already pass). Once your have
142- foo.bc, one of the following commands should fail:
140+ source file to a `` .bc `` file by passing "``-emit-llvm -c -o foo.bc ``" to
141+ clang (in addition to the options you already pass). Once you have
142+ `` foo.bc `` , one of the following commands should fail:
143143
144144#. ``llc foo.bc ``
145145#. ``llc foo.bc -relocation-model=pic ``
146146#. ``llc foo.bc -relocation-model=static ``
147147
148148If none of these crash, please follow the instructions for a :ref: `front-end
149- bug<frontend-crash>`. If one of these do crash , you should be able to reduce
149+ bug<frontend-crash>`. If one of these crashes , you should be able to reduce
150150this with one of the following :doc: `bugpoint <Bugpoint >` command lines (use
151151the one corresponding to the command above that failed):
152152
153153#. ``bugpoint -run-llc foo.bc ``
154154#. ``bugpoint -run-llc foo.bc --tool-args -relocation-model=pic ``
155155#. ``bugpoint -run-llc foo.bc --tool-args -relocation-model=static ``
156156
157- Please run this, then file a bug with the instructions and reduced .bc file
157+ Please run this, then file a bug with the instructions and reduced `` .bc `` file
158158that bugpoint emits. If something goes wrong with bugpoint, please submit
159- the " foo.bc" file and the option that llc crashes with.
159+ the `` foo.bc `` file and the option that llc crashes with.
160160
161161LTO bugs
162162---------------------------
@@ -174,7 +174,7 @@ in addition to your existing compilation options:
174174 These options enable LTO and save temporary files generated during compilation
175175for later analysis.
176176
177- On Windows, you should be using lld-link as the linker. Adjust your compilation
177+ On Windows, use lld-link as the linker. Adjust your compilation
178178flags as follows:
179179* Add ``/lldsavetemps `` to the linker flags.
180180* When linking from the compiler driver, add ``/link /lldsavetemps `` in order to forward that flag to the linker.
@@ -199,7 +199,7 @@ command line (use the bc file corresponding to the command above that failed):
199199
200200 llvm-reduce --test reduce.sh a.out.0.2.internalize.bc
201201
202- Example of reduce.sh script
202+ Example of `` reduce.sh `` script
203203
204204.. code-block :: bash
205205
@@ -209,9 +209,9 @@ Example of reduce.sh script
209209 path/to/not --crash path/to/opt " -passes=lto<O3>" $1 -o temp.bc 2> err.log
210210 grep -q " It->second == &Insn" err.log
211211
212- Here we have grepped the failed assert message.
212+ Here we have grepped for the failed assert message.
213213
214- Please run this, then file a bug with the instructions and reduced .bc file
214+ Please run this, then file a bug with the instructions and reduced `` .bc `` file
215215that llvm-reduce emits.
216216
217217.. _miscompiling :
@@ -221,16 +221,16 @@ Miscompilations
221221
222222If clang successfully produces an executable, but that executable doesn't run
223223right, this is either a bug in the code or a bug in the compiler. The first
224- thing to check is to make sure it is not using undefined behavior (e.g.
224+ thing to check is to make sure it is not using undefined behavior (e.g.,
225225reading a variable before it is defined). In particular, check to see if the
226226program is clean under various `sanitizers
227- <https://github.com/google/sanitizers> `_ (e.g. ``clang
227+ <https://github.com/google/sanitizers> `_ (e.g., ``clang
228228-fsanitize=undefined,address ``) and `valgrind <http://valgrind.org/ >`_. Many
229229"LLVM bugs" that we have chased down ended up being bugs in the program being
230230compiled, not LLVM.
231231
232232Once you determine that the program itself is not buggy, you should choose
233- which code generator you wish to compile the program with (e.g. LLC or the JIT)
233+ which code generator you wish to compile the program with (e.g., LLC or the JIT)
234234and optionally a series of LLVM passes to run. For example:
235235
236236.. code-block :: bash
0 commit comments