Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
| 3 | <html> |
| 4 | <head> |
| 5 | <title>How to submit an LLVM bug report</title> |
| 6 | <link rel="stylesheet" href="llvm.css" type="text/css"> |
| 7 | </head> |
| 8 | <body> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 9 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 10 | <div class="doc_title"> |
| 11 | How to submit an LLVM bug report |
| 12 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 13 | |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 14 | <table class="layout" style="width: 90%" > |
| 15 | <tr class="layout"> |
| 16 | <td class="left"> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 17 | <ol> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 18 | <li><a href="#introduction">Introduction - Got bugs?</a></li> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 19 | <li><a href="#crashers">Crashing Bugs</a> |
| 20 | <ul> |
| 21 | <li><a href="#front-end">Front-end bugs</a> |
| 22 | <li><a href="#gccas">GCCAS bugs</a> |
| 23 | <li><a href="#gccld">GCCLD bugs</a> |
| 24 | <li><a href="#passes">Bugs in LLVM passes</a> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 25 | </ul></li> |
| 26 | <li><a href="#miscompilations">Miscompilations</a></li> |
| 27 | <li><a href="#codegen">Incorrect code generation (JIT and LLC)</a></li> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 28 | </ol> |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 29 | <div class="doc_author"> |
| 30 | <p>Written by <a href="mailto:sabre@nondot.org">Chris Lattner</a> and |
| 31 | <a href="http://misha.brukman.net">Misha Brukman</a></p> |
Reid Spencer | 97510e7 | 2004-11-01 08:24:13 +0000 | [diff] [blame] | 32 | </div> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 33 | </td> |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 34 | <td class="right"> |
Misha Brukman | e849a1a | 2004-05-12 21:26:16 +0000 | [diff] [blame] | 35 | <img src="img/Debugging.gif" alt="Debugging" width="444" height="314"> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 36 | </td> |
| 37 | </tr> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 38 | </table> |
| 39 | |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 40 | <!-- *********************************************************************** --> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 41 | <div class="doc_section"> |
| 42 | <a name="introduction">Introduction - Got bugs?</a> |
| 43 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 44 | <!-- *********************************************************************** --> |
| 45 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 46 | <div class="doc_text"> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 47 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 48 | <p>If you're working with LLVM and run into a bug, we definitely want to know |
| 49 | about it. This document describes what you can do to increase the odds of |
| 50 | getting it fixed quickly.</p> |
| 51 | |
| 52 | <p>Basically you have to do two things at a minimum. First, decide whether the |
| 53 | bug <a href="#crashers">crashes the compiler</a> (or an LLVM pass), or if the |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 54 | compiler is <a href="#miscompilations">miscompiling</a> the program. Based on |
| 55 | what type of bug it is, follow the instructions in the linked section to narrow |
| 56 | down the bug so that the person who fixes it will be able to find the problem |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 57 | more easily.</p> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 58 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 59 | <p>Once you have a reduced test-case, go to <a |
| 60 | href="http://llvm.cs.uiuc.edu/bugs/enter_bug.cgi">the LLVM Bug Tracking |
| 61 | System</a>, select the category in which the bug falls, and fill out the form |
| 62 | with the necessary details. The bug description should contain the following |
| 63 | information:</p> |
| 64 | |
John Criswell | 4d37c7b | 2003-10-22 15:06:11 +0000 | [diff] [blame] | 65 | <ul> |
Misha Brukman | afac73e | 2003-10-22 17:01:44 +0000 | [diff] [blame] | 66 | <li>All information necessary to reproduce the problem.</li> |
| 67 | <li>The reduced test-case that triggers the bug.</li> |
| 68 | <li>The location where you obtained LLVM (if not from our CVS |
| 69 | repository).</li> |
John Criswell | 4d37c7b | 2003-10-22 15:06:11 +0000 | [diff] [blame] | 70 | </ul> |
| 71 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 72 | <p>Thanks for helping us make LLVM better!</p> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 73 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 74 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 75 | |
| 76 | <!-- *********************************************************************** --> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 77 | <div class="doc_section"> |
| 78 | <a name="crashers">Crashing Bugs</a> |
| 79 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 80 | <!-- *********************************************************************** --> |
| 81 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 82 | <div class="doc_text"> |
| 83 | |
| 84 | <p>More often than not, bugs in the compiler cause it to crash - often due to an |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 85 | assertion failure of some sort. If you are running <tt><b>opt</b></tt> or |
| 86 | <tt><b>analyze</b></tt> directly, and something crashes, jump to the section on |
| 87 | <a href="#passes">bugs in LLVM passes</a>. Otherwise, the most important |
| 88 | piece of the puzzle is to figure out if it is the GCC-based front-end that is |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 89 | buggy or if it's one of the LLVM tools that has problems.</p> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 90 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 91 | <p>To figure out which program is crashing (the front-end, |
| 92 | <tt><b>gccas</b></tt>, or <tt><b>gccld</b></tt>), run the |
| 93 | <tt><b>llvm-gcc</b></tt> command line as you were when the crash occurred, but |
| 94 | add a <tt>-v</tt> option to the command line. The compiler will print out a |
John Criswell | 7992691 | 2004-03-12 20:42:16 +0000 | [diff] [blame] | 95 | bunch of stuff, and should end with telling you that one of |
| 96 | <tt><b>cc1</b>/<b>cc1plus</b></tt>, <tt><b>gccas</b></tt>, or |
| 97 | <tt><b>gccld</b></tt> crashed.</p> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 98 | |
| 99 | <ul> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 100 | |
John Criswell | 7992691 | 2004-03-12 20:42:16 +0000 | [diff] [blame] | 101 | <li>If <tt><b>cc1</b></tt> or <tt><b>cc1plus</b></tt> crashed, you found a |
| 102 | problem with the front-end. |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 103 | Jump ahead to the section on <a href="#front-end">front-end bugs</a>.</li> |
| 104 | |
| 105 | <li>If <tt><b>gccas</b></tt> crashed, you found a bug in <a href="#gccas">one |
| 106 | of the passes in <tt><b>gccas</b></tt></a>.</li> |
| 107 | |
| 108 | <li>If <tt><b>gccld</b></tt> crashed, you found a bug in <a href="#gccld">one |
| 109 | of the passes in <tt><b>gccld</b></tt></a>.</li> |
| 110 | |
| 111 | <li>Otherwise, something really weird happened. Email the list with what you |
| 112 | have at this point.</li> |
| 113 | |
| 114 | </ul> |
| 115 | |
| 116 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 117 | |
| 118 | <!-- ======================================================================= --> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 119 | <div class="doc_subsection"> |
| 120 | <a name="front-end">Front-end bugs</a> |
| 121 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 122 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 123 | <div class="doc_text"> |
| 124 | |
| 125 | <p>If the problem is in the front-end, you should re-run the same |
Brian Gaeke | eefe979 | 2003-05-23 21:03:50 +0000 | [diff] [blame] | 126 | <tt>llvm-gcc</tt> command that resulted in the crash, but add the |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 127 | <tt>-save-temps</tt> option. The compiler will crash again, but it will leave |
| 128 | behind a <tt><i>foo</i>.i</tt> file (containing preprocessed C source code) and |
| 129 | possibly <tt><i>foo</i>.s</tt> (containing LLVM assembly code), for each |
| 130 | compiled <tt><i>foo</i>.c</tt> file. Send us the <tt><i>foo</i>.i</tt> file, |
| 131 | along with a brief description of the error it caused.</p> |
| 132 | |
| 133 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 134 | |
| 135 | <!-- ======================================================================= --> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 136 | <div class="doc_subsection"> |
| 137 | <a name="gccas">GCCAS bugs</a> |
| 138 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 139 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 140 | <div class="doc_text"> |
| 141 | |
| 142 | <p>If you find that a bug crashes in the <tt><b>gccas</b></tt> stage of |
Brian Gaeke | eefe979 | 2003-05-23 21:03:50 +0000 | [diff] [blame] | 143 | compilation, compile your test-case to a <tt>.s</tt> file with the |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 144 | <tt>-save-temps</tt> option to <tt><b>llvm-gcc</b></tt>. Then run:</p> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 145 | |
Misha Brukman | f4e4feb | 2004-04-15 20:49:32 +0000 | [diff] [blame] | 146 | <div class="doc_code"> |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 147 | <p><tt><b>gccas</b> -debug-pass=Arguments < /dev/null -o - > /dev/null</tt></p> |
Misha Brukman | f4e4feb | 2004-04-15 20:49:32 +0000 | [diff] [blame] | 148 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 149 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 150 | <p>... which will print a list of arguments, indicating the list of passes that |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 151 | <tt><b>gccas</b></tt> runs. Once you have the input file and the list of |
| 152 | passes, go to the section on <a href="#passes">debugging bugs in LLVM |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 153 | passes</a>.</p> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 154 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 155 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 156 | |
| 157 | <!-- ======================================================================= --> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 158 | <div class="doc_subsection"> |
| 159 | <a name="gccld">GCCLD bugs</a> |
| 160 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 161 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 162 | <div class="doc_text"> |
| 163 | |
| 164 | <p>If you find that a bug crashes in the <tt><b>gccld</b></tt> stage of |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 165 | compilation, gather all of the <tt>.o</tt> bytecode files and libraries that are |
| 166 | being linked together (the "<tt><b>llvm-gcc</b> -v</tt>" output should include |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 167 | the full list of objects linked). Then run:</p> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 168 | |
Misha Brukman | f4e4feb | 2004-04-15 20:49:32 +0000 | [diff] [blame] | 169 | <div class="doc_code"> |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 170 | <p><tt><b>llvm-as</b> < /dev/null > null.bc<br> |
| 171 | <b>gccld</b> -debug-pass=Arguments null.bc</tt> |
| 172 | </p> |
Misha Brukman | f4e4feb | 2004-04-15 20:49:32 +0000 | [diff] [blame] | 173 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 174 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 175 | <p>... which will print a list of arguments, indicating the list of passes that |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 176 | <tt><b>gccld</b></tt> runs. Once you have the input files and the list of |
| 177 | passes, go to the section on <a href="#passes">debugging bugs in LLVM |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 178 | passes</a>.</p> |
| 179 | |
| 180 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 181 | |
| 182 | <!-- ======================================================================= --> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 183 | <div class="doc_subsection"> |
| 184 | <a name="passes">Bugs in LLVM passes</a> |
| 185 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 186 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 187 | <div class="doc_text"> |
| 188 | |
| 189 | <p>At this point, you should have some number of LLVM assembly files or bytecode |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 190 | files and a list of passes which crash when run on the specified input. In |
| 191 | order to reduce the list of passes (which is probably large) and the input to |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 192 | something tractable, use the <tt><b>bugpoint</b></tt> tool as follows:</p> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 193 | |
Misha Brukman | f4e4feb | 2004-04-15 20:49:32 +0000 | [diff] [blame] | 194 | <div class="doc_code"> |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 195 | <p><tt><b>bugpoint</b> <input files> <list of passes></tt></p> |
Misha Brukman | f4e4feb | 2004-04-15 20:49:32 +0000 | [diff] [blame] | 196 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 197 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 198 | <p><tt><b>bugpoint</b></tt> will print a bunch of output as it reduces the |
| 199 | test-case, but it should eventually print something like this:</p> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 200 | |
Misha Brukman | e8cad78 | 2004-04-19 03:07:29 +0000 | [diff] [blame] | 201 | <div class="doc_code"> |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 202 | <p><tt> |
| 203 | ...<br> |
| 204 | Emitted bytecode to 'bugpoint-reduced-simplified.bc'<br> |
| 205 | <br> |
| 206 | *** You can reproduce the problem with: opt bugpoint-reduced-simplified.bc -licm<br> |
| 207 | </tt></p> |
Misha Brukman | e8cad78 | 2004-04-19 03:07:29 +0000 | [diff] [blame] | 208 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 209 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 210 | <p>Once you complete this, please send the LLVM bytecode file and the command |
| 211 | line to reproduce the problem to the llvmbugs mailing list.</p> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 212 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 213 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 214 | |
| 215 | <!-- *********************************************************************** --> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 216 | <div class="doc_section"> |
| 217 | <a name="miscompilations">Miscompilations</a> |
| 218 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 219 | <!-- *********************************************************************** --> |
| 220 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 221 | <div class="doc_text"> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 222 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 223 | <p>A miscompilation occurs when a pass does not correctly transform a program, |
| 224 | thus producing errors that are only noticed during execution. This is different |
| 225 | from producing invalid LLVM code (i.e., code not in SSA form, using values |
| 226 | before defining them, etc.) which the verifier will check for after a pass |
| 227 | finishes its run.</p> |
| 228 | |
Chris Lattner | 8436c21 | 2004-05-11 19:34:27 +0000 | [diff] [blame] | 229 | <p>If it looks like the LLVM compiler is miscompiling a program, the very first |
Misha Brukman | 300e74b | 2004-05-12 00:57:24 +0000 | [diff] [blame] | 230 | thing to check is to make sure it is not using undefined behavior. In |
| 231 | particular, check to see if the program <a |
| 232 | href="http://valgrind.kde.org/">valgrind</a>s clean, passes purify, or some |
Chris Lattner | 8436c21 | 2004-05-11 19:34:27 +0000 | [diff] [blame] | 233 | other memory checker tool. Many of the "LLVM bugs" that we have chased down |
| 234 | ended up being bugs in the program being compiled, not LLVM.</p> |
| 235 | |
| 236 | <p>Once you determine that the program itself is not buggy, you should choose |
| 237 | which code generator you wish to compile the program with (e.g. C backend, the |
| 238 | JIT, or LLC) and optionally a series of LLVM passes to run. For example:</p> |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 239 | |
Misha Brukman | f4e4feb | 2004-04-15 20:49:32 +0000 | [diff] [blame] | 240 | <div class="doc_code"> |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 241 | <p><tt> |
| 242 | <b>bugpoint</b> -run-cbe [... optzn passes ...] file-to-test.bc --args -- [program arguments]</tt></p> |
Misha Brukman | f4e4feb | 2004-04-15 20:49:32 +0000 | [diff] [blame] | 243 | </div> |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 244 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 245 | <p><tt>bugpoint</tt> will try to narrow down your list of passes to the one pass |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 246 | that causes an error, and simplify the bytecode file as much as it can to assist |
| 247 | you. It will print a message letting you know how to reproduce the resulting |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 248 | error.</p> |
| 249 | |
| 250 | </div> |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 251 | |
| 252 | <!-- *********************************************************************** --> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 253 | <div class="doc_section"> |
| 254 | <a name="codegen">Incorrect code generation</a> |
| 255 | </div> |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 256 | <!-- *********************************************************************** --> |
| 257 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 258 | <div class="doc_text"> |
| 259 | |
| 260 | <p>Similarly to debugging incorrect compilation by mis-behaving passes, you can |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 261 | debug incorrect code generation by either LLC or the JIT, using |
| 262 | <tt>bugpoint</tt>. The process <tt>bugpoint</tt> follows in this case is to try |
| 263 | to narrow the code down to a function that is miscompiled by one or the other |
| 264 | method, but since for correctness, the entire program must be run, |
| 265 | <tt>bugpoint</tt> will compile the code it deems to not be affected with the C |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 266 | Backend, and then link in the shared object it generates.</p> |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 267 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 268 | <p>To debug the JIT:</p> |
| 269 | |
Misha Brukman | f4e4feb | 2004-04-15 20:49:32 +0000 | [diff] [blame] | 270 | <div class="doc_code"> |
Misha Brukman | 1e4ae2b | 2004-05-14 18:57:24 +0000 | [diff] [blame] | 271 | <pre> |
| 272 | bugpoint -run-jit -output=[correct output file] [bytecode file] \ |
| 273 | --tool-args -- [arguments to pass to lli] \ |
| 274 | --args -- [program arguments] |
| 275 | </pre> |
Misha Brukman | f4e4feb | 2004-04-15 20:49:32 +0000 | [diff] [blame] | 276 | </div> |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 277 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 278 | <p>Similarly, to debug the LLC, one would run:</p> |
| 279 | |
Misha Brukman | f4e4feb | 2004-04-15 20:49:32 +0000 | [diff] [blame] | 280 | <div class="doc_code"> |
Misha Brukman | 1e4ae2b | 2004-05-14 18:57:24 +0000 | [diff] [blame] | 281 | <pre> |
| 282 | bugpoint -run-llc -output=[correct output file] [bytecode file] \ |
| 283 | --tool-args -- [arguments to pass to llc] \ |
| 284 | --args -- [program arguments] |
| 285 | </pre> |
Misha Brukman | f4e4feb | 2004-04-15 20:49:32 +0000 | [diff] [blame] | 286 | </div> |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 287 | |
Misha Brukman | 180e8af | 2004-04-15 21:01:21 +0000 | [diff] [blame] | 288 | <p><b>Special note:</b> if you are debugging MultiSource or SPEC tests that |
| 289 | already exist in the <tt>llvm/test</tt> hierarchy, there is an easier way to |
| 290 | debug the JIT, LLC, and CBE, using the pre-written Makefile targets, which |
| 291 | will pass the program options specified in the Makefiles:</p> |
| 292 | |
| 293 | <div class="doc_code"> |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 294 | <p><tt> |
| 295 | cd llvm/test/../../program<br> |
Misha Brukman | 3c687a0 | 2004-05-14 19:04:07 +0000 | [diff] [blame] | 296 | make bugpoint-jit |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 297 | </tt></p> |
Misha Brukman | 180e8af | 2004-04-15 21:01:21 +0000 | [diff] [blame] | 298 | </div> |
| 299 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 300 | <p>At the end of a successful <tt>bugpoint</tt> run, you will be presented |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 301 | with two bytecode files: a <em>safe</em> file which can be compiled with the C |
| 302 | backend and the <em>test</em> file which either LLC or the JIT |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 303 | mis-codegenerates, and thus causes the error.</p> |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 304 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 305 | <p>To reproduce the error that <tt>bugpoint</tt> found, it is sufficient to do |
| 306 | the following:</p> |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 307 | |
| 308 | <ol> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 309 | |
Misha Brukman | 3c687a0 | 2004-05-14 19:04:07 +0000 | [diff] [blame] | 310 | <li><p>Regenerate the shared object from the safe bytecode file:</p> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 311 | |
Misha Brukman | 3c687a0 | 2004-05-14 19:04:07 +0000 | [diff] [blame] | 312 | <div class="doc_code"> |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 313 | <p><tt> |
| 314 | <b>llc</b> -march=c safe.bc -o safe.c<br> |
Misha Brukman | 3c687a0 | 2004-05-14 19:04:07 +0000 | [diff] [blame] | 315 | <b>gcc</b> -shared safe.c -o safe.so |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 316 | </tt></p> |
Misha Brukman | 3c687a0 | 2004-05-14 19:04:07 +0000 | [diff] [blame] | 317 | </div></li> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 318 | |
Misha Brukman | 3c687a0 | 2004-05-14 19:04:07 +0000 | [diff] [blame] | 319 | <li><p>If debugging LLC, compile test bytecode native and link with the shared |
| 320 | object:</p> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 321 | |
Misha Brukman | 3c687a0 | 2004-05-14 19:04:07 +0000 | [diff] [blame] | 322 | <div class="doc_code"> |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 323 | <p><tt> |
| 324 | <b>llc</b> test.bc -o test.s -f<br> |
| 325 | <b>gcc</b> test.s safe.so -o test.llc<br> |
Misha Brukman | 3c687a0 | 2004-05-14 19:04:07 +0000 | [diff] [blame] | 326 | ./test.llc [program options] |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 327 | </tt></p> |
Misha Brukman | 3c687a0 | 2004-05-14 19:04:07 +0000 | [diff] [blame] | 328 | </div></li> |
| 329 | |
| 330 | <li><p>If debugging the JIT, load the shared object and supply the test |
| 331 | bytecode:</p> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 332 | |
Misha Brukman | 3c687a0 | 2004-05-14 19:04:07 +0000 | [diff] [blame] | 333 | <div class="doc_code"> |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 334 | <p><tt><b>lli</b> -load=safe.so test.bc [program options]</tt></p> |
Misha Brukman | 3c687a0 | 2004-05-14 19:04:07 +0000 | [diff] [blame] | 335 | </div></li> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 336 | |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 337 | </ol> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 338 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 339 | </div> |
| 340 | |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 341 | <!-- *********************************************************************** --> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 342 | <hr> |
Misha Brukman | 637cab0 | 2004-01-15 19:03:47 +0000 | [diff] [blame] | 343 | <address> |
| 344 | <a href="http://jigsaw.w3.org/css-validator/check/referer"><img |
| 345 | src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a> |
| 346 | <a href="http://validator.w3.org/check/referer"><img |
| 347 | src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /></a> |
| 348 | |
| 349 | <a href="mailto:sabre@nondot.org">Chris Lattner</a><br> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 350 | <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a> |
| 351 | <br> |
| 352 | Last modified: $Date$ |
Misha Brukman | 637cab0 | 2004-01-15 19:03:47 +0000 | [diff] [blame] | 353 | </address> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 354 | |
| 355 | </body> |
| 356 | </html> |