{"id":181743,"date":"2024-03-19T11:13:00","date_gmt":"2024-03-19T10:13:00","guid":{"rendered":"https:\/\/liora.io\/en\/?p=181743"},"modified":"2026-08-09T19:41:40","modified_gmt":"2026-08-09T18:41:40","slug":"llvm-everything-you-need-to-know-about-this-compiler","status":"publish","type":"post","link":"https:\/\/liora.io\/en\/llvm-everything-you-need-to-know-about-this-compiler","title":{"rendered":"LLVM: Everything you need to know about this compiler"},"content":{"rendered":"\n<p><strong>While it is common practice for developers to write programs in a &#8220;high-level&#8221; language such as Python or Java, these same programs need to be &#8220;compiled&#8221; in order to make direct use of the microprocessor&#8217;s capabilities. LLVM has been a major innovator in this field, promoting aspects such as modularity and real-time compilation.<\/strong><\/p>\n\n\n<p><strong>Developers<\/strong> know that writing a sequence of instructions in a language such as Python, Java or <a href=\"https:\/\/liora.io\/en\/c-what-is-this-computer-language-for\">C++<\/a> is just one step in the process leading to an executable program. The process that transforms the &#8220;source code&#8221; (what the developer writes) into code that can be used by the <strong>microprocessor is called compilation.<\/strong><\/p>\n\n\n<p>Languages such as Python or Java are called high-level languages. They feature instructions that are easy for humans to understand, such as the famous IF, which is used to test a condition and is found in most languages<\/p>\n\n\n<p>Developing a program in machine code is extremely arduous, so it&#8217;s compilation that converts instructions written in a high-level language into machine code.<\/p>\n\n\n<p>Designed by computer scientist Chris Lattner around 2002, at the University of Illinois, as part of his doctoral thesis, <strong>LLVM<\/strong> was conceived with a view to renewing the approach to compilation and optimizing its use.<\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"optimizing-the-compilation-process\">Optimizing the compilation process<\/h2>\n\n\n<p><strong>Optimizing compilers<\/strong> is nothing new. The GCC compiler ,  an integral part of the GNU (for Linux) operating system launched by Richard Stallman in 1984 ,  has over time incorporated numerous optimization options to <a href=\"https:\/\/liora.io\/en\/horizontal-scaling-definition-features-and-benefits\">improve the efficiency of the code it generates.<\/a><\/p>\n\n\n<p><strong>LLVM<\/strong>, for its part, appeared in the early 2000s, at a time when multi-core<a href=\"https:\/\/liora.io\/en\/computational-resources-definition-operation-and-role\"> microprocessor<\/a> architectures were becoming commonplace, as were GPUs or computer graphics processors.<\/p>\n\n\n<p>LLVM stands for Low Level <a href=\"https:\/\/liora.io\/en\/virtual-machine-definition-use-and-benefits\">Virtual Machine,<\/a> and this name partly sums up what it achieves: the creation of virtual machines (capable of emulating the behavior of given processors) at a low level (and therefore, close to the processor).<\/p>\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex is-content-justification-center wp-container-core-buttons-is-layout-5ee10de4\" style=\"margin-top:32px;margin-bottom:32px\"><div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"\/en\/courses\/cloud-dev\/devops-engineer\">Find out more about our DevOps training<\/a><\/div><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"llvm-s-innovative-approach\">LLVM&#8217;s innovative approach<\/h2>\n\n\n<p>LLVM has proposed a number of innovative approaches:<\/p>\n\n\n<ul class=\"wp-block-list\"><li>modular architecture ;<\/li><li>JIT compilation ;<\/li><li>IR Intermediate Representation;<\/li><li>a whole ecosystem of reusable tools.<\/li><\/ul>\n\n\n<p>Let&#8217;s take a look at these various points.<\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"modular-architecture\">Modular architecture<\/h2>\n\n\n<p>Traditionally, most <strong>compilers consisted of a single program, making it difficult to optimize or extend their capabilities.<\/strong><\/p>\n\n\n<p>One of the main objectives for <strong>LLVM<\/strong> was to create a modular compiler architecture, in other words, to get different components to work harmoniously together. This has brought many benefits.<\/p>\n\n\n<p>Compiler development can be entrusted to different teams, each responsible for developing one or more specific modules. This reduces development time and increases overall efficiency. The code produced by a team is usually cleaner and easier to understand by those who would be in charge of maintaining it.<\/p>\n\n\n<p>When a<strong> compiler<\/strong> comes in the form of a series of modules, it is possible to optimize any one of them separately. And since maintenance can be carried out on this isolated module. The result is greater flexibility.<\/p>\n\n\n<p>If, over the months, it turns out that a major function is missing from the compiler, it can be added, either by modifying one of the existing modules or by creating a new one.<\/p>\n\n\n<p>In this way, the modular structure encourages experimentation and the implementation of new capabilities.<br\/>Modular <a href=\"https:\/\/liora.io\/en\/distributed-architecture-definition-and-relationship-to-big-data\">architecture<\/a> facilitates the integration of external tools.<\/p>\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex is-content-justification-center wp-container-core-buttons-is-layout-5ee10de4\" style=\"margin-top:32px;margin-bottom:32px\"><div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"\/en\/courses\/cloud-dev\/devops-engineer\">Discover our DevOps training<\/a><\/div><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"jit-or-on-the-fly-compilation\">JIT or &#8220;on-the-fly&#8221; compilation<\/h2>\n\n\n<p>In the traditional compilation process, the conversion is produced in its entirety before the program is executed, producing definitive, uneditable machine code.<\/p>\n\n\n<p>With <strong>LLVM&#8217;s JIT (Just-In-Time) compilation,<\/strong> the source code written by the developer is converted into executable machine code at the very moment of execution.<\/p>\n\n\n<p>JIT compilation takes place just before the execution of a sequence of machine code. This is known as &#8220;selective compilation&#8221;. Optimization takes place dynamically (in real time), according to the program&#8217;s behavior.<\/p>\n\n\n<p>LLVM is not the only tool to use JIT compilation. The same is true of Microsoft&#8217;s .Net and many Java implementations.<\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"ir-or-intermediate-representation\">IR or intermediate representation<\/h2>\n\n\n<p>As we saw above, LLVM stands for <strong>&#8220;low-level virtual machines&#8221;<\/strong>. And here we have another key to LLVM: it doesn&#8217;t generate code adapted to a particular microprocessor, but rather intermediate code, close to machine language but independent of a given computing unit.<\/p>\n\n\n<p>This &#8220;intermediate representation&#8221; (IR) can be adapted to all kinds of processors, from computing units to graphics processors. Once again, this approach has a number of advantages:<\/p>\n\n\n<ul class=\"wp-block-list\"><li>IR can be optimized independently of the final, processor-specific code.<\/li><li>IR code is easier to analyze and debug than machine language.<\/li><li>When a new processor is released, it&#8217;s easy to get the compiler to integrate the corresponding machine language type.<\/li><\/ul>\n\n\n<h2 class=\"wp-block-heading\" id=\"a-rich-ecosystem\">A rich ecosystem<\/h2>\n\n\n<p>LLVM also benefits from a vast ecosystem of tools and extensions capable of extending its capabilities. This is due in part to the presence of high-quality user communities. For example, the Clang compiler (based on LLVM for languages such as C, C++ and Objective-C) is actively supported by employees from Google, Apple, Mozilla and ARM. Similarly, recent high-performance languages such as Rust and Swift, similarly based on LLVM, have large, participative communities.<\/p>\n\n\n","protected":false},"excerpt":{"rendered":"<p>While it is common practice for developers to write programs in a &#8220;high-level&#8221; language such as Python or Java, these same programs need to be &#8220;compiled&#8221; in order to make direct use of the microprocessor&#8217;s capabilities. LLVM has been a major innovator in this field, promoting aspects such as modularity and real-time compilation. Developers know [&hellip;]<\/p>\n","protected":false},"author":76,"featured_media":181744,"comment_status":"open","ping_status":"open","sticky":false,"template":"elementor_theme","format":"standard","meta":{"_acf_changed":false,"editor_notices":[],"footnotes":""},"categories":[2434],"class_list":["post-181743","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud-dev"],"acf":[],"_links":{"self":[{"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/posts\/181743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/users\/76"}],"replies":[{"embeddable":true,"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/comments?post=181743"}],"version-history":[{"count":3,"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/posts\/181743\/revisions"}],"predecessor-version":[{"id":211048,"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/posts\/181743\/revisions\/211048"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/media\/181744"}],"wp:attachment":[{"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/media?parent=181743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/categories?post=181743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}