SlideShare a Scribd company logo
LLVM
Michel Guillet
michel.guillet@gmail.com
@guilletmichel
1
What is LLVM ?
• LLVM stood for: Low Level Virtual Machine
• “The LLVM Project is a collection of modular and
reusable compiler and toolchain technologies” —
llvm.org
• LLVM Core: backend, assembly code generator for
10+ CPUs (60+ for GCC)
• LLDB: debugger
• Clang: C/C++/Objective-C frontend + static analyser
2
History
• March 22, 1987: GGC 0.9 — First beta version
• Circa 2000: LLVM Project started
• Circa 2005: C. Lattner hired by Apple
• July 18, 2007: GGC 4.2.1 — Last GPLv2 version
• Crica 2010: C. Lattner began working on Swift
• October 12, 2011: Xcode 4.1 — LLVM only
3
Why GCC became an
issue ?
• GPLv3: Apple would have been forced to open
Xcode and other build tool related to GCC
• Not modular: Poor integration into the IDE
• 7+ MLOC: Too big, too old
• Objective-C: Not a priority for GCC team, slow
improvements
4
But what is “compilation” ?
• Compilation: transformation of a source code into
another source code (of a lesser abstraction)
• Example: C into x86 assembly or Ada into PowerPC
assembly
• Transpilation: compilation into a langage of similar
abstraction
• Example: CoffeeScript into Javascript or LESS into CSS
5
You !
Front end (Clang)
Back end (LLVM)
But what is “compilation” ?
CPU (x86, ARM)
1) Algorithm
2) Implementation (C, Java)
3) IR (GIMPLE, LLVM IR)
4) Assembly (x86-64, PPC, ARM)
5) Microcode
6
– 2
bar 3
=
int foo +
4 x
Front End
1. Lexical analysis
2. Syntax analysis
3. Semantic analysis
int foo = 4 + 2 * ( bar - 3 )
int foo = 4 + 2 * ( bar - 3 )
do we know “int” ?
does “foo” already exist ?
do we know “x” ?
is this an int ?
do we know “bar” as this stage ?
is this an int ?7
– 2
bar 3
=
int foo +
4 x
Front End
4. Optimization
5. IR generation
int foo = 4 + 2 * ( bar - 3 )
bar 2
=
int foo -
x 2
%tmp = mul i32 %bar, 2
%foo1 = sub i32 %tmp, 2
8
11110010 11100101 11101011
11010000 11000100 11000110
00110000 00100000 01101111
00111100 00111100 00100000
Back End
• Optimization
• Assembly generation
%tmp = mul i32 %bar, 2
%foo1 = sub i32 %tmp, 2
%0 = add i32 %bar, %bar
%foo1 = sub i32 %0, 2
9
This is not new !
• GCC has a similar design…
• … but it’s not modular
• You cannot hack you way in
• LLVM was built modularly from the beginning
Why Modularity is a big deal
• No need to deal with CPU specificities
• Creating a new language is easier (reduce skill
set)
• Adding new CPU support is easier (do it one time)
• Creating tools around languages is easier (Clang
Static Analyzer, Refactoring)
Webkit FTL
https://www.webkit.org/blog/3362/introducing-the-webkit-ftl-jit/
Q&A
13
Thanks!
14

More Related Content

PDF
CocoaHeads Rennes #13 : CocoaPods
PDF
CocoaConf DC - Automate with Swift - Tony Ingraldi
PDF
Launch Arguments & NSUserDefaults by Franck Lefebvre
PDF
How to build a tool for operating Flink on Kubernetes
PPTX
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
PPTX
Deploy Node.js application in Heroku using Eclipse
PPTX
NDK Introduction
PDF
Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...
CocoaHeads Rennes #13 : CocoaPods
CocoaConf DC - Automate with Swift - Tony Ingraldi
Launch Arguments & NSUserDefaults by Franck Lefebvre
How to build a tool for operating Flink on Kubernetes
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Deploy Node.js application in Heroku using Eclipse
NDK Introduction
Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...

What's hot (19)

