blob: b7bc2042a946ead383041e67114680fd29cc13ed [file] [log] [blame]
Chris Lattner8b6be362003-05-21 22:21:07 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head><title>How to submit an LLVM bug report</title></head>
3
4<body bgcolor=white>
5
6<table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
7<tr><td>&nbsp; <font size=+3 color="#EEEEFF" face="Georgia,Palatino,Times,Roman"><b>How to submit an LLVM bug report</b></font></td>
8</tr></table>
9
10<table border=0 width=100%>
11<tr><td valign=top>
12<p><font size=+1>
13<ol>
14 <li><a href="#introduction">Introduction - Got bugs?</a>
15 <li><a href="#crashers">Crashing Bugs</a>
16 <ul>
17 <li><a href="#front-end">Front-end bugs</a>
18 <li><a href="#gccas">GCCAS bugs</a>
19 <li><a href="#gccld">GCCLD bugs</a>
20 <li><a href="#passes">Bugs in LLVM passes</a>
21 </ul>
22 <li><a href="#miscompilations">Miscompilations</a>
Misha Brukmanf1d01fb2003-09-17 18:51:47 +000023 <li><a href="#codegen">Incorrect code generation (JIT and LLC)</a>
Chris Lattner8b6be362003-05-21 22:21:07 +000024
Misha Brukmanf1d01fb2003-09-17 18:51:47 +000025 <p><b>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a> and
26 <a href="http://misha.brukman.net">Misha Brukman</a></b><p>
Chris Lattner8b6be362003-05-21 22:21:07 +000027</ol><p></font>
28</td><td valign=top align=right>
29<img src="Debugging.gif" width=444 height=314>
30</td></tr>
31</table>
32
33
34<!-- *********************************************************************** -->
35<table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
36<tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
37<a name="introduction">Introduction - Got bugs?
38</b></font></td></tr></table><ul>
39<!-- *********************************************************************** -->
40
41If you're working with LLVM and run into a bug, we definitely want to know about
42it. This document describes what you can do to increase the odds of getting it
43fixed quickly.<p>
44
45Basically you have to do two things at a minimum. First, decide whether the bug
46<a href="#crashers">crashes the compiler</a> (or an LLVM pass), or if the
47compiler is <a href="#miscompilations">miscompiling</a> the program. Based on
48what type of bug it is, follow the instructions in the linked section to narrow
49down the bug so that the person who fixes it will be able to find the problem
50more easily.<p>
51
John Criswell4d37c7b2003-10-22 15:06:11 +000052Once you have a reduced test-case, go to
53<a href="http://zion.cs.uiuc.edu/bugs/enter_bug.cgi">
54the LLVM Bug Tracking System,
55</a>
56select the catagory in which the bug falls, and fill out the form with the
57necessary details. The bug description should contain the following
58information:
59<ul>
60 <li>
61 All information necessary to reproduce the problem.
Chris Lattner8b6be362003-05-21 22:21:07 +000062
John Criswell4d37c7b2003-10-22 15:06:11 +000063 <li>
64 The reduced test-case that triggers the bug.
65
66 <li>
67 The location where you obtained LLVM (if not from our CVS repository).
68</ul>
69
70<p>
Chris Lattner8b6be362003-05-21 22:21:07 +000071Thanks for helping us make LLVM better!<p>
72
73
74<!-- *********************************************************************** -->
75</ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
76<tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
77<a name="crashers">Crashing Bugs
78</b></font></td></tr></table><ul>
79<!-- *********************************************************************** -->
80
81More often than not, bugs in the compiler cause it to crash - often due to an
82assertion failure of some sort. If you are running <tt><b>opt</b></tt> or
83<tt><b>analyze</b></tt> directly, and something crashes, jump to the section on
84<a href="#passes">bugs in LLVM passes</a>. Otherwise, the most important
85piece of the puzzle is to figure out if it is the GCC-based front-end that is
86buggy or if it's one of the LLVM tools that has problems.<p>
87
88To figure out which program is crashing (the front-end, <tt><b>gccas</b></tt>,
89or <tt><b>gccld</b></tt>), run the <tt><b>llvm-gcc</b></tt> command line as you
90were when the crash occurred, but add a <tt>-v</tt> option to the command line.
91The compiler will print out a bunch of stuff, and should end with telling you
92that one of <tt><b>cc1</b></tt>, <tt><b>gccas</b></tt>, or <tt><b>gccld</b></tt>
93crashed.<p>
94
95<ul>
96<li>If <tt><b>cc1</b></tt> crashed, you found a problem with the front-end.
97Jump ahead to the section on <a href="#front-end">front-end bugs</a>.
98<li>If <tt><b>gccas</b></tt> crashed, you found a bug in <a href="#gccas">one of
99the passes in <tt><b>gccas</b></tt></a>.
100<li>If <tt><b>gccld</b></tt> crashed, you found a bug in <a href="#gccld">one
101of the passes in <tt><b>gccld</b></tt></a>.
102<li>Otherwise, something really weird happened. Email the list with what you
103have at this point.
104</ul><p>
105
106
107<!-- ======================================================================= -->
108</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
109<tr><td>&nbsp;</td><td width="100%">&nbsp;
110<font color="#EEEEFF" face="Georgia,Palatino"><b>
111<a name="front-end">Front-end bugs
112</b></font></td></tr></table><ul>
113
Brian Gaekeeefe9792003-05-23 21:03:50 +0000114If the problem is in the front-end, you should re-run the same
115<tt>llvm-gcc</tt> command that resulted in the crash, but add the
116<tt>-save-temps</tt> option. The compiler will crash again, but it
117will leave behind a <tt><i>foo</i>.i</tt> file (containing preprocessed
118C source code) and possibly <tt><i>foo</i>.s</tt> (containing LLVM
119assembly code), for each compiled <tt><i>foo</i>.c</tt> file. Send us
120the <tt><i>foo</i>.i</tt> file, along with a brief description of the
121error it caused.<p>
Chris Lattner8b6be362003-05-21 22:21:07 +0000122
123<!-- ======================================================================= -->
124</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
125<tr><td>&nbsp;</td><td width="100%">&nbsp;
126<font color="#EEEEFF" face="Georgia,Palatino"><b>
127<a name="gccas">GCCAS bugs
128</b></font></td></tr></table><ul>
129
130If you find that a bug crashes in the <tt><b>gccas</b></tt> stage of
Brian Gaekeeefe9792003-05-23 21:03:50 +0000131compilation, compile your test-case to a <tt>.s</tt> file with the
132<tt>-save-temps</tt> option to <tt><b>llvm-gcc</b></tt>. Then run:<p>
Chris Lattner8b6be362003-05-21 22:21:07 +0000133
134<pre>
135 <b>gccas</b> -debug-pass=Arguments &lt; /dev/null -o - &gt; /dev/null
136</pre><p>
137
138... which will print a list of arguments, indicating the list of passes that
139<tt><b>gccas</b></tt> runs. Once you have the input file and the list of
140passes, go to the section on <a href="#passes">debugging bugs in LLVM
141passes</a>.<p>
142
143
144<!-- ======================================================================= -->
145</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
146<tr><td>&nbsp;</td><td width="100%">&nbsp;
147<font color="#EEEEFF" face="Georgia,Palatino"><b>
148<a name="gccld">GCCLD bugs
149</b></font></td></tr></table><ul>
150
151If you find that a bug crashes in the <tt><b>gccld</b></tt> stage of
152compilation, gather all of the <tt>.o</tt> bytecode files and libraries that are
153being linked together (the "<tt><b>llvm-gcc</b> -v</tt>" output should include
154the full list of objects linked). Then run:<p>
155
156<pre>
Misha Brukmanf1d01fb2003-09-17 18:51:47 +0000157 <b>llvm-as</b> &lt; /dev/null &gt; null.bc
Chris Lattnerddaf5002003-05-23 14:49:32 +0000158 <b>gccld</b> -debug-pass=Arguments null.bc
Chris Lattner8b6be362003-05-21 22:21:07 +0000159</pre><p>
160
161... which will print a list of arguments, indicating the list of passes that
162<tt><b>gccld</b></tt> runs. Once you have the input files and the list of
163passes, go to the section on <a href="#passes">debugging bugs in LLVM
164passes</a>.<p>
165
166<!-- ======================================================================= -->
167</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
168<tr><td>&nbsp;</td><td width="100%">&nbsp;
169<font color="#EEEEFF" face="Georgia,Palatino"><b>
170<a name="passes">Bugs in LLVM passes
171</b></font></td></tr></table><ul>
172
173At this point, you should have some number of LLVM assembly files or bytecode
174files and a list of passes which crash when run on the specified input. In
175order to reduce the list of passes (which is probably large) and the input to
176something tractable, use the <tt><b>bugpoint</b></tt> tool as follows:<p>
177
178<pre>
179 <b>bugpoint</b> &lt;input files&gt; &lt;list of passes&gt;
180</pre><p>
181
182<tt><b>bugpoint</b></tt> will print a bunch of output as it reduces the
183test-case, but it should eventually print something like this:<p>
184
185<pre>
186 ...
187 Emitted bytecode to 'bugpoint-reduced-simplified.bc'
188
189 *** You can reproduce the problem with: opt bugpoint-reduced-simplified.bc -licm
190</pre><p>
191
192Once you complete this, please send the LLVM bytecode file and the command line
193to reproduce the problem to the llvmbugs mailing list.<p>
194
195
196<!-- *********************************************************************** -->
197</ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
198<tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
Misha Brukmanf1d01fb2003-09-17 18:51:47 +0000199<a name="miscompilations">Miscompilations</a>
Chris Lattner8b6be362003-05-21 22:21:07 +0000200</b></font></td></tr></table><ul>
201<!-- *********************************************************************** -->
202
Misha Brukmanf1d01fb2003-09-17 18:51:47 +0000203A miscompilation occurs when a pass does not correctly transform a program, thus
204producing errors that are only noticed during execution. This is different from
205producing invalid LLVM code (i.e., code not in SSA form, using values before
206defining them, etc.) which the verifier will check for after a pass finishes its
207run.<p>
Chris Lattner8b6be362003-05-21 22:21:07 +0000208
Misha Brukmanf1d01fb2003-09-17 18:51:47 +0000209To debug a miscompilation, you should choose which program you wish to run the
210output through, e.g. C backend, the JIT, or LLC, and a selection of passes, one
211of which may be causing the error, and run, for example:
212
213<pre>
Chris Lattner18ab2b92003-10-14 20:58:07 +0000214 <b>bugpoint</b> -run-cbe [... optimization passes ...] file-to-test.bc
Misha Brukmanf1d01fb2003-09-17 18:51:47 +0000215</pre>
216
217<tt>bugpoint</tt> will try to narrow down your list of passes to the one pass
218that causes an error, and simplify the bytecode file as much as it can to assist
219you. It will print a message letting you know how to reproduce the resulting
220error.
221
222<!-- *********************************************************************** -->
223</ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
224<tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
225<a name="codegen">Incorrect code generation</a>
226</b></font></td></tr></table><ul>
227<!-- *********************************************************************** -->
228
229Similarly to debugging incorrect compilation by mis-behaving passes, you can
230debug incorrect code generation by either LLC or the JIT, using
231<tt>bugpoint</tt>. The process <tt>bugpoint</tt> follows in this case is to try
232to narrow the code down to a function that is miscompiled by one or the other
233method, but since for correctness, the entire program must be run,
234<tt>bugpoint</tt> will compile the code it deems to not be affected with the C
235Backend, and then link in the shared object it generates.<p>
236
237To debug the JIT:
238<pre>
Chris Lattner18ab2b92003-10-14 20:58:07 +0000239 <b>bugpoint</b> -run-jit -output=[correct output file] [bytecodefile]
Misha Brukmanf1d01fb2003-09-17 18:51:47 +0000240</pre>
241
242Similarly, to debug the LLC, one would run:
243<pre>
Chris Lattner18ab2b92003-10-14 20:58:07 +0000244 <b>bugpoint</b> -run-llc -output=[correct output file] [bytecodefile]
Misha Brukmanf1d01fb2003-09-17 18:51:47 +0000245</pre>
246
247At the end of a successful <tt>bugpoint</tt> run, you will be presented
248with two bytecode files: a <em>safe</em> file which can be compiled with the C
249backend and the <em>test</em> file which either LLC or the JIT
250mis-codegenerates, and thus causes the error.<p>
251
252To reproduce the error that <tt>bugpoint</tt> found, it is sufficient to do the
253following:
254
255<ol>
256 <li>Regenerate the shared object from the safe bytecode file:<br>
257<pre>
258 <b>llvm-dis</b> -c safe.bc -o safe.c<br>
259 <b>gcc</b> -shared safe.c -o safe.so
260</pre></li>
261 <li>If debugging LLC, compile test bytecode native and link with the shared object:<br>
262<pre>
263 <b>llc</b> test.bc -o test.s -f<br>
264 gcc test.s safe.so -o test.llc<br>
265 ./test.llc [program options]
266</pre></li>
267 <p>
268 If debugging the JIT, load the shared object and supply the test bytecode:<br>
269<pre>
270 <b>lli</b> -load=safe.so test.bc [program options]
271</pre></li>
272</ol>
Chris Lattner8b6be362003-05-21 22:21:07 +0000273
274<!-- *********************************************************************** -->
275</ul>
276<!-- *********************************************************************** -->
277
278<hr><font size-1>
279<address><a href="mailto:sabre@nondot.org">Chris Lattner</a></address>
280<!-- Created: Tue Aug 6 15:00:33 CDT 2002 -->
281<!-- hhmts start -->
Chris Lattner18ab2b92003-10-14 20:58:07 +0000282Last modified: Tue Oct 14 15:57:47 CDT 2003
Chris Lattner8b6be362003-05-21 22:21:07 +0000283<!-- hhmts end -->
284</font></body></html>