1Samsung Open Source Group
Where is LLVM being used today?
Tilmann Scheller
Senior LLVM Compiler Engineer
t.scheller@samsung.com
Samsung Open Source Group
Samsung Research UK
FOSDEM 2016
Brussels, Belgium, January 30 – 31, 2016
2Samsung Open Source Group
Overview
● Introduction
● LLVM Overview
● Projects
● Summary
3Samsung Open Source Group
Introduction
4Samsung Open Source Group
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)
5Samsung Open Source Group
Which companies are contributing?
®
6Samsung Open Source Group
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
7Samsung Open Source Group
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
8Samsung Open Source Group
LLVM Overview
9Samsung Open Source Group
LLVM
● LLVM IR (Intermediate Representation)
● Scalar optimizations
● Interprocedural optimizations
● Auto-vectorizer (BB, Loop and SLP)
● Profile-guided optimizations
10Samsung Open Source Group
Compiler architecture
C Frontend
C++ Frontend
Fortran Frontend
Optimizer
x86 Backend
ARM Backend
MIPS Backend
11Samsung Open Source Group
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
12Samsung Open Source Group
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
13Samsung Open Source Group
Projects
14Samsung Open Source Group
Traditional C/C++ Toolchain
● Apple iOS/OS X SDK
● Android NDK
● Tizen SDK
● Sony PS4 SDK
● Qualcomm Snapdragon LLVM Compiler for Android
15Samsung Open Source Group
Programming languages
● Swift
● Haskell: GHC, LHC, UHC
● Ruby: Rubinius, RubyMotion
● Python: Pyston
● Common Lisp: Clasp
● D: LDC
● Go: llgo
16Samsung Open Source Group
Programming languages
● Standard ML: MLton, SML#, Ex-SML
● Rust
● Julia
● Pure
● Ravi
17Samsung Open Source Group
Language Runtime Systems
● VMKit (unmaintained)
● LLILC - LLVM-based .NET MSIL compiler
● Mono
● OpenJDK
18Samsung Open Source Group
GPU
● LLVMpipe (software rasterizer)
● CUDA
● GLSL (LunarGLASS)
● AMDGPU open source drivers
● SPIR
● Majority of OpenCL implementations based on
Clang/LLVM
19Samsung Open Source Group
Web
● PNaCl
● WebKit FTL JIT
● Emscripten
● WebAssembly
20Samsung Open Source Group
Sanitizers
● AddressSanitizers
● MemorySanitizer
● ThreadSanitizer
● LeakSanitizer
● SAFECode
21Samsung Open Source Group
Integrated Development Environments
● Xcode
● KDevelop
● CodeLite
● Qt Creator
● Geany
22Samsung Open Source Group
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
23Samsung Open Source Group
Out of tree LLVM backends
● RISC-V
● OpenRISC 1000
● VideoCore IV (VPU/QPU)
● LatticeMico32
● AAP
24Samsung Open Source Group
Binary translation
● llvm-qemu
● Dagger
● McSema
● libcpu
● Fracture
● SkyEye
25Samsung Open Source Group
Symbolic Execution/Formal Verification
● KLEE
● S2E
● K framework with formal semantics for LLVM IR
26Samsung Open Source Group
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
27Samsung Open Source Group
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
28Samsung Open Source Group
Summary
29Samsung Open Source Group
Summary
● Wide range of different projects
● New frontends being written constantly
● Great compiler infrastructure
● Fast C/C++ compiler with expressive diagnostics
30Samsung Open Source Group
Give it a try!
● Visit llvm.org
● Distributions with Clang/LLVM packages:
– Fedora
– Debian/Ubuntu
– openSUSE
– Arch Linux
– ...and many more
Thank you.
31Samsung Open Source Group
32Samsung Open Source Group
Contact Information:
Tilmann Scheller
t.scheller@samsung.com
Samsung Open Source Group
Samsung Research UK