PPT
Native Android for Windows Developers
PPTX
PDF
Android NDK and the x86 Platform
PDF
Dependent things dependency management for apple sw - slideshare
PDF
Acceptance testing plone sites and add ons with robot framework and selenium
PDF
CI/CD Using Ansible and Jenkins for Infrastructure
PPTX
Road to sbt 1.0: Paved with server (2015 Amsterdam)
PPTX
AspectJ Android with Example
PDF
Functional Programming in JavaScript
PDF
Raspberry and Pharo
PPTX
Kotlin Multiplatfom In Action
PDF
Get that Corner Office with Angular 2 and Electron
PDF
Kotlin Multiplatfom In Action
PDF
Automate Yo' Self
PDF
[HKOSCON][20200613][ Ansible: From VM to Kubernetes]
PDF
2021.laravelconf.tw.slides1
PDF
Queick: A Simple Job Queue System for Python
PDF
Low Level Exploits
PDF
java8-patterns
Native Android for Windows Developers
Android NDK and the x86 Platform
Dependent things dependency management for apple sw - slideshare
Acceptance testing plone sites and add ons with robot framework and selenium
CI/CD Using Ansible and Jenkins for Infrastructure
Road to sbt 1.0: Paved with server (2015 Amsterdam)
AspectJ Android with Example
Functional Programming in JavaScript
Raspberry and Pharo
Kotlin Multiplatfom In Action
Get that Corner Office with Angular 2 and Electron
Kotlin Multiplatfom In Action
Automate Yo' Self
[HKOSCON][20200613][ Ansible: From VM to Kubernetes]
2021.laravelconf.tw.slides1
Queick: A Simple Job Queue System for Python
Low Level Exploits
java8-patterns
Ad

Similar to LLVM Internal Architecture par Michel Guillet (20)

PPT
PPTX
LLVM Compiler
PDF
不深不淺,帶你認識 LLVM (Found LLVM in your life)
PDF
Os Lattner
PDF
Part II: LLVM Intermediate Representation
PDF
Virtual CPU
PDF
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
PPT
A Life of breakpoint
PDF
Introduction to the LLVM Compiler System
PDF
Virtual Machines Lecture
PDF
Developments in LLVM-based toolchains and tooling for RISC-V
PPTX
07 140430-ipp-languages used in llvm during compilation
PDF
Smalltalk JIT Compilation: LLVM Experimentation
PDF
Swift 2 Under the Hood - Gotober 2015
PDF
LCU14 209- LLVM Linux
PDF
Haskell Symposium 2010: An LLVM backend for GHC
PDF
MacRuby
PDF
Handling inline assembly in Clang and LLVM
PDF
BUD17-302: LLVM Internals #2
PDF
Clang: More than just a C/C++ Compiler
LLVM Compiler
不深不淺,帶你認識 LLVM (Found LLVM in your life)
Os Lattner
Part II: LLVM Intermediate Representation
Virtual CPU
차세대컴파일러, VM의미래: 애플 오픈소스 LLVM
A Life of breakpoint
Introduction to the LLVM Compiler System
Virtual Machines Lecture
Developments in LLVM-based toolchains and tooling for RISC-V
07 140430-ipp-languages used in llvm during compilation
Smalltalk JIT Compilation: LLVM Experimentation
Swift 2 Under the Hood - Gotober 2015
LCU14 209- LLVM Linux
Haskell Symposium 2010: An LLVM backend for GHC
MacRuby
Handling inline assembly in Clang and LLVM
BUD17-302: LLVM Internals #2
Clang: More than just a C/C++ Compiler
Ad

More from CocoaHeads France (20)

