blob: d8db473390e3a3b5e8526c7c682ff95203a2acaf [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
Misha Brukmanafac73e2003-10-22 17:01:44 +000053<a href="http://llvm.cs.uiuc.edu/bugs/enter_bug.cgi">
John Criswell4d37c7b2003-10-22 15:06:11 +000054the 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>
Misha Brukmanafac73e2003-10-22 17:01:44 +000060 <li>All information necessary to reproduce the problem.</li>
61 <li>The reduced test-case that triggers the bug.</li>
62 <li>The location where you obtained LLVM (if not from our CVS
63 repository).</li>
John Criswell4d37c7b2003-10-22 15:06:11 +000064</ul>
65
66<p>
Chris Lattner8b6be362003-05-21 22:21:07 +000067Thanks for helping us make LLVM better!<p>
68
69
70<!-- *********************************************************************** -->
71</ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
72<tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
73<a name="crashers">Crashing Bugs
74</b></font></td></tr></table><ul>
75<!-- *********************************************************************** -->
76
77More often than not, bugs in the compiler cause it to crash - often due to an
78assertion failure of some sort. If you are running <tt><b>opt</b></tt> or
79<tt><b>analyze</b></tt> directly, and something crashes, jump to the section on
80<a href="#passes">bugs in LLVM passes</a>. Otherwise, the most important
81piece of the puzzle is to figure out if it is the GCC-based front-end that is
82buggy or if it's one of the LLVM tools that has problems.<p>
83
84To figure out which program is crashing (the front-end, <tt><b>gccas</b></tt>,
85or <tt><b>gccld</b></tt>), run the <tt><b>llvm-gcc</b></tt> command line as you
86were when the crash occurred, but add a <tt>-v</tt> option to the command line.
87The compiler will print out a bunch of stuff, and should end with telling you
88that one of <tt><b>cc1</b></tt>, <tt><b>gccas</b></tt>, or <tt><b>gccld</b></tt>
89crashed.<p>
90
91<ul>
92<li>If <tt><b>cc1</b></tt> crashed, you found a problem with the front-end.
93Jump ahead to the section on <a href="#front-end">front-end bugs</a>.
94<li>If <tt><b>gccas</b></tt> crashed, you found a bug in <a href="#gccas">one of
95the passes in <tt><b>gccas</b></tt></a>.
96<li>If <tt><b>gccld</b></tt> crashed, you found a bug in <a href="#gccld">one
97of the passes in <tt><b>gccld</b></tt></a>.
98<li>Otherwise, something really weird happened. Email the list with what you
99have at this point.
100</ul><p>
101
102
103<!-- ======================================================================= -->
104</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
105<tr><td>&nbsp;</td><td width="100%">&nbsp;
106<font color="#EEEEFF" face="Georgia,Palatino"><b>
107<a name="front-end">Front-end bugs
108</b></font></td></tr></table><ul>
109
Brian Gaekeeefe9792003-05-23 21:03:50 +0000110If the problem is in the front-end, you should re-run the same
111<tt>llvm-gcc</tt> command that resulted in the crash, but add the
112<tt>-save-temps</tt> option. The compiler will crash again, but it
113will leave behind a <tt><i>foo</i>.i</tt> file (containing preprocessed
114C source code) and possibly <tt><i>foo</i>.s</tt> (containing LLVM
115assembly code), for each compiled <tt><i>foo</i>.c</tt> file. Send us
116the <tt><i>foo</i>.i</tt> file, along with a brief description of the
117error it caused.<p>
Chris Lattner8b6be362003-05-21 22:21:07 +0000118
119<!-- ======================================================================= -->
120</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
121<tr><td>&nbsp;</td><td width="100%">&nbsp;
122<font color="#EEEEFF" face="Georgia,Palatino"><b>
123<a name="gccas">GCCAS bugs
124</b></font></td></tr></table><ul>
125
126If you find that a bug crashes in the <tt><b>gccas</b></tt> stage of
Brian Gaekeeefe9792003-05-23 21:03:50 +0000127compilation, compile your test-case to a <tt>.s</tt> file with the
128<tt>-save-temps</tt> option to <tt><b>llvm-gcc</b></tt>. Then run:<p>
Chris Lattner8b6be362003-05-21 22:21:07 +0000129
130<pre>
131 <b>gccas</b> -debug-pass=Arguments &lt; /dev/null -o - &gt; /dev/null
132</pre><p>
133
134... which will print a list of arguments, indicating the list of passes that
135<tt><b>gccas</b></tt> runs. Once you have the input file and the list of
136passes, go to the section on <a href="#passes">debugging bugs in LLVM
137passes</a>.<p>
138
139
140<!-- ======================================================================= -->
141</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
142<tr><td>&nbsp;</td><td width="100%">&nbsp;
143<font color="#EEEEFF" face="Georgia,Palatino"><b>
144<a name="gccld">GCCLD bugs
145</b></font></td></tr></table><ul>
146
147If you find that a bug crashes in the <tt><b>gccld</b></tt> stage of
148compilation, gather all of the <tt>.o</tt> bytecode files and libraries that are
149being linked together (the "<tt><b>llvm-gcc</b> -v</tt>" output should include
150the full list of objects linked). Then run:<p>
151
152<pre>
Misha Brukmanf1d01fb2003-09-17 18:51:47 +0000153 <b>llvm-as</b> &lt; /dev/null &gt; null.bc
Chris Lattnerddaf5002003-05-23 14:49:32 +0000154 <b>gccld</b> -debug-pass=Arguments null.bc
Chris Lattner8b6be362003-05-21 22:21:07 +0000155</pre><p>
156
157... which will print a list of arguments, indicating the list of passes that
158<tt><b>gccld</b></tt> runs. Once you have the input files and the list of
159passes, go to the section on <a href="#passes">debugging bugs in LLVM
160passes</a>.<p>
161
162<!-- ======================================================================= -->
163</ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
164<tr><td>&nbsp;</td><td width="100%">&nbsp;
165<font color="#EEEEFF" face="Georgia,Palatino"><b>
166<a name="passes">Bugs in LLVM passes
167</b></font></td></tr></table><ul>
168
169At this point, you should have some number of LLVM assembly files or bytecode
170files and a list of passes which crash when run on the specified input. In
171order to reduce the list of passes (which is probably large) and the input to
172something tractable, use the <tt><b>bugpoint</b></tt> tool as follows:<p>
173
174<pre>
175 <b>bugpoint</b> &lt;input files&gt; &lt;list of passes&gt;
176</pre><p>
177
178<tt><b>bugpoint</b></tt> will print a bunch of output as it reduces the
179test-case, but it should eventually print something like this:<p>
180
181<pre>
182 ...
183 Emitted bytecode to 'bugpoint-reduced-simplified.bc'
184
185 *** You can reproduce the problem with: opt bugpoint-reduced-simplified.bc -licm
186</pre><p>
187
188Once you complete this, please send the LLVM bytecode file and the command line
189to reproduce the problem to the llvmbugs mailing list.<p>
190
191
192<!-- *********************************************************************** -->
193</ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
194<tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
Misha Brukmanf1d01fb2003-09-17 18:51:47 +0000195<a name="miscompilations">Miscompilations</a>
Chris Lattner8b6be362003-05-21 22:21:07 +0000196</b></font></td></tr></table><ul>
197<!-- *********************************************************************** -->
198
Misha Brukmanf1d01fb2003-09-17 18:51:47 +0000199A miscompilation occurs when a pass does not correctly transform a program, thus
200producing errors that are only noticed during execution. This is different from
201producing invalid LLVM code (i.e., code not in SSA form, using values before
202defining them, etc.) which the verifier will check for after a pass finishes its
203run.<p>
Chris Lattner8b6be362003-05-21 22:21:07 +0000204
Misha Brukmanf1d01fb2003-09-17 18:51:47 +0000205To debug a miscompilation, you should choose which program you wish to run the
206output through, e.g. C backend, the JIT, or LLC, and a selection of passes, one
207of which may be causing the error, and run, for example:
208
209<pre>
Chris Lattner18ab2b92003-10-14 20:58:07 +0000210 <b>bugpoint</b> -run-cbe [... optimization passes ...] file-to-test.bc
Misha Brukmanf1d01fb2003-09-17 18:51:47 +0000211</pre>
212
213<tt>bugpoint</tt> will try to narrow down your list of passes to the one pass
214that causes an error, and simplify the bytecode file as much as it can to assist
215you. It will print a message letting you know how to reproduce the resulting
216error.
217
218<!-- *********************************************************************** -->
219</ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
220<tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
221<a name="codegen">Incorrect code generation</a>
222</b></font></td></tr></table><ul>
223<!-- *********************************************************************** -->
224
225Similarly to debugging incorrect compilation by mis-behaving passes, you can
226debug incorrect code generation by either LLC or the JIT, using
227<tt>bugpoint</tt>. The process <tt>bugpoint</tt> follows in this case is to try
228to narrow the code down to a function that is miscompiled by one or the other
229method, but since for correctness, the entire program must be run,
230<tt>bugpoint</tt> will compile the code it deems to not be affected with the C
231Backend, and then link in the shared object it generates.<p>
232
233To debug the JIT:
234<pre>
Chris Lattner18ab2b92003-10-14 20:58:07 +0000235 <b>bugpoint</b> -run-jit -output=[correct output file] [bytecodefile]
Misha Brukmanf1d01fb2003-09-17 18:51:47 +0000236</pre>
237
238Similarly, to debug the LLC, one would run:
239<pre>
Chris Lattner18ab2b92003-10-14 20:58:07 +0000240 <b>bugpoint</b> -run-llc -output=[correct output file] [bytecodefile]
Misha Brukmanf1d01fb2003-09-17 18:51:47 +0000241</pre>
242
243At the end of a successful <tt>bugpoint</tt> run, you will be presented
244with two bytecode files: a <em>safe</em> file which can be compiled with the C
245backend and the <em>test</em> file which either LLC or the JIT
246mis-codegenerates, and thus causes the error.<p>
247
248To reproduce the error that <tt>bugpoint</tt> found, it is sufficient to do the
249following:
250
251<ol>
252 <li>Regenerate the shared object from the safe bytecode file:<br>
253<pre>
254 <b>llvm-dis</b> -c safe.bc -o safe.c<br>
255 <b>gcc</b> -shared safe.c -o safe.so
256</pre></li>
257 <li>If debugging LLC, compile test bytecode native and link with the shared object:<br>
258<pre>
259 <b>llc</b> test.bc -o test.s -f<br>
260 gcc test.s safe.so -o test.llc<br>
261 ./test.llc [program options]
262</pre></li>
263 <p>
264 If debugging the JIT, load the shared object and supply the test bytecode:<br>
265<pre>
266 <b>lli</b> -load=safe.so test.bc [program options]
267</pre></li>
268</ol>
Chris Lattner8b6be362003-05-21 22:21:07 +0000269
270<!-- *********************************************************************** -->
271</ul>
272<!-- *********************************************************************** -->
273
274<hr><font size-1>
275<address><a href="mailto:sabre@nondot.org">Chris Lattner</a></address>
John Criswell0f6d7c02003-10-27 18:18:16 +0000276<a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a>
277<br>
Chris Lattner8b6be362003-05-21 22:21:07 +0000278<!-- Created: Tue Aug 6 15:00:33 CDT 2002 -->
279<!-- hhmts start -->
John Criswell0f6d7c02003-10-27 18:18:16 +0000280Last modified: Mon Oct 27 12:00:00 CDT 2003
Chris Lattner8b6be362003-05-21 22:21:07 +0000281<!-- hhmts end -->
282</font></body></html>