LLVM is a set of compiler and toolchain technologies that can be used to develop a frontend for any programming language and a backend for any instruction set architecture . LLVM is designed around a language-independent intermediate representation (IR) that serves as a portable , high-level assembly language that can be optimized with a variety of transformations over multiple passes. The name LLVM originally stood for Low Level Virtual Machine, though the project has expanded and the name is no longer officially an initialism .
43-831: LLVM is written in C++ and is designed for compile-time , link-time , runtime , and "idle-time" optimization. Originally implemented for C and C++, the language-agnostic design of LLVM has since spawned a wide variety of frontends: languages with compilers that use LLVM (or which do not directly use LLVM but can generate compiled programs as LLVM IR) include ActionScript , Ada , C# for .NET , Common Lisp , PicoLisp , Crystal , CUDA , D , Delphi , Dylan , Forth , Fortran , FreeBASIC , Free Pascal , Halide , Haskell , Idris , Java bytecode , Julia , Kotlin , LabVIEW 's G language, Lua , Objective-C , OpenCL , PostgreSQL 's SQL and PLpgSQL, Ruby , Rust , Scala , Standard ML , Swift , Xojo , and Zig . The LLVM project started in 2000 at
86-533: A polyhedral model . llvm-libc is an incomplete, upcoming, ABI independent C standard library designed by and for the LLVM project. Due to its permissive license, many vendors release their own tuned forks of LLVM. This is officially recognized by LLVM's documentation, which suggests against using version numbers in feature checks for this reason. Some of the vendors include: Compile-time In computer science , compile time (or compile-time ) describes
129-470: A concrete language can be represented by combining these basic types in LLVM. For example, a class in C++ can be represented by a mix of structures, functions and arrays of function pointers . The LLVM JIT compiler can optimize unneeded static branches out of a program at runtime, and thus is useful for partial evaluation in cases where a program has many options, most of which can easily be determined unneeded in
172-469: A proper 3D hardware driver loaded. In 2011, programs compiled by GCC outperformed those from LLVM by 10%, on average. In 2013, phoronix reported that LLVM had caught up with GCC, compiling binaries of approximately equal performance. LLVM has become an umbrella project containing multiple components. LLVM was originally written to be a replacement for the extant code generator in the GCC stack, and many of
215-518: A specific environment. This feature is used in the OpenGL pipeline of Mac OS X Leopard (v10.5) to provide support for missing hardware features. Graphics code within the OpenGL stack can be left in intermediate representation and then compiled when run on the target machine. On systems with high-end graphics processing units (GPUs), the resulting code remains quite thin, passing the instructions on to
258-580: A target platform. LLVM can accept the IR from the GNU Compiler Collection (GCC) toolchain , allowing it to be used with a wide array of extant compiler front-ends written for that project. LLVM can also be built with gcc after version 7.5. LLVM can also generate relocatable machine code at compile-time or link-time or even binary machine code at runtime. LLVM supports a language-independent instruction set and type system . Each instruction
301-498: A team to work on the LLVM system for various uses within Apple's development systems. LLVM has been an integral part of Apple's Xcode development tools for macOS and iOS since Xcode 4 in 2011. In 2006, Lattner started working on a new project named Clang . The combination of Clang frontend and LLVM backend is named Clang/LLVM or simply Clang. The name LLVM was originally an initialism for Low Level Virtual Machine . However,
344-907: Is PNaCl . The LLVM project also introduces another type of intermediate representation named MLIR which helps build reusable and extensible compiler infrastructure by employing a plugin architecture named Dialect. It enables the use of higher-level information on the program structure in the process of optimization including polyhedral compilation . At version 16, LLVM supports many instruction sets , including IA-32 , x86-64 , ARM , Qualcomm Hexagon , LoongArch , M68K , MIPS , NVIDIA Parallel Thread Execution (PTX, also named NVPTX in LLVM documentation), PowerPC , AMD TeraScale , most recent AMD GPUs (also named AMDGPU in LLVM documentation), SPARC , z/Architecture (also named SystemZ in LLVM documentation), and XCore . Some features are not available on some platforms. Most features are present for IA-32, x86-64, z/Architecture, ARM, and PowerPC. RISC-V
387-407: Is LLVM's framework for translating machine instructions between textual forms and machine code. Formerly, LLVM relied on the system assembler, or one provided by a toolchain, to translate assembly into machine code. LLVM MC's integrated assembler supports most LLVM targets, including IA-32, x86-64, ARM, and ARM64. For some targets, including the various MIPS instruction sets, integrated assembly support
430-543: Is a stub . You can help Misplaced Pages by expanding it . Apache License 2.0 The Apache License is a permissive free software license written by the Apache Software Foundation (ASF). It allows users to use the software for any purpose, to distribute it, to modify it, and to distribute modified versions of the software under the terms of the license, without concern for royalties . The ASF and its projects release their software products under
473-535: Is aimed at replacing the C/Objective-C compiler in the GCC system with a system that is more easily integrated with integrated development environments (IDEs) and has wider support for multithreading . Support for OpenMP directives has been included in Clang since release 3.8. The Utrecht Haskell compiler can generate code for LLVM. While the generator was in early stages of development, in many cases it
SECTION 10
#1732772692543516-594: Is in static single assignment form (SSA), meaning that each variable (called a typed register) is assigned once and then frozen. This helps simplify the analysis of dependencies among variables. LLVM allows code to be compiled statically, as it is under the traditional GCC system, or left for late-compiling from the IR to machine code via just-in-time compilation (JIT), similar to Java . The type system consists of basic types such as integer or floating-point numbers and five derived types : pointers , arrays , vectors , structures , and functions . A type construct in
559-431: Is mostly obsolete. LLVM currently supports compiling of Ada , C , C++ , D , Delphi , Fortran , Haskell , Julia , Objective-C , Rust , and Swift using various frontends . Widespread interest in LLVM has led to several efforts to develop new frontends for many languages. The one that has received the most attention is Clang, a newer compiler supporting C, C++, and Objective-C. Primarily supported by Apple, Clang
602-819: Is supported as of version 7. In the past, LLVM also supported other backends, fully or partially, including C backend, Cell SPU , mblaze (MicroBlaze) , AMD R600, DEC/Compaq Alpha ( Alpha AXP ) and Nios2 , but that hardware is mostly obsolete, and LLVM developers decided the support and maintenance costs were no longer justified. LLVM also supports WebAssembly as a target, enabling compiled programs to execute in WebAssembly-enabled environments such as Google Chrome / Chromium , Firefox , Microsoft Edge , Apple Safari or WAVM . LLVM-compliant WebAssembly compilers typically support mostly unmodified source code written in C, C++, D, Rust, Nim, Kotlin and several other languages. The LLVM machine code (MC) subproject
645-543: Is usable but still in the beta stage. The lld subproject is an attempt to develop a built-in, platform-independent linker for LLVM. lld aims to remove dependence on a third-party linker. As of May 2017, lld supports ELF , PE/COFF , Mach-O , and WebAssembly in descending order of completeness. lld is faster than both flavors of GNU ld . Unlike the GNU linkers, lld has built-in support for link-time optimization (LTO). This allows for faster code generation as it bypasses
688-500: The NOTICE text is permissible, provided that these notices cannot be understood as modifying the license. Modifications may have appropriate copyright notices, and may provide different license terms for the modifications. Unless explicitly stated otherwise, any contributions submitted by a licensee to a licensor will be under the terms of the license without any terms and conditions, but this does not preclude any separate agreements with
731-671: The Free Software Foundation agree that the Apache License 2.0 is a free software license , compatible with the GNU General Public License (GPL) version 3, meaning that code under GPLv3 and Apache License 2.0 can be combined, as long as the resulting software is licensed under the GPLv3. The Free Software Foundation considers all versions of the Apache License to be incompatible with
774-561: The Rust compiler, a Java bytecode frontend, a Common Intermediate Language (CIL) frontend, the MacRuby implementation of Ruby 1.9, various frontends for Standard ML , and a new graph coloring register allocator. The core of LLVM is the intermediate representation (IR), a low-level programming language similar to assembly. IR is a strongly typed reduced instruction set computer (RISC) instruction set which abstracts away most details of
817-484: The University of Illinois at Urbana–Champaign , under the direction of Vikram Adve and Chris Lattner . LLVM was originally developed as a research infrastructure to investigate dynamic compilation techniques for static and dynamic programming languages. LLVM was released under the University of Illinois/NCSA Open Source License , a permissive free software licence . In 2005, Apple Inc. hired Lattner and formed
860-531: The 1.1 version may have used different wording due to varying requirements for attribution or mark identification, but the binding terms were the same. In January 2004, ASF decided to depart from the BSD model and produced the Apache License 2.0. The stated goals of the license included making it easier for non-ASF projects to use, improving compatibility with GPL -based software, allowing the license to be included by reference instead of listed in every file, clarifying
903-446: The Apache License 2.0 to be an acceptable free license because of its patent provisions. The OpenBSD policy believes that when the license forces one to give up a legal right that one otherwise has, that license is no longer free. Moreover, the project objects to involving contract law with copyright law, stating "...Copyright law is somewhat standardized by international agreements, contract law differs wildly among jurisdictions. So what
SECTION 20
#1732772692543946-620: The Apache License. The license is also used by many non-ASF projects. Beginning in 1995, the Apache Group (later the Apache Software Foundation) released successive versions of the Apache HTTP Server . Its initial license was essentially the same as the original 4-clause BSD license , with only the names of the organizations changed, and with an additional clause forbidding derivative works from bearing
989-593: The Apache name. In July 1999, the Berkeley Software Distribution accepted the argument put to it by the Free Software Foundation and retired their advertising clause (clause 3) to form the new 3-clause BSD license. In 2000, Apache did likewise and created the Apache License 1.1, in which derived products are no longer required to include attribution in their advertising materials, only in their documentation. Individual packages licensed under
1032-508: The GCC frontends have been modified to work with it, resulting in the now-defunct LLVM-GCC suite. The modifications generally involve a GIMPLE -to-LLVM IR step so that LLVM optimizers and codegen can be used instead of GCC's GIMPLE system. Apple was a significant user of LLVM-GCC through Xcode 4.x (2013). This use of the GCC frontend was considered mostly a temporary measure, but with the advent of Clang and advantages of LLVM and Clang's modern and modular codebase (as well as compilation speed),
1075-585: The GPU with minimal changes. On systems with low-end GPUs, LLVM will compile optional procedures that run on the local central processing unit (CPU) that emulate instructions that the GPU cannot run internally. LLVM improved performance on low-end machines using Intel GMA chipsets. A similar system was developed under the Gallium3D LLVMpipe, and incorporated into the GNOME shell to allow it to run without
1118-639: The LLVM implementation of the C++ Standard Library (with full support of C++11 and C++14 ), etc. LLVM is administered by the LLVM Foundation. Compiler engineer Tanya Lattner became its president in 2014 and was in post as of March 2024. "For designing and implementing LLVM" , the Association for Computing Machinery presented Vikram Adve, Chris Lattner, and Evan Cheng with the 2012 ACM Software System Award . The project
1161-404: The LLVM project evolved into an umbrella project that has little relationship to what most current developers think of as a virtual machine . This made the initialism "confusing" and "inappropriate", and since 2011 LLVM is "officially no longer an acronym", but a brand that applies to the LLVM umbrella project. The project encompasses the LLVM intermediate representation (IR), the LLVM debugger ,
1204-426: The amount of storage required by types and variables can be deduced. Properties of a program that can be reasoned about at compile time include range-checks (e.g., proving that an array index will not exceed the array bounds), deadlock freedom in concurrent languages , or timings (e.g., proving that a sequence of code takes no more than an allocated amount of time). Compile-time occurs before link time (when
1247-594: The following compiler phases (which therefore occur at compile-time): syntax analysis , semantic analysis , and code generation . During optimization phases, constant expressions in the source code can also be evaluated at compile-time using compile-time execution , which reduces the constant expressions to a single value. This is not necessary for correctness, but improves program performance during runtime. Programming language definitions usually specify compile time requirements that source code must meet to be successfully compiled. For example, languages may stipulate that
1290-467: The human-readable IR format: The many different conventions used and features provided by different targets mean that LLVM cannot truly produce a target-independent IR and retarget it without breaking some established rules. Examples of target dependence beyond what is explicitly mentioned in the documentation can be found in a 2011 proposal for "wordcode", a fully target-independent variant of LLVM IR intended for online distribution. A more practical example
1333-448: The license on contributions, and requiring a patent license on contributions that necessarily infringe a contributor's own patents. This license requires the preservation of the copyright notice and disclaimer . The Apache License is permissive ; unlike copyleft licenses, it does not require a derivative work of the software, or modifications to the original, to be distributed using the same license. It still requires application of
LLVM - Misplaced Pages Continue
1376-625: The licensor regarding these contributions. The Apache License 2.0 attempts to forestall potential patent litigation in Section 3. The user is granted a patent license from each contributor to "make, have made, use, offer to sell, sell, import, and otherwise transfer the Work." Through an in terrorem clause, if the user sues anyone alleging that the software or a contribution within it constitutes patent infringement, any such patent licenses for that work are terminated. The Apache Software Foundation and
1419-469: The original work, then derivative works must include a readable copy of these notices within a NOTICE text file distributed as part of the derivative works, within the source form or documentation, or within a display generated by the derivative works (wherever such third-party notices normally appear). The contents of the NOTICE file do not modify the license, as they are for informational purposes only, and adding more attribution notices as addenda to
1462-414: The output of one or more compiled files are joined) and runtime (when a program is executed ). Although in the case of dynamic compilation , the final transformations into machine language happen at runtime. There is a trade-off between compile-time and link-time in that many compile time operations can be deferred to link-time without incurring run-time cost. This computer science article
1505-505: The previous GPL versions 1 and 2. Furthermore, it considers Apache License versions before 2.0 incompatible with GPLv3. Because of version 2.0's patent license requirements, the Free Software Foundation recommends it over other non-copyleft licenses. If the Apache License with the LLVM exception is used, then it is compatible with GPLv2. In October 2012, 8,708 projects located at SourceForge.net were available under
1548-402: The program that can be reasoned about during compilation. The actual length of time it takes to compile a program is usually referred to as compilation time . The determination of execution model have been set during the compile time stage. Run time- the method of execution and allocation - have been set during the run time and are based on the run time dynamicity. Most compilers have at least
1591-405: The same license to all unmodified parts. In every licensed file, original copyright, patent, trademark, and attribution notices must be preserved (excluding notices that do not pertain to any part of the derivative works). In every licensed file changed, a notification must be added stating that changes have been made to that file. If a NOTICE text file is included as part of the distribution of
1634-439: The target. For example, the calling convention is abstracted through call and ret instructions with explicit arguments. Also, instead of a fixed set of registers, IR uses an infinite set of temporaries of the form %0, %1, etc. LLVM supports three equivalent forms of IR: a human-readable assembly format, an in-memory format suitable for frontends, and a dense bitcode format for serializing. A simple "Hello, world!" program in
1677-551: The terms of the Apache License. In a blog post from May 2008, Google mentioned that over 25% of the nearly 100,000 projects then hosted on Google Code were using the Apache License, including the Android operating system . As of 2015 , according to Black Duck Software and GitHub , the Apache license is the third most popular license in the FOSS domain after MIT License and GPLv2 . The OpenBSD project does not consider
1720-487: The time window during which a language's statements are converted into binary instructions for the processor to execute. The term is used as an adjective to describe concepts related to the context of program compilation, as opposed to concepts related to the context of program execution ( runtime ). For example, compile-time requirements are programming language requirements that must be met by source code before compilation and compile-time properties are properties of
1763-623: The use of a linker plugin, but on the other hand prohibits interoperability with other flavors of LTO. The LLVM project includes an implementation of the C++ Standard Library named libc++, dual-licensed under the MIT License and the UIUC license . Since v9.0.0, it was relicensed to the Apache License 2.0 with LLVM Exceptions. This implements a suite of cache-locality optimizations as well as auto-parallelism and vectorization using
LLVM - Misplaced Pages Continue
1806-448: Was more efficient than the C code generator. The Glasgow Haskell Compiler (GHC) backend uses LLVM and achieves a 30% speed-up of compiled code relative to native code compiling via GHC or C code generation followed by compiling, missing only one of the many optimizing techniques implemented by the GHC. Many other components are in various stages of development, including, but not limited to,
1849-481: Was originally available under the UIUC license . After v9.0.0 released in 2019, LLVM relicensed to the Apache License 2.0 with LLVM Exceptions. As of November 2022 about 400 contributions had not been relicensed. LLVM can provide the middle layers of a complete compiler system, taking intermediate representation (IR) code from a compiler and emitting an optimized IR. This new IR can then be converted and linked into machine-dependent assembly language code for
#542457