PDF
Mutation testing for a safer Future
PDF
iOS App Group for Debugging
PDF
Asynchronous swift
PDF
Visual accessibility in iOS11
PDF
My script - One year of CocoaHeads
PDF
Ui testing dealing with push notifications
PDF
CONTINUOUS DELIVERY WITH FASTLANE
PDF
L'intégration continue avec Bitrise
PDF
Super combinators
PDF
Design like a developer
PDF
Handle the error
PDF
Quoi de neuf dans iOS 10.3
PDF
IoT Best practices
PDF
SwiftyGPIO
PDF
Présentation de HomeKit
PDF
Programme MFI retour d'expérience
PDF
How to communicate with Smart things?
PDF
Build a lego app with CocoaPods
PDF
Let's migrate to Swift 3.0
PDF
Project Entourage
Mutation testing for a safer Future
iOS App Group for Debugging
Asynchronous swift
Visual accessibility in iOS11
My script - One year of CocoaHeads
Ui testing dealing with push notifications
CONTINUOUS DELIVERY WITH FASTLANE
L'intégration continue avec Bitrise
Super combinators
Design like a developer
Handle the error
Quoi de neuf dans iOS 10.3
IoT Best practices
SwiftyGPIO
Présentation de HomeKit
Programme MFI retour d'expérience
How to communicate with Smart things?
Build a lego app with CocoaPods
Let's migrate to Swift 3.0
Project Entourage

LLVM Internal Architecture par Michel Guillet

  • 2. What is LLVM ? • LLVM stood for: Low Level Virtual Machine • “The LLVM Project is a collection of modular and reusable compiler and toolchain technologies” — llvm.org • LLVM Core: backend, assembly code generator for 10+ CPUs (60+ for GCC) • LLDB: debugger • Clang: C/C++/Objective-C frontend + static analyser 2
  • 3. History • March 22, 1987: GGC 0.9 — First beta version • Circa 2000: LLVM Project started • Circa 2005: C. Lattner hired by Apple • July 18, 2007: GGC 4.2.1 — Last GPLv2 version • Crica 2010: C. Lattner began working on Swift • October 12, 2011: Xcode 4.1 — LLVM only 3
  • 4. Why GCC became an issue ? • GPLv3: Apple would have been forced to open Xcode and other build tool related to GCC • Not modular: Poor integration into the IDE • 7+ MLOC: Too big, too old • Objective-C: Not a priority for GCC team, slow improvements 4
  • 5. But what is “compilation” ? • Compilation: transformation of a source code into another source code (of a lesser abstraction) • Example: C into x86 assembly or Ada into PowerPC assembly • Transpilation: compilation into a langage of similar abstraction • Example: CoffeeScript into Javascript or LESS into CSS 5
  • 6. You ! Front end (Clang) Back end (LLVM) But what is “compilation” ? CPU (x86, ARM) 1) Algorithm 2) Implementation (C, Java) 3) IR (GIMPLE, LLVM IR) 4) Assembly (x86-64, PPC, ARM) 5) Microcode 6
  • 7. – 2 bar 3 = int foo + 4 x Front End 1. Lexical analysis 2. Syntax analysis 3. Semantic analysis int foo = 4 + 2 * ( bar - 3 ) int foo = 4 + 2 * ( bar - 3 ) do we know “int” ? does “foo” already exist ? do we know “x” ? is this an int ? do we know “bar” as this stage ? is this an int ?7
  • 8. – 2 bar 3 = int foo + 4 x Front End 4. Optimization 5. IR generation int foo = 4 + 2 * ( bar - 3 ) bar 2 = int foo - x 2 %tmp = mul i32 %bar, 2 %foo1 = sub i32 %tmp, 2 8
  • 9. 11110010 11100101 11101011 11010000 11000100 11000110 00110000 00100000 01101111 00111100 00111100 00100000 Back End • Optimization • Assembly generation %tmp = mul i32 %bar, 2 %foo1 = sub i32 %tmp, 2 %0 = add i32 %bar, %bar %foo1 = sub i32 %0, 2 9
  • 10. This is not new ! • GCC has a similar design… • … but it’s not modular • You cannot hack you way in • LLVM was built modularly from the beginning
  • 11. Why Modularity is a big deal • No need to deal with CPU specificities • Creating a new language is easier (reduce skill set) • Adding new CPU support is easier (do it one time) • Creating tools around languages is easier (Clang Static Analyzer, Refactoring)