Where Is LLVM Being Used Today?
Total Page:16
File Type:pdf, Size:1020Kb
Where is LLVM being used today? Tilmann Scheller Senior LLVM Compiler Engineer [email protected] Samsung Open Source Group Samsung Research UK FOSDEM 2016 Brussels, Belgium, January 30 – 31, 2016 Samsung Open Source Group 1 Overview ● Introduction ● LLVM Overview ● Projects ● Summary Samsung Open Source Group 2 Introduction Samsung Open Source Group 3 What is LLVM? ● Mature, production-quality compiler framework ● Modular architecture ● Heavily optimizing static and dynamic compiler ● Supports all major architectures (x86, ARM, MIPS, PowerPC, …) ● Powerful link-time optimizations (LTO) ● Permissive license (BSD-like) Samsung Open Source Group 4 Which companies are contributing? ® Samsung Open Source Group 5 History ● Started as Chris Lattner's Master's Thesis at UIUC ● LLVM 1.0 released in October 2003 ● LLVM 3.8 about to be released ● Today: LLVM + Clang together 2.5 million LOC of C++ code Samsung Open Source Group 6 LLVM sub-projects ● Clang C/C++/Objective C frontend and static analyzer ● LLDB Next generation debugger leveraging the LLVM libraries, e.g. the Clang expression parser ● lld Framework for creating linkers, will make Clang independent of the system linker in the future ● Polly Polyhedral optimizer for LLVM, e.g. high-level loop optimizations and data-locality optimizations Samsung Open Source Group 7 LLVM Overview Samsung Open Source Group 8 LLVM ● LLVM IR (Intermediate Representation) ● Scalar optimizations ● Interprocedural optimizations ● Auto-vectorizer (BB, Loop and SLP) ● Profile-guided optimizations Samsung Open Source Group 9 Compiler architecture C Frontend x86 Backend C++ Frontend Optimizer ARM Backend Fortran Frontend MIPS Backend Samsung Open Source Group 10 Compilation steps ● Many steps involved in the translation from C source code to machine code: – Frontend: ● Lexing, Parsing, AST construction ● Translation to LLVM IR – Middle-end ● Target-independent optimizations (Analyses & Transformations) – Backend: ● Translation into a DAG ● Instruction selection: Pattern matching on the DAG ● Instruction scheduling: Assigning an order of execution ● Register allocation: Trying to reduce memory traffic Samsung Open Source Group 11 Clang ● Goals: – Fast compile time – Low memory usage – GCC compatibility – Expressive diagnostics ● Several tools built on top of Clang: – Clang static analyzer – clang-format, clang-modernize, clang-tidy Samsung Open Source Group 12 Projects Samsung Open Source Group 13 Traditional C/C++ Toolchain ● Apple iOS/OS X SDK ● Android NDK ● Tizen SDK ● Sony PS4 SDK ● Qualcomm Snapdragon LLVM Compiler for Android Samsung Open Source Group 14 Programming languages ● Swift ● Haskell: GHC, LHC, UHC ● Ruby: Rubinius, RubyMotion ● Python: Pyston ● Common Lisp: Clasp ● D: LDC ● Go: llgo Samsung Open Source Group 15 Programming languages ● Standard ML: MLton, SML#, Ex-SML ● Rust ● Julia ● Pure ● Ravi Samsung Open Source Group 16 Language Runtime Systems ● VMKit (unmaintained) ● LLILC - LLVM-based .NET MSIL compiler ● Mono ● OpenJDK Samsung Open Source Group 17 GPU ● LLVMpipe (software rasterizer) ● CUDA ● GLSL (LunarGLASS) ● AMDGPU open source drivers ● SPIR ● Majority of OpenCL implementations based on Clang/LLVM Samsung Open Source Group 18 Web ● PNaCl ● WebKit FTL JIT ● Emscripten ● WebAssembly Samsung Open Source Group 19 Sanitizers ● AddressSanitizers ● MemorySanitizer ● ThreadSanitizer ● LeakSanitizer ● SAFECode Samsung Open Source Group 20 Integrated Development Environments ● Xcode ● KDevelop ● CodeLite ● Qt Creator ● Geany Samsung Open Source Group 21 Source code navigation ● Doxygen ● Woboq Code Browser ● YouCompleteMe - Code completion for Vim ● clang-tags ● clang-ctags ● clang_complete - Code completion for Vim ● rtags - Indexer for C/C++ with Emacs integration Samsung Open Source Group 22 Out of tree LLVM backends ● RISC-V ● OpenRISC 1000 ● VideoCore IV (VPU/QPU) ● LatticeMico32 ● AAP Samsung Open Source Group 23 Binary translation ● llvm-qemu ● Dagger ● McSema ● libcpu ● Fracture ● SkyEye Samsung Open Source Group 24 Symbolic Execution/Formal Verification ● KLEE ● S2E ● K framework with formal semantics for LLVM IR Samsung Open Source Group 25 Linux/FreeBSD ● Debian experimenting with Clang as an additional compiler (94.1% of ~22k packages successfully build with Clang 3.6) ● LLVMLinux ● OpenMandriva Lx ● FreeBSD Samsung Open Source Group 26 Misc ● Emacs fork using the LLVM JIT for Elisp byte code execution :) ● Cling - C++ interpreter ● CodeChecker - Web frontend for the Clang static analyzer ● include-what-you-use ● clang-closure ● Numba Samsung Open Source Group 27 Summary Samsung Open Source Group 28 Summary ● Wide range of different projects ● New frontends being written constantly ● Great compiler infrastructure ● Fast C/C++ compiler with expressive diagnostics Samsung Open Source Group 29 Give it a try! ● Visit llvm.org ● Distributions with Clang/LLVM packages: – Fedora – Debian/Ubuntu – openSUSE – Arch Linux – ...and many more Samsung Open Source Group 30 Thank you. Samsung Open Source Group 31 Contact Information: Tilmann Scheller [email protected] Samsung Open Source Group Samsung Research UK Samsung Open Source Group 32.