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