LLVM: A Compila ilation Framework for Lifelong Progr for Lifelong - - PowerPoint PPT Presentation

llvm a compila ilation framework for lifelong progr for
SMART_READER_LITE
LIVE PREVIEW

LLVM: A Compila ilation Framework for Lifelong Progr for Lifelong - - PowerPoint PPT Presentation

Systems and Internet Infrastructure Security ity Network and Security Research Center Department of Computer Science and Engineering Pennsylvania State University, University Park PA LLVM: A Compila ilation Framework for Lifelong Progr for


slide-1
SLIDE 1

Systems and Internet Infrastructure Security

Network and Security Research Center Department of Computer Science and Engineering Pennsylvania State University, University Park PA

LLVM: A Compila for Lifelong Progr

Systems and Internet Infrastructure Security (SIIS) Laboratory

for Lifelong Progr Transfor

Chris Lattner an Presented by: N

ity

ilation Framework gram Analysis and

Page 1

gram Analysis and

  • rmation

and Vikram Adve Nirupama Talele

slide-2
SLIDE 2

Agenda

  • What is LLVM
  • LLVM Code Represent
  • LLVM Compiler Archite

Systems and Internet Infrastructure Security (SIIS) Laboratory

  • Framework Analysis

ntation itecture

Page 2

slide-3
SLIDE 3

LLVM

  • “Compiler framework desig

lifelong, program analysis

  • Provides high level info to

Systems and Internet Infrastructure Security (SIIS) Laboratory

  • Compile-time
  • Link-time
  • Run-time
  • In-idle-time

signed to support transparent, is and transformation” to compiler transformations

Page 3

slide-4
SLIDE 4

LLVM

  • Program analysis shou

lifetime of a program

  • Intra-procedural optimiz

Systems and Internet Infrastructure Security (SIIS) Laboratory

  • Intra-procedural optimiz
  • Machine-dependent opt
  • Dynamic optimization (r
  • Profile-guided optimizat

uld occur through the

izations (link time)

Page

izations (link time) ptimizations (install time) (run time) ations (idle time)

4

slide-5
SLIDE 5

LLVM Difference

  • No high-level construct
  • classes, inheritance, etc

Systems and Internet Infrastructure Security (SIIS) Laboratory

  • No runtime system or o
  • Does not guarantee sa
  • type and memory

e with VMs

cts

etc

Page

r object model afety

5

slide-6
SLIDE 6

LLVM Analysis

  • Aim to make lifelong an

programmers

Systems and Internet Infrastructure Security (SIIS) Laboratory

  • Achieved through two p
  • Code Representation
  • Compiler Architecture

analysis transparent to

Page

parts:

6

slide-7
SLIDE 7

LLVM Code Repr

  • Key feature: high and low
  • RISC-like instruction set
  • SSA-based representation

Systems and Internet Infrastructure Security (SIIS) Laboratory

  • SSA-based representation
  • Low-level, language indep
  • LLVM is complementary to

JVM,Microsoft CLI), not an

presentation

w level

Page

ependent type system to virtual machines(like an alternative

7

slide-8
SLIDE 8

LLVM Code Repr

  • How Support Lifelong A
  • 5 capabilities
  • Persistent program info
  • Offline code generation

Systems and Internet Infrastructure Security (SIIS) Laboratory

  • Offline code generation
  • User-based profiling/op
  • Transparent runtime mo
  • Uniform, whole program
  • No previous system pro

presentation

Analysis?

formation n

Page

n ptimization

  • del

m compilation

rovides all 5

8

slide-9
SLIDE 9

Instruction Set

  • Avoids machine specific co
  • Infinite set of typed virtual
  • In SSA form
  • Includes support for phi fun
  • This allows flow insensitive

Systems and Internet Infrastructure Security (SIIS) Laboratory

  • This allows flow insensitive

sensitive without expensive

  • Avoids same code for mul
  • pcodes)
  • Is in load/store form -progr

registers and memory sole

  • perations using typed po

constraints al registers

nctions ve algo to gain benefits of flow

Page

ve algo to gain benefits of flow ve Data Flow analysis

