LLVM
Original author(s) | Chris Lattner, Vikram Adve |
---|---|
Developer(s) | LLVM Developer Group |
Initial release | 2003 |
Stable release | 18.1.4[2]
/ 16 April 2024 |
Repository | |
Written in | Apache License 2.0 with LLVM Exceptions (v9.0.0 or later)[3] |
Website | www |
LLVM is a set of
LLVM is written in
History
The LLVM project started in 2000 at the
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
"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.[25]
The project was originally available under the
Features
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 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.[29]
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
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 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.[30]
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
In 2011, programs compiled by GCC outperformed those from LLVM by 10%, on average.[32][33] In 2013, phoronix reported that LLVM had caught up with GCC, compiling binaries of approximately equal performance.[34]
Components
LLVM has become an umbrella project containing multiple components.
Frontends
LLVM was originally written to be a replacement for the extant
LLVM currently[as of?] 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 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.[38]
The Utrecht Haskell compiler can generate code for LLVM. While the generator was in early stages of development, in many cases it was more efficient than the C code generator.[39] 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.[40]
Many other components are in various stages of development, including, but not limited to, 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.[citation needed]
Intermediate representation
The core of LLVM is the
@.str = internal constant [14 x i8] c"Hello, world\0A\00"
declare i32 @printf(ptr, ...)
define i32 @main(i32 %argc, ptr %argv) nounwind {
entry:
%tmp1 = getelementptr [14 x i8], ptr @.str, i32 0, i32 0
%tmp2 = call i32 (ptr, ...) @printf( ptr %tmp1 ) nounwind
ret i32 0
}
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.
The LLVM project also introduces another type of intermediate representation named MLIR[44] which helps build reusable and extensible compiler infrastructure by employing a plugin architecture named Dialect.[45] It enables the use of higher-level information on the program structure in the process of optimization including polyhedral compilation.
Backends
At version 16, LLVM supports many
Some features are not available on some platforms. Most features are present for IA-32, x86-64, z/Architecture, ARM, and PowerPC.[48] RISC-V is supported as of version 7.
In the past, LLVM also supported other backends, fully or partially, including C backend,
LLVM also supports
The LLVM machine code (MC) subproject 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 is usable but still in the beta stage.[citation needed]
Linker
The lld subproject is an attempt to develop a built-in, platform-independent
Unlike the GNU linkers, lld has built-in support for
C++ Standard Library
The LLVM project includes an implementation of the
Since v9.0.0, it was relicensed to the
Polly
This implements a suite of cache-locality optimizations as well as auto-parallelism and vectorization using a polyhedral model.[56]
Debugger
C Standard Library
llvm-libc is an incomplete, upcoming, ABI independent C standard library designed by and for the LLVM project.[57]
Derivatives
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.[58] Some of the vendors include:
- AMD's AMD Optimizing C/C++ Compiler is based on LLVM, Clang, and Flang.
- Apple maintains an open-source fork for Xcode.[59]
- Armprovides a number of LLVM based toolchains, including Arm Compiler for Embedded targeting bare-metal development and Arm Compiler for Linux targeting the High Performance Computing market
- Flang, Fortran project in development as of 2022[update]
- IBM is adopting LLVM in its C/C++ and Fortran compilers.[60]
- Intel has adopted LLVM for their next generation Intel C++ Compiler.[61]
- The Los Alamos National Laboratory has a parallel-computing fork of LLVM 8 named "Kitsune".[62]
- Nvidia uses LLVM in the implementation of its NVVM CUDA Compiler.[63] The NVVM compiler is distinct from the "NVPTX" backend mentioned in the Backends section, although both generate PTX code for Nvidia GPUs.
- Since 2013, Sony has been using LLVM's primary front-end Clang compiler in the software development kit (SDK) of its PlayStation 4 console.[64]
See also
- Common Intermediate Language
- HHVM
- C--
- Amsterdam Compiler Kit (ACK)
- Optimizing compiler
- LLDB (debugger)
- GNU lightning
- GNU Compiler Collection (GCC)
- Pure
- OpenCL
- ROCm
- Emscripten
- TenDRA Distribution Format
- Architecture Neutral Distribution Format (ANDF)
- Comparison of application virtualization software
- SPIR-V
- University of Illinois at Urbana Champaign discoveries & innovations
Literature
- Open Access).[65]
- LLVM: A Compilation Framework for Lifelong Program Analysis & Transformation, a published paper by Chris Lattner, Vikram Adve
References
- ^ "LLVM Logo". The LLVM Compiler Infrastructure Project.
- ^ "LLVM 18.1.4". April 16, 2024. Retrieved April 16, 2024.
- ^ a b c d "LICENSE.TXT". llvm.org. Retrieved September 24, 2019.
- ^ "The LLVM Compiler Infrastructure Project". Retrieved March 11, 2016.
- ^ a b "LLVM Language Reference Manual". Retrieved June 9, 2019.
- ^ "Announcing LLILC - A new LLVM-based Compiler for .NET". dotnetfoundation.org. Archived from the original on December 12, 2021. Retrieved September 12, 2020.
- ^ "Mono LLVM". Retrieved March 10, 2013.
- ^ Lattner, Chris (2011). "LLVM". In Brown, Amy; Wilson, Greg (eds.). The Architecture of Open Source Applications.
- ^ "MovForth". GitHub. November 28, 2021.
- ^ William Wong (May 23, 2017). "What's the Difference Between LabVIEW 2017 and LabVIEW NXG?". Electronic Design.
- ^ "NI LabVIEW Compiler: Under the Hood".
- ^ Larabel, Michael (April 11, 2018). "Khronos Officially Announces Its LLVM/SPIR-V Translator". Phoronix.com.
- ^ "32.1. What is JIT compilation?". PostgreSQL Documentation. November 12, 2020. Retrieved January 25, 2021.
- ^ "Features". RubyMotion. Scratchwork Development LLC. Retrieved June 17, 2017.
RubyMotion transforms the Ruby source code of your project into ... machine code using a[n] ... ahead-of-time (AOT) compiler, based on LLVM.
- ^ "Code Generation - Guide to Rustc Development". rust-lang.org. Retrieved January 4, 2023.
- ^ Reedy, Geoff (September 24, 2012). "Compiling Scala to LLVM". St. Louis, Missouri, United States. Retrieved February 19, 2013.
- ^ "Scala Native". Retrieved November 26, 2023.
- ^ Adam Treat (February 19, 2005), mkspecs and patches for LLVM compile of Qt4, archived from the original on October 4, 2011, retrieved January 27, 2012
- ^ "Developer Tools Overview". Apple Developer. Apple. Archived from the original on April 23, 2011.
- ^ Lattner, Chris (December 21, 2011). "The name of LLVM". llvm-dev (Mailing list). Retrieved March 2, 2016.
'LLVM' is officially no longer an acronym. The acronym it once expanded too was confusing, and inappropriate almost from day 1. :) As LLVM has grown to encompass other subprojects, it became even less useful and meaningless.
- ISBN 978-1257638017.
The name 'LLVM' was once an acronym, but is now just a brand for the umbrella project.
- ^ ""libc++" C++ Standard Library".
- ^ Lattner, Chris (April 3, 2014). "The LLVM Foundation". LLVM Project Blog.
- ^ "Board of Directors". LLVM Foundation. Retrieved March 19, 2024.
- ^ "ACM Software System Award". ACM.
- ^ Wennborg, Hans (September 19, 2019). "[llvm-announce] LLVM 9.0.0 Release".
- ^ "Relicensing Long Tail". foundation.llvm.org. November 11, 2022.
- ^ "LLVM relicensing - long tail". LLVM Project. Retrieved November 27, 2022 – via Google Docs.
- ^ "⚙ D156286 [docs] Bump minimum GCC version to 7.5". reviews.llvm.org. Retrieved July 28, 2023.
- ^ Lattner, Chris (August 15, 2006). "A cool use of LLVM at Apple: the OpenGL stack". llvm-dev (Mailing list). Retrieved March 1, 2016.
- ^ Michael Larabel, "GNOME Shell Works Without GPU Driver Support", phoronix, November 6, 2011
- ^ Makarov, V. "SPEC2000: Comparison of LLVM-2.9 and GCC4.6.1 on x86". Retrieved October 3, 2011.
- ^ Makarov, V. "SPEC2000: Comparison of LLVM-2.9 and GCC4.6.1 on x86_64". Retrieved October 3, 2011.
- ^ Larabel, Michael (December 27, 2012). "LLVM/Clang 3.2 Compiler Competing With GCC". Retrieved March 31, 2013.
- ^ Lattner, Chris; Adve, Vikram (May 2003). Architecture For a Next-Generation GCC. First Annual GCC Developers' Summit. Retrieved September 6, 2009.
- ^ "LLVM Compiler Overview". developer.apple.com.
- ^ "Xcode 5 Release Notes". Apple Inc.
- ^ "Clang 3.8 Release Notes". Retrieved August 24, 2016.
- ^ "Compiling Haskell To LLVM". Retrieved February 22, 2009.
- ^ "LLVM Project Blog: The Glasgow Haskell Compiler and LLVM". May 17, 2010. Retrieved August 13, 2010.
- ^ "LLVM Language Reference Manual". LLVM.org. January 10, 2023.
- ^ Kang, Jin-Gu. "Wordcode: more target independent LLVM bitcode" (PDF). Retrieved December 1, 2019.
- ^ "PNaCl: Portable Native Client Executables" (PDF). Archived from the original (PDF) on 2 May 2012. Retrieved 25 April 2012.
- ^ "MLIR". mlir.llvm.org. Retrieved June 7, 2022.
- ^ "Dialects - MLIR". mlir.llvm.org. Retrieved June 7, 2022.
- ^ Stellard, Tom (March 26, 2012). "[LLVMdev] RFC: R600, a new backend for AMD GPUs". llvm-dev (Mailing list).
- ^ "User Guide for AMDGPU Backend — LLVM 15.0.0git documentation".
- ^ Target-specific Implementation Notes: Target Feature Matrix // The LLVM Target-Independent Code Generator, LLVM site.
- ^ "Remove the mblaze backend from llvm". GitHub. July 25, 2013. Retrieved January 26, 2020.
- ^ "Remove the Alpha backend". GitHub. October 27, 2011. Retrieved January 26, 2020.
- ^ "[Nios2] Remove Nios2 backend". GitHub. January 15, 2019. Retrieved January 26, 2020.
- ^ "lld - The LLVM Linker". The LLVM Project. Retrieved May 10, 2017.
- ^ "WebAssembly lld port".
- ^ "42446 – lld can't handle gcc LTO files". bugs.llvm.org.
- ^ ""libc++" C++ Standard Library".
- ^ "Polly - Polyhedral optimizations for LLVM".
- ^ "llvm-libc: An ISO C-conformant Standard Library — libc 15.0.0git documentation". libc.llvm.org. Retrieved July 18, 2022.
- ^ "Clang Language Extensions". Clang 12 documentation.
Note that marketing version numbers should not be used to check for language features, as different vendors use different numbering schemes. Instead, use the Feature Checking Macros.
- ^ "apple/llvm-project". Apple. September 5, 2020.
- ^ "IBM C/C++ and Fortran compilers to adopt LLVM open source infrastructure".
- ^ "Intel C/C++ compilers complete adoption of LLVM". Intel. Retrieved August 17, 2021.
- ^ "lanl/kitsune". Los Alamos National Laboratory. February 27, 2020.
- ^ "NVVM IR Specification 1.5".
The current NVVM IR is based on LLVM 5.0
- ^ Developer Toolchain for ps4 (PDF), retrieved February 24, 2015
- ISBN 978-1257638017.
External links