-
-<p>Following example illustrates advantage of integrated approach that uses
-clean interface.
-<li> Input source file <tt>a.c</tt> is compiled into LLVM byte code form.
-<li> Input source file <tt>main.c</tt> is compiled into native object code.
-<br>
-<code>
-<br>--- a.h ---
-<br>extern int foo1(void);
-<br>extern void foo2(void);
-<br>extern void foo4(void);
-<br>--- a.c ---
-<br>#include "a.h"
-<br>
-<br>static signed int i = 0;
-<br>
-<br>void foo2(void) {
-<br> i = -1;
-<br>}
-<br>
-<br>static int foo3() {
-<br>foo4();
-<br>return 10;
-<br>}
-<br>
-<br>int foo1(void) {
-<br>int data = 0;
-<br>
-<br>if (i < 0) { data = foo3(); }
-<br>
-<br>data = data + 42;
-<br>return data;
-<br>}
-<br>
-<br>--- main.c ---
-<br>#include <stdio.h>
-<br>#include "a.h"
-<br>
-<br>void foo4(void) {
-<br> printf ("Hi\n");
-<br>}
-<br>
-<br>int main() {
-<br> return foo1();
-<br>}
-<br>
-<br>--- command lines ---
-<br> $ llvm-gcc4 --emit-llvm -c a.c -o a.o # <-- a.o is LLVM bytecode file
-<br> $ llvm-gcc4 -c main.c -o main.o # <-- main.o is native object file
-<br> $ llvm-gcc4 a.o main.o -o main # <-- standard link command without any modifications
-<br>
-</code>
-</p>
-<p>
-In this example, the linker recognizes that <tt>foo2()</tt> is a externally visible
-symbol defined in LLVM byte code file. This information is collected using
-<a href=#lreadllvmbytecodefile> readLLVMByteCodeFile() </a>. Based on this
-information, linker completes its usual symbol resolution pass and finds that
-<tt>foo2()</tt> is not used anywhere. This information is used by LLVM optimizer
-and it removes <tt>foo2()</tt>. As soon as <tt>foo2()</tt> is removed, optimizer
-recognizes that condition <tt> i < 0 </tt> is always false, which means
-<tt>foo3()</tt> is never used. Hence, optimizer removes <tt>foo3()</tt> also.
-And this in turn, enables linker to remove <tt>foo4()</tt>.
-This example illustrates advantage of tight integration with linker. Here,
-optimizer can not remove <tt>foo3()</tt> without the linker's input.
-</p>
+ <p>The following example illustrates the advantages of LTO's integrated
+ approach and clean interface. This example requires a system linker which
+ supports LTO through the interface described in this document. Here,
+ llvm-gcc transparently invokes system linker. </p>
+ <ul>
+ <li> Input source file <tt>a.c</tt> is compiled into LLVM bitcode form.
+ <li> Input source file <tt>main.c</tt> is compiled into native object code.
+ </ul>
+<div class="doc_code"><pre>
+--- a.h ---
+extern int foo1(void);
+extern void foo2(void);
+extern void foo4(void);
+--- a.c ---
+#include "a.h"
+
+static signed int i = 0;
+
+void foo2(void) {
+ i = -1;
+}
+
+static int foo3() {
+foo4();
+return 10;
+}
+
+int foo1(void) {
+int data = 0;
+
+if (i < 0) { data = foo3(); }
+
+data = data + 42;
+return data;
+}
+
+--- main.c ---
+#include <stdio.h>
+#include "a.h"
+
+void foo4(void) {
+ printf ("Hi\n");
+}
+
+int main() {
+ return foo1();
+}
+
+--- command lines ---
+$ llvm-gcc --emit-llvm -c a.c -o a.o # <-- a.o is LLVM bitcode file
+$ llvm-gcc -c main.c -o main.o # <-- main.o is native object file
+$ llvm-gcc a.o main.o -o main # <-- standard link command without any modifications
+</pre></div>
+ <p>In this example, the linker recognizes that <tt>foo2()</tt> is an
+ externally visible symbol defined in LLVM bitcode file. The linker completes
+ its usual symbol resolution
+ pass and finds that <tt>foo2()</tt> is not used anywhere. This information
+ is used by the LLVM optimizer and it removes <tt>foo2()</tt>. As soon as
+ <tt>foo2()</tt> is removed, the optimizer recognizes that condition
+ <tt>i < 0</tt> is always false, which means <tt>foo3()</tt> is never
+ used. Hence, the optimizer removes <tt>foo3()</tt>, also. And this in turn,
+ enables linker to remove <tt>foo4()</tt>. This example illustrates the
+ advantage of tight integration with the linker. Here, the optimizer can not
+ remove <tt>foo3()</tt> without the linker's input.
+ </p>