Where is LLVM Being Used Today?

  • 1.
    1Samsung Open SourceGroup Where is LLVM being used today? Tilmann Scheller Senior LLVM Compiler Engineer t.scheller@samsung.com Samsung Open Source Group Samsung Research UK FOSDEM 2016 Brussels, Belgium, January 30 – 31, 2016
  • 2.
    2Samsung Open SourceGroup Overview ● Introduction ● LLVM Overview ● Projects ● Summary
  • 3.
    3Samsung Open SourceGroup Introduction
  • 4.
    4Samsung Open SourceGroup 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)
  • 5.
    5Samsung Open SourceGroup Which companies are contributing? ®
  • 6.
    6Samsung Open SourceGroup 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
  • 7.
    7Samsung Open SourceGroup 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
  • 8.
    8Samsung Open SourceGroup LLVM Overview
  • 9.
    9Samsung Open SourceGroup LLVM ● LLVM IR (Intermediate Representation) ● Scalar optimizations ● Interprocedural optimizations ● Auto-vectorizer (BB, Loop and SLP) ● Profile-guided optimizations
  • 10.
    10Samsung Open SourceGroup Compiler architecture C Frontend C++ Frontend Fortran Frontend Optimizer x86 Backend ARM Backend MIPS Backend
  • 11.
    11Samsung Open SourceGroup 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
  • 12.
    12Samsung Open SourceGroup 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
  • 13.
    13Samsung Open SourceGroup Projects
  • 14.
    14Samsung Open SourceGroup Traditional C/C++ Toolchain ● Apple iOS/OS X SDK ● Android NDK ● Tizen SDK ● Sony PS4 SDK ● Qualcomm Snapdragon LLVM Compiler for Android
  • 15.
    15Samsung Open SourceGroup Programming languages ● Swift ● Haskell: GHC, LHC, UHC ● Ruby: Rubinius, RubyMotion ● Python: Pyston ● Common Lisp: Clasp ● D: LDC ● Go: llgo
  • 16.
    16Samsung Open SourceGroup Programming languages ● Standard ML: MLton, SML#, Ex-SML ● Rust ● Julia ● Pure ● Ravi
  • 17.
    17Samsung Open SourceGroup Language Runtime Systems ● VMKit (unmaintained) ● LLILC - LLVM-based .NET MSIL compiler ● Mono ● OpenJDK
  • 18.
    18Samsung Open SourceGroup GPU ● LLVMpipe (software rasterizer) ● CUDA ● GLSL (LunarGLASS) ● AMDGPU open source drivers ● SPIR ● Majority of OpenCL implementations based on Clang/LLVM
  • 19.
    19Samsung Open SourceGroup Web ● PNaCl ● WebKit FTL JIT ● Emscripten ● WebAssembly
  • 20.
    20Samsung Open SourceGroup Sanitizers ● AddressSanitizers ● MemorySanitizer ● ThreadSanitizer ● LeakSanitizer ● SAFECode
  • 21.
    21Samsung Open SourceGroup Integrated Development Environments ● Xcode ● KDevelop ● CodeLite ● Qt Creator ● Geany
  • 22.
    22Samsung Open SourceGroup 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
  • 23.
    23Samsung Open SourceGroup Out of tree LLVM backends ● RISC-V ● OpenRISC 1000 ● VideoCore IV (VPU/QPU) ● LatticeMico32 ● AAP
  • 24.
    24Samsung Open SourceGroup Binary translation ● llvm-qemu ● Dagger ● McSema ● libcpu ● Fracture ● SkyEye
  • 25.
    25Samsung Open SourceGroup Symbolic Execution/Formal Verification ● KLEE ● S2E ● K framework with formal semantics for LLVM IR
  • 26.
    26Samsung Open SourceGroup 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
  • 27.
    27Samsung Open SourceGroup 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
  • 28.
    28Samsung Open SourceGroup Summary
  • 29.
    29Samsung Open SourceGroup Summary ● Wide range of different projects ● New frontends being written constantly ● Great compiler infrastructure ● Fast C/C++ compiler with expressive diagnostics
  • 30.
    30Samsung Open SourceGroup Give it a try! ● Visit llvm.org ● Distributions with Clang/LLVM packages: – Fedora – Debian/Ubuntu – openSUSE – Arch Linux – ...and many more
  • 31.
  • 32.
    32Samsung Open SourceGroup Contact Information: Tilmann Scheller t.scheller@samsung.com Samsung Open Source Group Samsung Research UK