ultiple instructions (overloaded grams transfer values between lely via load and store

  • inters

9

slide-10
SLIDE 10

Type Information

  • Makes all address arith

to all LLVM optimizatio

Example :- X[i].a = 1; (assuming a is third field)

Systems and Internet Infrastructure Security (SIIS) Laboratory

Example :- X[i].a = 1; (assuming a is third field) %p = getelementptr %xty* %X, long %i, ubyte 3; store int 1, int* %p;

  • All addressable objects

allocated ithmetic explicit, exposing it ions.

X[i].a = 1; (assuming a is third field)

Page

X[i].a = 1; (assuming a is third field) %p = getelementptr %xty* %X, long %i, ubyte 3;

ts (“lvalues”) are explicitly

10

slide-11
SLIDE 11

Exception Hand

  • Exceptions mechanism

instructions

  • invoke
  • unwind

Systems and Internet Infrastructure Security (SIIS) Laboratory

unwind

  • Isolate code to throw/re

front-end libraries

  • Handling automatic var
  • An invoke instruction is

destructor is run, then u the unwind instruction.

dling

m based on two

Page

/recover from exceptions to ariable destructors:

is used to halt unwinding, the unwinding is continued with

11

slide-12
SLIDE 12

LLVM Compiler A

  • Remember: goal to ena

link-time, install-time, ru

  • Must be transparent to

Systems and Internet Infrastructure Security (SIIS) Laboratory

  • Must be transparent to

and end-users

  • Efficient enough for use

applications

Architecture

nable transformations at run-time, and idle-time to application developers

Page

to application developers se with real-world

12

slide-13
SLIDE 13

LLVM Compiler A

Systems and Internet Infrastructure Security (SIIS) Laboratory

  • This strategy provides the
  • Some limitations
  • Language specific optimiza

end

  • Benefit to languages like Ja

systems?

Architecture

Page

e 5 benefits discussed earlier

ations must be performed on front Java requiring sophisticated runtime

13

slide-14
SLIDE 14

LLVM Compiler A

Systems and Internet Infrastructure Security (SIIS) Laboratory

  • Front-end compiler
  • Translate source code to LL
  • Perform language specific o
  • Need not perform SSA const
  • Invoke LLVM passes for glo

at module level

Architecture

Page

LLVM representation c optimizations nstruction at this time lobal inter procedural optimization

14

slide-15
SLIDE 15

LLVM Compiler A

Systems and Internet Infrastructure Security (SIIS) Laboratory

  • Linker/Interprocedure Opti
  • Various analyses occur
  • Points-to analysis
  • Mod/Ref analysis
  • Dead global elimination, dead

propagation, array bounds che

  • Can be speeded up by adding

Architecture

Page

ptimizer

d argument elimination, constant heck, etc g inter-procedural summaries)

15

slide-16
SLIDE 16

LLVM Compiler A

Systems and Internet Infrastructure Security (SIIS) Laboratory

  • Native Code Generation
  • JIT or Offline
  • Currently supports Sparc V

Architecture

Page

c V9 and x86 architectures

16

slide-17
SLIDE 17

LLVM Compiler A

Systems and Internet Infrastructure Security (SIIS) Laboratory

  • Reoptimizers
  • Identifies frequently run cod
  • Performs additional optimiza

generation can be performe

  • Idle-time reoptimizer

Architecture

Page

code and ‘hotspots’ izations, thus native code ed ahead of time

17

slide-18
SLIDE 18

LLVM Analysis

  • When compiled to LLV

undergo the following a

Systems and Internet Infrastructure Security (SIIS) Laboratory

  • Flow-insensitive, field-s

points-to analysis

  • Uses Data Structure An

VM, a program can analyses

Page

sensitive, context-sensitive nalysis (DSA)

18

slide-19
SLIDE 19

LLVM Analysis –

  • Relatively compact cod

Systems and Internet Infrastructure Security (SIIS) Laboratory

Code Size

  • de size

Page 19

slide-20
SLIDE 20

Conclusion

  • LLVM is language inde
  • Optimizations at all sta

(compile,link, runtime, e

  • Compact code size

Systems and Internet Infrastructure Security (SIIS) Laboratory

  • Efficient- due to small,

low level representation

  • Future work: can high-l

implemented on top of

  • ptimization and code g

ependent tages of software lifetime , etc)

Page

ll, uniform instruction set in ion level VMs be f the LLVM runtime e generation framework?

20

slide-21
SLIDE 21

Questions?

Systems and Internet Infrastructure Security (SIIS) Laboratory Page 21