1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html><head><title>How to submit an LLVM bug report</title></head>
6 <table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
7 <tr><td> <font size=+3 color="#EEEEFF" face="Georgia,Palatino,Times,Roman"><b>How to submit an LLVM bug report</b></font></td>
10 <table border=0 width=100%>
14 <li><a href="#introduction">Introduction - Got bugs?</a>
15 <li><a href="#crashers">Crashing Bugs</a>
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>
22 <li><a href="#miscompilations">Miscompilations</a>
23 <li><a href="#codegen">Incorrect code generation (JIT and LLC)</a>
25 <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>
28 </td><td valign=top align=right>
29 <img src="Debugging.gif" width=444 height=314>
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 <!-- *********************************************************************** -->
41 If you're working with LLVM and run into a bug, we definitely want to know about
42 it. This document describes what you can do to increase the odds of getting it
45 Basically 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
47 compiler is <a href="#miscompilations">miscompiling</a> the program. Based on
48 what type of bug it is, follow the instructions in the linked section to narrow
49 down the bug so that the person who fixes it will be able to find the problem
52 Once you have a reduced test-case, email information about the bug to: <a
53 href="mailto:llvmbugs@cs.uiuc.edu">llvmbugs@cs.uiuc.edu</a>. This should
54 include all of the information necessary to reproduce the problem, including
55 where you got the LLVM tree from (if you're not working out of CVS).<p>
57 Thanks for helping us make LLVM better!<p>
60 <!-- *********************************************************************** -->
61 </ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
62 <tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
63 <a name="crashers">Crashing Bugs
64 </b></font></td></tr></table><ul>
65 <!-- *********************************************************************** -->
67 More often than not, bugs in the compiler cause it to crash - often due to an
68 assertion failure of some sort. If you are running <tt><b>opt</b></tt> or
69 <tt><b>analyze</b></tt> directly, and something crashes, jump to the section on
70 <a href="#passes">bugs in LLVM passes</a>. Otherwise, the most important
71 piece of the puzzle is to figure out if it is the GCC-based front-end that is
72 buggy or if it's one of the LLVM tools that has problems.<p>
74 To figure out which program is crashing (the front-end, <tt><b>gccas</b></tt>,
75 or <tt><b>gccld</b></tt>), run the <tt><b>llvm-gcc</b></tt> command line as you
76 were when the crash occurred, but add a <tt>-v</tt> option to the command line.
77 The compiler will print out a bunch of stuff, and should end with telling you
78 that one of <tt><b>cc1</b></tt>, <tt><b>gccas</b></tt>, or <tt><b>gccld</b></tt>
82 <li>If <tt><b>cc1</b></tt> crashed, you found a problem with the front-end.
83 Jump ahead to the section on <a href="#front-end">front-end bugs</a>.
84 <li>If <tt><b>gccas</b></tt> crashed, you found a bug in <a href="#gccas">one of
85 the passes in <tt><b>gccas</b></tt></a>.
86 <li>If <tt><b>gccld</b></tt> crashed, you found a bug in <a href="#gccld">one
87 of the passes in <tt><b>gccld</b></tt></a>.
88 <li>Otherwise, something really weird happened. Email the list with what you
93 <!-- ======================================================================= -->
94 </ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
95 <tr><td> </td><td width="100%">
96 <font color="#EEEEFF" face="Georgia,Palatino"><b>
97 <a name="front-end">Front-end bugs
98 </b></font></td></tr></table><ul>
100 If the problem is in the front-end, you should re-run the same
101 <tt>llvm-gcc</tt> command that resulted in the crash, but add the
102 <tt>-save-temps</tt> option. The compiler will crash again, but it
103 will leave behind a <tt><i>foo</i>.i</tt> file (containing preprocessed
104 C source code) and possibly <tt><i>foo</i>.s</tt> (containing LLVM
105 assembly code), for each compiled <tt><i>foo</i>.c</tt> file. Send us
106 the <tt><i>foo</i>.i</tt> file, along with a brief description of the
109 <!-- ======================================================================= -->
110 </ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
111 <tr><td> </td><td width="100%">
112 <font color="#EEEEFF" face="Georgia,Palatino"><b>
113 <a name="gccas">GCCAS bugs
114 </b></font></td></tr></table><ul>
116 If you find that a bug crashes in the <tt><b>gccas</b></tt> stage of
117 compilation, compile your test-case to a <tt>.s</tt> file with the
118 <tt>-save-temps</tt> option to <tt><b>llvm-gcc</b></tt>. Then run:<p>
121 <b>gccas</b> -debug-pass=Arguments < /dev/null -o - > /dev/null
124 ... which will print a list of arguments, indicating the list of passes that
125 <tt><b>gccas</b></tt> runs. Once you have the input file and the list of
126 passes, go to the section on <a href="#passes">debugging bugs in LLVM
130 <!-- ======================================================================= -->
131 </ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
132 <tr><td> </td><td width="100%">
133 <font color="#EEEEFF" face="Georgia,Palatino"><b>
134 <a name="gccld">GCCLD bugs
135 </b></font></td></tr></table><ul>
137 If you find that a bug crashes in the <tt><b>gccld</b></tt> stage of
138 compilation, gather all of the <tt>.o</tt> bytecode files and libraries that are
139 being linked together (the "<tt><b>llvm-gcc</b> -v</tt>" output should include
140 the full list of objects linked). Then run:<p>
143 <b>llvm-as</b> < /dev/null > null.bc
144 <b>gccld</b> -debug-pass=Arguments null.bc
147 ... which will print a list of arguments, indicating the list of passes that
148 <tt><b>gccld</b></tt> runs. Once you have the input files and the list of
149 passes, go to the section on <a href="#passes">debugging bugs in LLVM
152 <!-- ======================================================================= -->
153 </ul><table width="100%" bgcolor="#441188" border=0 cellpadding=4 cellspacing=0>
154 <tr><td> </td><td width="100%">
155 <font color="#EEEEFF" face="Georgia,Palatino"><b>
156 <a name="passes">Bugs in LLVM passes
157 </b></font></td></tr></table><ul>
159 At this point, you should have some number of LLVM assembly files or bytecode
160 files and a list of passes which crash when run on the specified input. In
161 order to reduce the list of passes (which is probably large) and the input to
162 something tractable, use the <tt><b>bugpoint</b></tt> tool as follows:<p>
165 <b>bugpoint</b> <input files> <list of passes>
168 <tt><b>bugpoint</b></tt> will print a bunch of output as it reduces the
169 test-case, but it should eventually print something like this:<p>
173 Emitted bytecode to 'bugpoint-reduced-simplified.bc'
175 *** You can reproduce the problem with: opt bugpoint-reduced-simplified.bc -licm
178 Once you complete this, please send the LLVM bytecode file and the command line
179 to reproduce the problem to the llvmbugs mailing list.<p>
182 <!-- *********************************************************************** -->
183 </ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
184 <tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
185 <a name="miscompilations">Miscompilations</a>
186 </b></font></td></tr></table><ul>
187 <!-- *********************************************************************** -->
189 A miscompilation occurs when a pass does not correctly transform a program, thus
190 producing errors that are only noticed during execution. This is different from
191 producing invalid LLVM code (i.e., code not in SSA form, using values before
192 defining them, etc.) which the verifier will check for after a pass finishes its
195 To debug a miscompilation, you should choose which program you wish to run the
196 output through, e.g. C backend, the JIT, or LLC, and a selection of passes, one
197 of which may be causing the error, and run, for example:
200 <b>bugpoint</b> -run-cbe [... optimization passes ...] file-to-test.bc
203 <tt>bugpoint</tt> will try to narrow down your list of passes to the one pass
204 that causes an error, and simplify the bytecode file as much as it can to assist
205 you. It will print a message letting you know how to reproduce the resulting
208 <!-- *********************************************************************** -->
209 </ul><table width="100%" bgcolor="#330077" border=0 cellpadding=4 cellspacing=0>
210 <tr><td align=center><font color="#EEEEFF" size=+2 face="Georgia,Palatino"><b>
211 <a name="codegen">Incorrect code generation</a>
212 </b></font></td></tr></table><ul>
213 <!-- *********************************************************************** -->
215 Similarly to debugging incorrect compilation by mis-behaving passes, you can
216 debug incorrect code generation by either LLC or the JIT, using
217 <tt>bugpoint</tt>. The process <tt>bugpoint</tt> follows in this case is to try
218 to narrow the code down to a function that is miscompiled by one or the other
219 method, but since for correctness, the entire program must be run,
220 <tt>bugpoint</tt> will compile the code it deems to not be affected with the C
221 Backend, and then link in the shared object it generates.<p>
225 <b>bugpoint</b> -run-jit -output=[correct output file] [bytecodefile]
228 Similarly, to debug the LLC, one would run:
230 <b>bugpoint</b> -run-llc -output=[correct output file] [bytecodefile]
233 At the end of a successful <tt>bugpoint</tt> run, you will be presented
234 with two bytecode files: a <em>safe</em> file which can be compiled with the C
235 backend and the <em>test</em> file which either LLC or the JIT
236 mis-codegenerates, and thus causes the error.<p>
238 To reproduce the error that <tt>bugpoint</tt> found, it is sufficient to do the
242 <li>Regenerate the shared object from the safe bytecode file:<br>
244 <b>llvm-dis</b> -c safe.bc -o safe.c<br>
245 <b>gcc</b> -shared safe.c -o safe.so
247 <li>If debugging LLC, compile test bytecode native and link with the shared object:<br>
249 <b>llc</b> test.bc -o test.s -f<br>
250 gcc test.s safe.so -o test.llc<br>
251 ./test.llc [program options]
254 If debugging the JIT, load the shared object and supply the test bytecode:<br>
256 <b>lli</b> -load=safe.so test.bc [program options]
260 <!-- *********************************************************************** -->
262 <!-- *********************************************************************** -->
265 <address><a href="mailto:sabre@nondot.org">Chris Lattner</a></address>
266 <!-- Created: Tue Aug 6 15:00:33 CDT 2002 -->
268 Last modified: Tue Oct 14 15:57:47 CDT 2003
270 </font></body></html>