32
1 Samsung Open Source Group 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

Where is LLVM Being Used Today?

Embed Size (px)

Citation preview

Page 1: Where is LLVM Being Used Today?

1Samsung Open Source Group

Where is LLVM being used today?

Tilmann SchellerSenior LLVM Compiler Engineer

[email protected]

Samsung Open Source GroupSamsung Research UK

FOSDEM 2016Brussels, Belgium, January 30 – 31, 2016

Page 2: Where is LLVM Being Used Today?

2Samsung Open Source Group

Overview

● Introduction

● LLVM Overview

● Projects

● Summary

Page 3: Where is LLVM Being Used Today?

3Samsung Open Source Group

Introduction

Page 4: Where is LLVM Being Used Today?

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)

Page 5: Where is LLVM Being Used Today?

5Samsung Open Source Group

Which companies are contributing?

®

Page 6: Where is LLVM Being Used Today?

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

Page 7: Where is LLVM Being Used Today?

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

Page 8: Where is LLVM Being Used Today?

8Samsung Open Source Group

LLVM Overview

Page 9: Where is LLVM Being Used Today?

9Samsung Open Source Group

LLVM

● LLVM IR (Intermediate Representation)

● Scalar optimizations

● Interprocedural optimizations

● Auto-vectorizer (BB, Loop and SLP)

● Profile-guided optimizations

Page 10: Where is LLVM Being Used Today?

10Samsung Open Source Group

Compiler architecture

C Frontend

C++ Frontend

Fortran Frontend

Optimizer

x86 Backend

ARM Backend

MIPS Backend

Page 11: Where is LLVM Being Used Today?

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

Page 12: Where is LLVM Being Used Today?

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

Page 13: Where is LLVM Being Used Today?

13Samsung Open Source Group

Projects

Page 14: Where is LLVM Being Used Today?

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

Page 15: Where is LLVM Being Used Today?

15Samsung Open Source Group

Programming languages

● Swift

● Haskell: GHC, LHC, UHC

● Ruby: Rubinius, RubyMotion

● Python: Pyston

● Common Lisp: Clasp

● D: LDC

● Go: llgo

Page 16: Where is LLVM Being Used Today?

16Samsung Open Source Group

Programming languages

● Standard ML: MLton, SML#, Ex-SML

● Rust

● Julia

● Pure

● Ravi

Page 17: Where is LLVM Being Used Today?

17Samsung Open Source Group

Language Runtime Systems

● VMKit (unmaintained)

● LLILC - LLVM-based .NET MSIL compiler

● Mono

● OpenJDK

Page 18: Where is LLVM Being Used Today?

18Samsung Open Source Group

GPU

● LLVMpipe (software rasterizer)

● CUDA

● GLSL (LunarGLASS)

● AMDGPU open source drivers

● SPIR

● Majority of OpenCL implementations based on

Clang/LLVM

Page 19: Where is LLVM Being Used Today?

19Samsung Open Source Group

Web

● PNaCl

● WebKit FTL JIT

● Emscripten

● WebAssembly

Page 20: Where is LLVM Being Used Today?

20Samsung Open Source Group

Sanitizers

● AddressSanitizers

● MemorySanitizer

● ThreadSanitizer

● LeakSanitizer

● SAFECode

Page 21: Where is LLVM Being Used Today?

21Samsung Open Source Group

Integrated Development Environments

● Xcode

● KDevelop

● CodeLite

● Qt Creator

● Geany

Page 22: Where is LLVM Being Used Today?

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

Page 23: Where is LLVM Being Used Today?

23Samsung Open Source Group

Out of tree LLVM backends

● RISC-V

● OpenRISC 1000

● VideoCore IV (VPU/QPU)

● LatticeMico32

● AAP

Page 24: Where is LLVM Being Used Today?

24Samsung Open Source Group

Binary translation

● llvm-qemu

● Dagger

● McSema

● libcpu

● Fracture

● SkyEye

Page 25: Where is LLVM Being Used Today?

25Samsung Open Source Group

Symbolic Execution/Formal Verification

● KLEE

● S2E

● K framework with formal semantics for LLVM IR

Page 26: Where is LLVM Being Used Today?

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

Page 27: Where is LLVM Being Used Today?

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

Page 28: Where is LLVM Being Used Today?

28Samsung Open Source Group

Summary

Page 29: Where is LLVM Being Used Today?

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

Page 30: Where is LLVM Being Used Today?

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

Page 31: Where is LLVM Being Used Today?

Thank you.

31Samsung Open Source Group

Page 32: Where is LLVM Being Used Today?

32Samsung Open Source Group

Contact Information:

Tilmann [email protected]

Samsung Open Source GroupSamsung Research UK