Fix some documentation for the tutorial.
[oota-llvm.git] / docs / FAQ.html
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>LLVM: Frequently Asked Questions</title>
6   <style type="text/css">
7     @import url("llvm.css");
8     .question { font-weight: bold }
9     .answer   { margin-left: 2em  }
10   </style>
11 </head>
12 <body>
13
14 <div class="doc_title">
15   LLVM: Frequently Asked Questions
16 </div>
17
18 <ol>
19   <li><a href="#license">License</a>
20   <ol>
21   <li>Why are the LLVM source code and the front-end distributed under different
22   licenses?</li>
23   <li>Does the University of Illinois Open Source License really qualify as an
24   "open source" license?</li>
25   <li>Can I modify LLVM source code and redistribute the modified source?</li>
26   <li>Can I modify LLVM source code and redistribute binaries or other tools
27   based on it, without redistributing the source?</li>
28   </ol></li>
29
30   <li><a href="#source">Source code</a>
31   <ol>
32   <li>In what language is LLVM written?</li>
33   <li>How portable is the LLVM source code?</li>
34   </ol></li>
35
36   <li><a href="#build">Build Problems</a>
37   <ol>
38   <li>When I run configure, it finds the wrong C compiler.</li>
39   <li>The <tt>configure</tt> script finds the right C compiler, but it uses the
40   LLVM linker from a previous build.  What do I do?</li>
41   <li>When creating a dynamic library, I get a strange GLIBC error.</li>
42   <li>I've updated my source tree from Subversion, and now my build is trying 
43   to use a file/directory that doesn't exist.</li>
44   <li>I've modified a Makefile in my source tree, but my build tree keeps using
45   the old version.  What do I do?</li>
46   <li>I've upgraded to a new version of LLVM, and I get strange build
47   errors.</li>
48   <li>I've built LLVM and am testing it, but the tests freeze.</li>
49   <li>Why do test results differ when I perform different types of builds?</li>
50   <li>Compiling LLVM with GCC 3.3.2 fails, what should I do?</li>
51   <li>When I use the test suite, all of the C Backend tests fail.  What is
52       wrong?</li>
53   <li>After Subversion update, rebuilding gives the error "No rule to make
54       target".</li>
55   <li><a href="#llvmc">The <tt>llvmc</tt> program gives me errors/doesn't
56       work.</a></li>
57   </ol></li>
58
59   <li><a href="#felangs">Source Languages</a>
60   <ol>
61     <li><a href="#langs">What source languages are supported?</a></li>
62     <li><a href="#langirgen">I'd like to write a self-hosting LLVM compiler. How
63       should I interface with the LLVM middle-end optimizers and back-end code 
64       generators?</a></div>
65     <li><a href="#langhlsupp">What support is there for higher level source
66       language constructs for building a compiler?</a></li>
67     <li><a href="GetElementPtr.html">I don't understand the GetElementPtr
68       instruction. Help!</a></li>
69   </ol>
70
71   <li><a href="#cfe">Using the GCC Front End</a>
72   <ol>
73     <li>
74     When I compile software that uses a configure script, the configure script
75     thinks my system has all of the header files and libraries it is testing
76     for.  How do I get configure to work correctly?
77     </li>
78
79     <li>
80     When I compile code using the LLVM GCC front end, it complains that it
81     cannot find libcrtend.a.
82     </li>
83
84     <li>
85     How can I disable all optimizations when compiling code using the LLVM GCC front end?
86     </li>
87
88     <li><a href="#translatec++">Can I use LLVM to convert C++ code to C code?</a></li>
89
90   </ol>
91   </li>
92
93   <li><a href="#cfe_code">Questions about code generated by the GCC front-end</a>
94   <ol>
95      <li><a href="#iosinit">What is this <tt>llvm.global_ctors</tt> and
96           <tt>_GLOBAL__I__tmp_webcompile...</tt> stuff that happens when I
97           #include &lt;iostream&gt;?</a></li>
98      <li><a href="#codedce">Where did all of my code go??</a></li>
99      <li><a href="#undef">What is this "<tt>undef</tt>" thing that shows up in my code?</a></li>
100   </ol>
101   </li>
102 </ol>
103
104 <div class="doc_author">
105   <p>Written by <a href="http://llvm.org">The LLVM Team</a></p>
106 </div>
107
108
109 <!-- *********************************************************************** -->
110 <div class="doc_section">
111   <a name="license">License</a>
112 </div>
113 <!-- *********************************************************************** -->
114
115 <div class="question">
116 <p>Why are the LLVM source code and the front-end distributed under different
117 licenses?</p>
118 </div>
119         
120 <div class="answer">
121 <p>The C/C++ front-ends are based on GCC and must be distributed under the GPL.
122 Our aim is to distribute LLVM source code under a <em>much less restrictive</em>
123 license, in particular one that does not compel users who distribute tools based
124 on modifying the source to redistribute the modified source code as well.</p>
125 </div>
126
127 <div class="question">
128 <p>Does the University of Illinois Open Source License really qualify as an
129 "open source" license?</p>
130 </div>
131
132 <div class="answer">
133 <p>Yes, the license is <a
134 href="http://www.opensource.org/licenses/UoI-NCSA.php">certified</a> by the Open
135 Source Initiative (OSI).</p>
136 </div>
137
138 <div class="question">
139 <p>Can I modify LLVM source code and redistribute the modified source?</p>
140 </div>
141
142 <div class="answer">
143 <p>Yes.  The modified source distribution must retain the copyright notice and
144 follow the three bulletted conditions listed in the <a
145 href="http://llvm.org/releases/1.3/LICENSE.TXT">LLVM license</a>.</p>
146 </div>
147
148 <div class="question">
149 <p>Can I modify LLVM source code and redistribute binaries or other tools based
150 on it, without redistributing the source?</p>
151 </div>
152
153 <div class="answer">
154 <p>Yes, this is why we distribute LLVM under a less restrictive license than
155 GPL, as explained in the first question above.</p>
156 </div>
157
158 <!-- *********************************************************************** -->
159 <div class="doc_section">
160   <a name="source">Source Code</a>
161 </div>
162 <!-- *********************************************************************** -->
163
164 <div class="question">
165 <p>In what language is LLVM written?</p>
166 </div>
167
168 <div class="answer">
169 <p>All of the LLVM tools and libraries are written in C++ with extensive use of
170 the STL.</p>
171 </div>
172
173 <div class="question">
174 <p>How portable is the LLVM source code?</p>
175 </div>
176
177 <div class="answer">
178 <p>The LLVM source code should be portable to most modern UNIX-like operating
179 systems.  Most of the code is written in standard C++ with operating system
180 services abstracted to a support library.  The tools required to build and test
181 LLVM have been ported to a plethora of platforms.</p>
182
183 <p>Some porting problems may exist in the following areas:</p>
184
185 <ul>
186   <li>The GCC front end code is not as portable as the LLVM suite, so it may not
187       compile as well on unsupported platforms.</li>
188
189   <li>The LLVM build system relies heavily on UNIX shell tools, like the Bourne
190       Shell and sed.  Porting to systems without these tools (MacOS 9, Plan 9)
191       will require more effort.</li>
192 </ul>
193
194 </div>
195
196 <!-- *********************************************************************** -->
197 <div class="doc_section">
198   <a name="build">Build Problems</a>
199 </div>
200 <!-- *********************************************************************** -->
201
202 <div class="question">
203 <p>When I run configure, it finds the wrong C compiler.</p>
204 </div>
205
206 <div class="answer">
207
208 <p>The <tt>configure</tt> script attempts to locate first <tt>gcc</tt> and then
209 <tt>cc</tt>, unless it finds compiler paths set in <tt>CC</tt> and <tt>CXX</tt>
210 for the C and C++ compiler, respectively.</p>
211
212 <p>If <tt>configure</tt> finds the wrong compiler, either adjust your
213 <tt>PATH</tt> environment variable or set <tt>CC</tt> and <tt>CXX</tt>
214 explicitly.</p>
215
216 </div>
217
218 <div class="question">
219 <p>The <tt>configure</tt> script finds the right C compiler, but it uses the
220 LLVM linker from a previous build.  What do I do?</p>
221 </div>
222
223 <div class="answer">
224 <p>The <tt>configure</tt> script uses the <tt>PATH</tt> to find executables, so
225 if it's grabbing the wrong linker/assembler/etc, there are two ways to fix
226 it:</p>
227
228 <ol>
229   <li><p>Adjust your <tt>PATH</tt> environment variable so that the correct
230       program appears first in the <tt>PATH</tt>.  This may work, but may not be
231       convenient when you want them <i>first</i> in your path for other
232       work.</p></li>
233
234   <li><p>Run <tt>configure</tt> with an alternative <tt>PATH</tt> that is
235       correct. In a Borne compatible shell, the syntax would be:</p>
236
237 <div class="doc_code">
238 <pre>
239 % PATH=[the path without the bad program] ./configure ...
240 </pre>
241 </div>
242
243       <p>This is still somewhat inconvenient, but it allows <tt>configure</tt>
244          to do its work without having to adjust your <tt>PATH</tt>
245          permanently.</p></li>
246 </ol>
247
248 </div>
249
250 <div class="question">
251 <p>When creating a dynamic library, I get a strange GLIBC error.</p>
252 </div>
253
254 <div class="answer">
255 <p>Under some operating systems (i.e. Linux), libtool does not work correctly if
256 GCC was compiled with the --disable-shared option.  To work around this, install
257 your own version of GCC that has shared libraries enabled by default.</p>
258 </div>
259
260 <div class="question">
261 <p>I've updated my source tree from Subversion, and now my build is trying to 
262 use a file/directory that doesn't exist.</p>
263 </div>
264
265 <div class="answer">
266 <p>You need to re-run configure in your object directory.  When new Makefiles
267 are added to the source tree, they have to be copied over to the object tree in
268 order to be used by the build.</p>
269 </div>
270
271 <div class="question">
272 <p>I've modified a Makefile in my source tree, but my build tree keeps using the
273 old version.  What do I do?</p>
274 </div>
275
276 <div class="answer">
277 <p>If the Makefile already exists in your object tree, you
278 can just run the following command in the top level directory of your object
279 tree:</p>
280
281 <div class="doc_code">
282 <pre>% ./config.status &lt;relative path to Makefile&gt;</pre>
283 </div>
284
285 <p>If the Makefile is new, you will have to modify the configure script to copy
286 it over.</p>
287
288 </div>
289
290 <div class="question">
291 <p>I've upgraded to a new version of LLVM, and I get strange build errors.</p>
292 </div>
293
294 <div class="answer">
295
296 <p>Sometimes, changes to the LLVM source code alters how the build system works.
297 Changes in libtool, autoconf, or header file dependencies are especially prone
298 to this sort of problem.</p>
299
300 <p>The best thing to try is to remove the old files and re-build.  In most
301 cases, this takes care of the problem.  To do this, just type <tt>make
302 clean</tt> and then <tt>make</tt> in the directory that fails to build.</p>
303
304 </div>
305
306 <div class="question">
307 <p>I've built LLVM and am testing it, but the tests freeze.</p>
308 </div>
309
310 <div class="answer">
311
312 <p>This is most likely occurring because you built a profile or release
313 (optimized) build of LLVM and have not specified the same information on the
314 <tt>gmake</tt> command line.</p>
315
316 <p>For example, if you built LLVM with the command:</p>
317
318 <div class="doc_code">
319 <pre>% gmake ENABLE_PROFILING=1</pre>
320 </div>
321
322 <p>...then you must run the tests with the following commands:</p>
323
324 <div class="doc_code">
325 <pre>
326 % cd llvm/test
327 % gmake ENABLE_PROFILING=1
328 </pre>
329 </div>
330
331 </div>
332
333 <div class="question">
334 <p>Why do test results differ when I perform different types of builds?</p>
335 </div>
336
337 <div class="answer">
338
339 <p>The LLVM test suite is dependent upon several features of the LLVM tools and
340 libraries.</p>
341
342 <p>First, the debugging assertions in code are not enabled in optimized or
343 profiling builds.  Hence, tests that used to fail may pass.</p>
344         
345 <p>Second, some tests may rely upon debugging options or behavior that is only
346 available in the debug build.  These tests will fail in an optimized or profile
347 build.</p>
348
349 </div>
350
351 <div class="question">
352 <p>Compiling LLVM with GCC 3.3.2 fails, what should I do?</p>
353 </div>
354
355 <div class="answer">
356 <p>This is <a href="http://gcc.gnu.org/PR?13392">a bug in GCC</a>, and 
357 affects projects other than LLVM.  Try upgrading or downgrading your GCC.</p>
358 </div>
359
360 <div class="question">
361 <p>After Subversion update, rebuilding gives the error "No rule to make
362 target".</p>
363 </div>
364
365 <div class="answer">
366 <p>If the error is of the form:</p>
367
368 <div class="doc_code">
369 <pre>
370 gmake[2]: *** No rule to make target `/path/to/somefile', needed by
371 `/path/to/another/file.d'.<br>
372 Stop.
373 </pre>
374 </div>
375
376 <p>This may occur anytime files are moved within the Subversion repository or 
377 removed entirely.  In this case, the best solution is to erase all 
378 <tt>.d</tt> files, which list dependencies for source files, and rebuild:</p>
379
380 <div class="doc_code">
381 <pre>
382 % cd $LLVM_OBJ_DIR
383 % rm -f `find . -name \*\.d` 
384 % gmake 
385 </pre>
386 </div>
387
388 <p>In other cases, it may be necessary to run <tt>make clean</tt> before
389 rebuilding.</p>
390 </div>
391
392 <div class="question"><p><a name="llvmc">
393 The <tt>llvmc</tt> program gives me errors/doesn't work.</a></p>
394 </div>
395
396 <div class="answer">
397 <p><tt>llvmc</tt> is experimental and isn't really supported. We suggest
398 using <tt>llvm-gcc</tt> instead.</p>
399 </div>
400
401 <!-- *********************************************************************** -->
402 <div class="doc_section"><a name="felangs">Source Languages</a></div>
403
404 <div class="question"><p>
405   <a name="langs">What source languages are supported?</a></p>
406 </div>
407 <div class="answer">
408   <p>LLVM currently has full support for C and C++ source languages. These are
409   available through a special version of GCC that LLVM calls the 
410   <a href="#cfe">C Front End</a></p>
411   <p>There is an incomplete version of a Java front end available in the
412   <tt>java</tt> module. There is no documentation on this yet so
413   you'll need to download the code, compile it, and try it.</p>
414   <p>In the <tt>stacker</tt> module is a compiler and runtime
415   library for the Stacker language, a "toy" language loosely based on Forth.</p>
416   <p>The PyPy developers are working on integrating LLVM into the PyPy backend
417   so that PyPy language can translate to LLVM.</p>
418 </div>
419
420 <div class="question"><p><a name="langirgen">
421   I'd like to write a self-hosting LLVM compiler. How should I interface with 
422   the LLVM middle-end optimizers and back-end code generators?
423 </a></p></div>
424 <div class="answer">
425   <p>Your compiler front-end will communicate with LLVM by creating a module in
426      the LLVM intermediate representation (IR) format. Assuming you want to 
427      write your language's compiler in the language itself (rather than C++), 
428      there are 3 major ways to tackle generating LLVM IR from a front-end:</p>
429   <ul>
430     <li>
431       <strong>Call into the LLVM libraries code using your language's FFI 
432               (foreign function interface).</strong>
433       <ul>
434         <li><em>for:</em> best tracks changes to the LLVM IR, .ll syntax, 
435             and .bc format</li>
436         <li><em>for:</em> enables running LLVM optimization passes without a 
437             emit/parse overhead</li>
438         <li><em>for:</em> adapts well to a JIT context</li>
439         <li><em>against:</em> lots of ugly glue code to write</li>
440       </ul>
441     </li>
442     <li>
443       <strong>Emit LLVM assembly from your compiler's native language.</strong>
444       <ul>
445         <li><em>for:</em> very straightforward to get started</li>
446         <li><em>against:</em> the .ll parser is slower than the bitcode reader 
447             when interfacing to the middle end</li>
448         <li><em>against:</em> you'll have to re-engineer the LLVM IR object 
449             model and asm writer in your language</li>
450         <li><em>against:</em> it may be harder to track changes to the IR</li>
451       </ul>
452     </li>
453     <li>
454       <strong>Emit LLVM bitcode from your compiler's native language.</strong>
455       <ul>
456         <li><em>for:</em> can use the more-efficient bitcode reader when 
457             interfacing to the middle end</li>
458         <li><em>against:</em> you'll have to re-engineer the LLVM IR object 
459             model and bitcode writer in your language</li>
460         <li><em>against:</em> it may be harder to track changes to the IR</li>
461       </ul>
462     </li>
463   </ul>
464   <p>If you go with the first option, the C bindings in include/llvm-c should
465      help a lot, since most languages have strong support for interfacing with 
466      C. The most common hurdle with calling C from managed code is interfacing
467      with the garbage collector. The C interface was designed to require very 
468      little memory management, and so is straightforward in this regard.</p>
469 </div>
470
471 <div class="question"><p><a name="langhlsupp">
472   What support is there for a higher level source language constructs for 
473   building a compiler?</a></p>
474 </div>
475 <div class="answer">
476   <p>Currently, there isn't much. LLVM supports an intermediate representation
477   which is useful for code representation but will not support the high level
478   (abstract syntax tree) representation needed by most compilers. There are no
479   facilities for lexical nor semantic analysis. There is, however, a <i>mostly
480     implemented</i> configuration-driven 
481   <a href="CompilerDriver.html">compiler driver</a> which simplifies the task
482   of running optimizations, linking, and executable generation.</p>
483 </div>
484
485 <div class="question"><p><a name="langhlsupp">
486   I don't understand the GetElementPtr instruction. Help!</a></p>
487 </div>
488 <div class="answer">
489   <p>See <a href="GetElementPtr.html">The Often Misunderstood GEP
490    Instruction</a>.</p>
491 </div>
492
493 <!-- *********************************************************************** -->
494 <div class="doc_section">
495   <a name="cfe">Using the GCC Front End</a>
496 </div>
497
498 <div class="question">
499 <p>
500 When I compile software that uses a configure script, the configure script
501 thinks my system has all of the header files and libraries it is testing for.
502 How do I get configure to work correctly?
503 </p>
504 </div>
505
506 <div class="answer">
507 <p>
508 The configure script is getting things wrong because the LLVM linker allows
509 symbols to be undefined at link time (so that they can be resolved during JIT
510 or translation to the C back end).  That is why configure thinks your system
511 "has everything."
512 </p>
513 <p>
514 To work around this, perform the following steps:
515 </p>
516 <ol>
517   <li>Make sure the CC and CXX environment variables contains the full path to 
518   the LLVM GCC front end.</li>
519
520   <li>Make sure that the regular C compiler is first in your PATH. </li>
521
522   <li>Add the string "-Wl,-native" to your CFLAGS environment variable.</li>
523 </ol>
524
525 <p>
526 This will allow the <tt>llvm-ld</tt> linker to create a native code executable 
527 instead of shell script that runs the JIT.  Creating native code requires 
528 standard linkage, which in turn will allow the configure script to find out if 
529 code is not linking on your system because the feature isn't available on your 
530 system.</p>
531 </div>
532
533 <div class="question">
534 <p>
535 When I compile code using the LLVM GCC front end, it complains that it cannot
536 find libcrtend.a.
537 </p>
538 </div>
539
540 <div class="answer">
541 <p>
542 The only way this can happen is if you haven't installed the runtime library. To
543 correct this, do:</p>
544
545 <div class="doc_code">
546 <pre>
547 % cd llvm/runtime
548 % make clean ; make install-bytecode
549 </pre>
550 </div>
551 </div>
552
553 <div class="question">
554 <p>
555 How can I disable all optimizations when compiling code using the LLVM GCC front end?
556 </p>
557 </div>
558
559 <div class="answer">
560 <p>
561 Passing "-Wa,-disable-opt -Wl,-disable-opt" will disable *all* cleanup and
562 optimizations done at the llvm level, leaving you with the truly horrible
563 code that you desire.
564 </p>
565 </div>
566
567
568 <div class="question">
569 <p>
570 <a name="translatec++">Can I use LLVM to convert C++ code to C code?</a>
571 </p>
572 </div>
573
574 <div class="answer">
575 <p>Yes, you can use LLVM to convert code from any language LLVM supports to C.
576 Note that the generated C code will be very low level (all loops are lowered
577 to gotos, etc) and not very pretty (comments are stripped, original source
578 formatting is totally lost, variables are renamed, expressions are regrouped), 
579 so this may not be what you're looking for.  However, this is a good way to add
580 C++ support for a processor that does not otherwise have a C++ compiler.
581 </p>
582
583 <p>Use commands like this:</p>
584
585 <ol>
586   <li><p>Compile your program as normal with llvm-g++:</p>
587
588 <div class="doc_code">
589 <pre>
590 % llvm-g++ x.cpp -o program
591 </pre>
592 </div>
593
594   <p>or:</p>
595
596 <div class="doc_code">
597 <pre>
598 % llvm-g++ a.cpp -c
599 % llvm-g++ b.cpp -c
600 % llvm-g++ a.o b.o -o program
601 </pre>
602 </div>
603
604       <p>With llvm-gcc3, this will generate program and program.bc.  The .bc
605          file is the LLVM version of the program all linked together.</p></li>
606
607   <li><p>Convert the LLVM code to C code, using the LLC tool with the C
608       backend:</p>
609
610 <div class="doc_code">
611 <pre>
612 % llc -march=c program.bc -o program.c
613 </pre>
614 </div></li>
615
616 <li><p>Finally, compile the C file:</p>
617
618 <div class="doc_code">
619 <pre>
620 % cc x.c
621 </pre>
622 </div></li>
623
624 </ol>
625
626 <p>Note that, by default, the C backend does not support exception handling.  If
627 you want/need it for a certain program, you can enable it by passing
628 "-enable-correct-eh-support" to the llc program.  The resultant code will use
629 setjmp/longjmp to implement exception support that is correct but relatively
630 slow.</p>
631
632 <p>Also note: this specific sequence of commands won't work if you use a
633 function defined in the C++ runtime library (or any other C++ library).  To
634 access an external C++ library, you must manually compile libstdc++ to LLVM
635 bitcode, statically link it into your program, then use the commands above to
636 convert the whole result into C code.  Alternatively, you can compile the
637 libraries and your application into two different chunks of C code and link
638 them.</p>
639
640 </div>
641
642 <!-- *********************************************************************** -->
643 <div class="doc_section">
644   <a name="cfe_code">Questions about code generated by the GCC front-end</a>
645 </div>
646
647 <div class="question">
648 <a name="iosinit"></a>
649 <p> What is this <tt>llvm.global_ctors</tt> and
650 <tt>_GLOBAL__I__tmp_webcompile...</tt> stuff that happens when I #include
651 &lt;iostream&gt;?</p>
652 </div>
653
654 <div class="answer">
655
656 <p>If you #include the &lt;iostream&gt; header into a C++ translation unit, the
657 file will probably use the <tt>std::cin</tt>/<tt>std::cout</tt>/... global
658 objects.  However, C++ does not guarantee an order of initialization between
659 static objects in different translation units, so if a static ctor/dtor in your
660 .cpp file used <tt>std::cout</tt>, for example, the object would not necessarily
661 be automatically initialized before your use.</p>
662
663 <p>To make <tt>std::cout</tt> and friends work correctly in these scenarios, the
664 STL that we use declares a static object that gets created in every translation
665 unit that includes <tt>&lt;iostream&gt;</tt>.  This object has a static
666 constructor and destructor that initializes and destroys the global iostream
667 objects before they could possibly be used in the file.  The code that you see
668 in the .ll file corresponds to the constructor and destructor registration code.
669 </p>
670
671 <p>If you would like to make it easier to <b>understand</b> the LLVM code
672 generated by the compiler in the demo page, consider using <tt>printf()</tt>
673 instead of <tt>iostream</tt>s to print values.</p>
674
675 </div>
676
677 <!--=========================================================================-->
678
679 <div class="question"><p>
680 <a name="codedce"></a>
681 Where did all of my code go??
682 </p></div>
683
684 <div class="answer">
685 <p>
686 If you are using the LLVM demo page, you may often wonder what happened to all
687 of the code that you typed in.  Remember that the demo script is running the
688 code through the LLVM optimizers, so if your code doesn't actually do anything
689 useful, it might all be deleted.
690 </p>
691
692 <p>
693 To prevent this, make sure that the code is actually needed.  For example, if
694 you are computing some expression, return the value from the function instead of
695 leaving it in a local variable.  If you really want to constrain the optimizer,
696 you can read from and assign to <tt>volatile</tt> global variables.
697 </p>
698 </div>
699
700 <!--=========================================================================-->
701
702 <div class="question"><p>
703 <a name="undef"></a>
704 <p>What is this "<tt>undef</tt>" thing that shows up in my code?
705 </p></div>
706
707 <div class="answer">
708 <p>
709 <a href="LangRef.html#undef"><tt>undef</tt></a> is the LLVM way of representing
710 a value that is not defined.  You can get these if you do not initialize a 
711 variable before you use it.  For example, the C function:</p>
712
713 <div class="doc_code">
714 <pre>
715 int X() { int i; return i; }
716 </pre>
717 </div>
718
719 <p>Is compiled to "<tt>ret i32 undef</tt>" because "<tt>i</tt>" never has
720 a value specified for it.</p>
721 </div>
722
723 <!-- *********************************************************************** -->
724
725 <hr>
726 <address>
727   <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
728   src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
729   <a href="http://validator.w3.org/check/referer"><img
730   src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
731
732   <a href="http://llvm.org">LLVM Compiler Infrastructure</a><br>
733   Last modified: $Date$
734 </address>
735
736 </body>
737 </html>