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> |
NAKAMURA Takumi | 5c6e4df | 2011-10-31 11:21:59 +0000 | [diff] [blame] | 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 6 | <title>How to submit an LLVM bug report</title> |
Daniel Dunbar | adea497 | 2012-04-19 20:20:34 +0000 | [diff] [blame] | 7 | <link rel="stylesheet" href="_static/llvm.css" type="text/css"> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 8 | </head> |
| 9 | <body> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 10 | |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 11 | <h1> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 12 | How to submit an LLVM bug report |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 13 | </h1> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 14 | |
Reid Spencer | d3f876c | 2004-11-01 08:19:36 +0000 | [diff] [blame] | 15 | <table class="layout" style="width: 90%" > |
| 16 | <tr class="layout"> |
| 17 | <td class="left"> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 18 | <ol> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 19 | <li><a href="#introduction">Introduction - Got bugs?</a></li> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 20 | <li><a href="#crashers">Crashing Bugs</a> |
| 21 | <ul> |
| 22 | <li><a href="#front-end">Front-end bugs</a> |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 23 | <li><a href="#ct_optimizer">Compile-time optimization bugs</a> |
| 24 | <li><a href="#ct_codegen">Code generator bugs</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> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 34 | </tr> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 35 | </table> |
| 36 | |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 37 | <!-- *********************************************************************** --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 38 | <h2> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 39 | <a name="introduction">Introduction - Got bugs?</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 40 | </h2> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 41 | <!-- *********************************************************************** --> |
| 42 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 43 | <div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 44 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 45 | <p>If you're working with LLVM and run into a bug, we definitely want to know |
| 46 | about it. This document describes what you can do to increase the odds of |
| 47 | getting it fixed quickly.</p> |
| 48 | |
| 49 | <p>Basically you have to do two things at a minimum. First, decide whether the |
| 50 | bug <a href="#crashers">crashes the compiler</a> (or an LLVM pass), or if the |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 51 | compiler is <a href="#miscompilations">miscompiling</a> the program (i.e., the |
| 52 | compiler successfully produces an executable, but it doesn't run right). Based |
| 53 | on |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 54 | what type of bug it is, follow the instructions in the linked section to narrow |
| 55 | 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] | 56 | more easily.</p> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 57 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 58 | <p>Once you have a reduced test-case, go to <a |
Reid Spencer | 05fe4b0 | 2006-03-14 05:39:39 +0000 | [diff] [blame] | 59 | href="http://llvm.org/bugs/enter_bug.cgi">the LLVM Bug Tracking |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 60 | System</a> and fill out the form with the necessary details (note that you don't |
Benjamin Kramer | 8040cd3 | 2009-10-12 14:46:08 +0000 | [diff] [blame] | 61 | need to pick a category, just use the "new-bugs" category if you're not sure). |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 62 | The bug description should contain the following |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 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> |
Reid Spencer | 669ed45 | 2007-07-09 08:04:31 +0000 | [diff] [blame] | 68 | <li>The location where you obtained LLVM (if not from our Subversion |
Misha Brukman | afac73e | 2003-10-22 17:01:44 +0000 | [diff] [blame] | 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 | <!-- *********************************************************************** --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 77 | <h2> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 78 | <a name="crashers">Crashing Bugs</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 79 | </h2> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 80 | <!-- *********************************************************************** --> |
| 81 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 82 | <div> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 83 | |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 84 | <p>More often than not, bugs in the compiler cause it to crash—often due |
| 85 | to an assertion failure of some sort. The most important |
| 86 | piece of the puzzle is to figure out if it is crashing in the GCC front-end |
| 87 | or if it is one of the LLVM libraries (e.g. the optimizer or code generator) |
| 88 | that has problems.</p> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 89 | |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 90 | <p>To figure out which component is crashing (the front-end, |
| 91 | optimizer or code generator), run the |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 92 | <tt><b>llvm-gcc</b></tt> command line as you were when the crash occurred, but |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 93 | with the following extra command line options:</p> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 94 | |
| 95 | <ul> |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 96 | <li><tt><b>-O0 -emit-llvm</b></tt>: If <tt>llvm-gcc</tt> still crashes when |
| 97 | passed these options (which disable the optimizer and code generator), then |
| 98 | the crash is in the front-end. Jump ahead to the section on <a |
| 99 | href="#front-end">front-end bugs</a>.</li> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 100 | |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 101 | <li><tt><b>-emit-llvm</b></tt>: If <tt>llvm-gcc</tt> crashes with this option |
| 102 | (which disables the code generator), you found an optimizer bug. Jump ahead |
| 103 | to <a href="#ct_optimizer"> compile-time optimization bugs</a>.</li> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 104 | |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 105 | <li>Otherwise, you have a code generator crash. Jump ahead to <a |
| 106 | href="#ct_codegen">code generator bugs</a>.</li> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 107 | |
| 108 | </ul> |
| 109 | |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 110 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 111 | <h3> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 112 | <a name="front-end">Front-end bugs</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 113 | </h3> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 114 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 115 | <div> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 116 | |
| 117 | <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] | 118 | <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] | 119 | <tt>-save-temps</tt> option. The compiler will crash again, but it will leave |
| 120 | behind a <tt><i>foo</i>.i</tt> file (containing preprocessed C source code) and |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 121 | possibly <tt><i>foo</i>.s</tt> for each |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 122 | compiled <tt><i>foo</i>.c</tt> file. Send us the <tt><i>foo</i>.i</tt> file, |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 123 | along with the options you passed to llvm-gcc, and a brief description of the |
| 124 | error it caused.</p> |
Bill Wendling | fa8a0e5 | 2007-02-24 03:46:42 +0000 | [diff] [blame] | 125 | |
| 126 | <p>The <a href="http://delta.tigris.org/">delta</a> tool helps to reduce the |
| 127 | preprocessed file down to the smallest amount of code that still replicates the |
| 128 | problem. You're encouraged to use delta to reduce the code to make the |
| 129 | developers' lives easier. <a |
| 130 | href="http://gcc.gnu.org/wiki/A_guide_to_testcase_reduction">This website</a> |
| 131 | has instructions on the best way to use delta.</p> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 132 | |
| 133 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 134 | |
| 135 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 136 | <h3> |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 137 | <a name="ct_optimizer">Compile-time optimization bugs</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 138 | </h3> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 139 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 140 | <div> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 141 | |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 142 | <p>If you find that a bug crashes in the optimizer, compile your test-case to a |
| 143 | <tt>.bc</tt> file by passing "<tt><b>-emit-llvm -O0 -c -o foo.bc</b></tt>". |
| 144 | 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 | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 147 | <p><tt><b>opt</b> -std-compile-opts -debug-pass=Arguments foo.bc |
| 148 | -disable-output</tt></p> |
Misha Brukman | f4e4feb | 2004-04-15 20:49:32 +0000 | [diff] [blame] | 149 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 150 | |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 151 | <p>This command should do two things: it should print out a list of passes, and |
Chad Rosier | 7b5c20b | 2011-06-07 20:03:13 +0000 | [diff] [blame] | 152 | then it should crash in the same way as llvm-gcc. If it doesn't crash, please |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 153 | follow the instructions for a <a href="#front-end">front-end bug</a>.</p> |
| 154 | |
| 155 | <p>If this does crash, then you should be able to debug this with the following |
| 156 | bugpoint command:</p> |
| 157 | |
| 158 | <div class="doc_code"> |
| 159 | <p><tt><b>bugpoint</b> foo.bc <list of passes printed by |
| 160 | <b>opt</b>></tt></p> |
| 161 | </div> |
| 162 | |
| 163 | <p>Please run this, then file a bug with the instructions and reduced .bc files |
| 164 | that bugpoint emits. If something goes wrong with bugpoint, please submit the |
| 165 | "foo.bc" file and the list of passes printed by <b>opt</b>.</p> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 166 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 167 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 168 | |
| 169 | <!-- ======================================================================= --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 170 | <h3> |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 171 | <a name="ct_codegen">Code generator bugs</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 172 | </h3> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 173 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 174 | <div> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 175 | |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 176 | <p>If you find a bug that crashes llvm-gcc in the code generator, compile your |
| 177 | source file to a .bc file by passing "<tt><b>-emit-llvm -c -o foo.bc</b></tt>" |
| 178 | to llvm-gcc (in addition to the options you already pass). Once your have |
| 179 | foo.bc, one of the following commands should fail:</p> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 180 | |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 181 | <ol> |
Dan Gohman | 0cabaa5 | 2009-08-25 15:54:01 +0000 | [diff] [blame] | 182 | <li><tt><b>llc</b> foo.bc</tt></li> |
| 183 | <li><tt><b>llc</b> foo.bc -relocation-model=pic</tt></li> |
| 184 | <li><tt><b>llc</b> foo.bc -relocation-model=static</tt></li> |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 185 | </ol> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 186 | |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 187 | <p>If none of these crash, please follow the instructions for a |
| 188 | <a href="#front-end">front-end bug</a>. If one of these do crash, you should |
| 189 | be able to reduce this with one of the following bugpoint command lines (use |
| 190 | the one corresponding to the command above that failed):</p> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 191 | |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 192 | <ol> |
Chris Lattner | c25904f | 2007-02-25 18:50:48 +0000 | [diff] [blame] | 193 | <li><tt><b>bugpoint</b> -run-llc foo.bc</tt></li> |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 194 | <li><tt><b>bugpoint</b> -run-llc foo.bc --tool-args |
| 195 | -relocation-model=pic</tt></li> |
| 196 | <li><tt><b>bugpoint</b> -run-llc foo.bc --tool-args |
| 197 | -relocation-model=static</tt></li> |
| 198 | </ol> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 199 | |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 200 | <p>Please run this, then file a bug with the instructions and reduced .bc file |
| 201 | that bugpoint emits. If something goes wrong with bugpoint, please submit the |
| 202 | "foo.bc" file and the option that llc crashes with.</p> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 203 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 204 | </div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 205 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 206 | </div> |
| 207 | |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 208 | <!-- *********************************************************************** --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 209 | <h2> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 210 | <a name="miscompilations">Miscompilations</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 211 | </h2> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 212 | <!-- *********************************************************************** --> |
| 213 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 214 | <div> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 215 | |
Chris Lattner | 1a5ed97 | 2007-02-25 01:11:36 +0000 | [diff] [blame] | 216 | <p>If llvm-gcc successfully produces an executable, but that executable doesn't |
| 217 | run right, this is either a bug in the code or a bug in the |
| 218 | compiler. The first thing to check is to make sure it is not using undefined |
| 219 | behavior (e.g. reading a variable before it is defined). In particular, check |
| 220 | to see if the program <a href="http://valgrind.org/">valgrind</a>s clean, |
| 221 | passes purify, or some other memory checker tool. Many of the "LLVM bugs" that |
| 222 | we have chased down ended up being bugs in the program being compiled, not |
| 223 | LLVM.</p> |
Chris Lattner | 8436c21 | 2004-05-11 19:34:27 +0000 | [diff] [blame] | 224 | |
| 225 | <p>Once you determine that the program itself is not buggy, you should choose |
| 226 | which code generator you wish to compile the program with (e.g. C backend, the |
| 227 | 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] | 228 | |
Misha Brukman | f4e4feb | 2004-04-15 20:49:32 +0000 | [diff] [blame] | 229 | <div class="doc_code"> |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 230 | <p><tt> |
| 231 | <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] | 232 | </div> |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 233 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 234 | <p><tt>bugpoint</tt> will try to narrow down your list of passes to the one pass |
Gabor Greif | 04367bf | 2007-07-06 22:07:22 +0000 | [diff] [blame] | 235 | that causes an error, and simplify the bitcode file as much as it can to assist |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 236 | 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] | 237 | error.</p> |
| 238 | |
| 239 | </div> |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 240 | |
| 241 | <!-- *********************************************************************** --> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 242 | <h2> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 243 | <a name="codegen">Incorrect code generation</a> |
NAKAMURA Takumi | 05d0265 | 2011-04-18 23:59:50 +0000 | [diff] [blame] | 244 | </h2> |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 245 | <!-- *********************************************************************** --> |
| 246 | |
NAKAMURA Takumi | f5af6ad | 2011-04-23 00:30:22 +0000 | [diff] [blame] | 247 | <div> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 248 | |
| 249 | <p>Similarly to debugging incorrect compilation by mis-behaving passes, you can |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 250 | debug incorrect code generation by either LLC or the JIT, using |
| 251 | <tt>bugpoint</tt>. The process <tt>bugpoint</tt> follows in this case is to try |
| 252 | to narrow the code down to a function that is miscompiled by one or the other |
| 253 | method, but since for correctness, the entire program must be run, |
| 254 | <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] | 255 | Backend, and then link in the shared object it generates.</p> |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 256 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 257 | <p>To debug the JIT:</p> |
| 258 | |
Misha Brukman | f4e4feb | 2004-04-15 20:49:32 +0000 | [diff] [blame] | 259 | <div class="doc_code"> |
Misha Brukman | 1e4ae2b | 2004-05-14 18:57:24 +0000 | [diff] [blame] | 260 | <pre> |
Gabor Greif | 04367bf | 2007-07-06 22:07:22 +0000 | [diff] [blame] | 261 | bugpoint -run-jit -output=[correct output file] [bitcode file] \ |
Bill Wendling | 4a2bca8 | 2009-04-05 00:41:19 +0000 | [diff] [blame] | 262 | --tool-args -- [arguments to pass to lli] \ |
Misha Brukman | 1e4ae2b | 2004-05-14 18:57:24 +0000 | [diff] [blame] | 263 | --args -- [program arguments] |
| 264 | </pre> |
Misha Brukman | f4e4feb | 2004-04-15 20:49:32 +0000 | [diff] [blame] | 265 | </div> |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 266 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 267 | <p>Similarly, to debug the LLC, one would run:</p> |
| 268 | |
Misha Brukman | f4e4feb | 2004-04-15 20:49:32 +0000 | [diff] [blame] | 269 | <div class="doc_code"> |
Misha Brukman | 1e4ae2b | 2004-05-14 18:57:24 +0000 | [diff] [blame] | 270 | <pre> |
Gabor Greif | 04367bf | 2007-07-06 22:07:22 +0000 | [diff] [blame] | 271 | bugpoint -run-llc -output=[correct output file] [bitcode file] \ |
Bill Wendling | 4a2bca8 | 2009-04-05 00:41:19 +0000 | [diff] [blame] | 272 | --tool-args -- [arguments to pass to llc] \ |
Misha Brukman | 1e4ae2b | 2004-05-14 18:57:24 +0000 | [diff] [blame] | 273 | --args -- [program arguments] |
| 274 | </pre> |
Misha Brukman | f4e4feb | 2004-04-15 20:49:32 +0000 | [diff] [blame] | 275 | </div> |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 276 | |
Misha Brukman | 180e8af | 2004-04-15 21:01:21 +0000 | [diff] [blame] | 277 | <p><b>Special note:</b> if you are debugging MultiSource or SPEC tests that |
| 278 | already exist in the <tt>llvm/test</tt> hierarchy, there is an easier way to |
| 279 | debug the JIT, LLC, and CBE, using the pre-written Makefile targets, which |
| 280 | will pass the program options specified in the Makefiles:</p> |
| 281 | |
| 282 | <div class="doc_code"> |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 283 | <p><tt> |
| 284 | cd llvm/test/../../program<br> |
Misha Brukman | 3c687a0 | 2004-05-14 19:04:07 +0000 | [diff] [blame] | 285 | make bugpoint-jit |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 286 | </tt></p> |
Misha Brukman | 180e8af | 2004-04-15 21:01:21 +0000 | [diff] [blame] | 287 | </div> |
| 288 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 289 | <p>At the end of a successful <tt>bugpoint</tt> run, you will be presented |
Gabor Greif | 04367bf | 2007-07-06 22:07:22 +0000 | [diff] [blame] | 290 | with two bitcode files: a <em>safe</em> file which can be compiled with the C |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 291 | 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] | 292 | mis-codegenerates, and thus causes the error.</p> |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 293 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 294 | <p>To reproduce the error that <tt>bugpoint</tt> found, it is sufficient to do |
| 295 | the following:</p> |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 296 | |
| 297 | <ol> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 298 | |
Gabor Greif | 04367bf | 2007-07-06 22:07:22 +0000 | [diff] [blame] | 299 | <li><p>Regenerate the shared object from the safe bitcode file:</p> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 300 | |
Misha Brukman | 3c687a0 | 2004-05-14 19:04:07 +0000 | [diff] [blame] | 301 | <div class="doc_code"> |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 302 | <p><tt> |
| 303 | <b>llc</b> -march=c safe.bc -o safe.c<br> |
Misha Brukman | 3c687a0 | 2004-05-14 19:04:07 +0000 | [diff] [blame] | 304 | <b>gcc</b> -shared safe.c -o safe.so |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 305 | </tt></p> |
Misha Brukman | 3c687a0 | 2004-05-14 19:04:07 +0000 | [diff] [blame] | 306 | </div></li> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 307 | |
Gabor Greif | 04367bf | 2007-07-06 22:07:22 +0000 | [diff] [blame] | 308 | <li><p>If debugging LLC, compile test bitcode native and link with the shared |
Misha Brukman | 3c687a0 | 2004-05-14 19:04:07 +0000 | [diff] [blame] | 309 | object:</p> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 310 | |
Misha Brukman | 3c687a0 | 2004-05-14 19:04:07 +0000 | [diff] [blame] | 311 | <div class="doc_code"> |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 312 | <p><tt> |
Dan Gohman | 0cabaa5 | 2009-08-25 15:54:01 +0000 | [diff] [blame] | 313 | <b>llc</b> test.bc -o test.s<br> |
Chris Lattner | 4129b2a | 2004-05-23 21:05:39 +0000 | [diff] [blame] | 314 | <b>gcc</b> test.s safe.so -o test.llc<br> |
Misha Brukman | 3c687a0 | 2004-05-14 19:04:07 +0000 | [diff] [blame] | 315 | ./test.llc [program options] |
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> |
| 318 | |
| 319 | <li><p>If debugging the JIT, load the shared object and supply the test |
Gabor Greif | 04367bf | 2007-07-06 22:07:22 +0000 | [diff] [blame] | 320 | bitcode:</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><b>lli</b> -load=safe.so test.bc [program options]</tt></p> |
Misha Brukman | 3c687a0 | 2004-05-14 19:04:07 +0000 | [diff] [blame] | 324 | </div></li> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 325 | |
Misha Brukman | f1d01fb | 2003-09-17 18:51:47 +0000 | [diff] [blame] | 326 | </ol> |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 327 | |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 328 | </div> |
| 329 | |
Chris Lattner | 8b6be36 | 2003-05-21 22:21:07 +0000 | [diff] [blame] | 330 | <!-- *********************************************************************** --> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 331 | <hr> |
Misha Brukman | 637cab0 | 2004-01-15 19:03:47 +0000 | [diff] [blame] | 332 | <address> |
| 333 | <a href="http://jigsaw.w3.org/css-validator/check/referer"><img |
Misha Brukman | 4440870 | 2008-12-11 17:34:48 +0000 | [diff] [blame] | 334 | src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a> |
Misha Brukman | 637cab0 | 2004-01-15 19:03:47 +0000 | [diff] [blame] | 335 | <a href="http://validator.w3.org/check/referer"><img |
Misha Brukman | f00ddb0 | 2008-12-11 18:23:24 +0000 | [diff] [blame] | 336 | src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a> |
Misha Brukman | 637cab0 | 2004-01-15 19:03:47 +0000 | [diff] [blame] | 337 | |
| 338 | <a href="mailto:sabre@nondot.org">Chris Lattner</a><br> |
NAKAMURA Takumi | b9a3363 | 2011-04-09 02:13:37 +0000 | [diff] [blame] | 339 | <a href="http://llvm.org/">The LLVM Compiler Infrastructure</a> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 340 | <br> |
| 341 | Last modified: $Date$ |
Misha Brukman | 637cab0 | 2004-01-15 19:03:47 +0000 | [diff] [blame] | 342 | </address> |
Misha Brukman | 9408239 | 2003-10-31 18:37:20 +0000 | [diff] [blame] | 343 | |
| 344 | </body> |
| 345 | </html> |