have your verified compiler and extend it too

19
Have Your Verified Compiler And Extend It Too Zachary Tatlock Sorin Lerner UC San Diego

Upload: naif

Post on 23-Feb-2016

30 views

Category:

Documents


0 download

DESCRIPTION

Have Your Verified Compiler And Extend It Too. Zachary Tatlock Sorin Lerner UC San Diego. Compiler Correctness. Building robust compilers is difficult complex interactions resist testing. Compiler bugs are contagious invalidate source level guarantees. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Have Your Verified Compiler And Extend It Too

Have Your Verified Compiler

And Extend It Too

Zachary TatlockSorin LernerUC San Diego

Page 2: Have Your Verified Compiler And Extend It Too

Compiler Correctness

Building robust compilers is difficultcomplex interactions resist testingCompiler bugs are contagiousinvalidate source level guarantees

Few users extend their compilerhand optimized, unreadable code

Page 3: Have Your Verified Compiler And Extend It Too

Verified Compilers

Implement compiler in proof assistant Prove compiler correct interactively CompCert [Leroy], Lambda Tamer

[Chlipala]Strong

Guarantee

Difficult to

Extend

Page 4: Have Your Verified Compiler And Extend It Too

DSL-based Compilers

Domain Specific Language for optimizations

DSL opts proven correct automatically Rhodium [POPL 05], PEC [PLDI 09]

Easier toExtend

WeakerGuarante

e

Page 5: Have Your Verified Compiler And Extend It Too

Contribution

PEC

CompCert

harder to extend

easier to extend

stronger guarantee

weaker guarantee

DSL Execution Engine +Correctness Proof

Reduce TCB

AddExtensibility

PEC

XCertCompCert

Page 6: Have Your Verified Compiler And Extend It Too

CompCert

XCert

RewriteRule

PEC

Extensible & Correct Compiler

Rewrite

LocallyCorrect

CompCert

C Asm

Correct Compiler

??

Main Theorem Proved in Coq : XCert Rules Locally Correct XCert Correct

? Formal Correctness Proof in Coq

Bulk of the development effort

[PLDI 09]

Page 7: Have Your Verified Compiler And Extend It Too

Extensible & Correct Compiler

1Rewrite

Rule

PEC CompCert

C Asm

2 XCert

Challenges and Evaluation3

[PLDI 09]

Page 8: Have Your Verified Compiler And Extend It Too

Rewrite Rule Find &

Replace Match

PatternC x <

10

I x Apply Subst

while(C ) I += 2

while(C ) I ++ I ++

PEC

x = 0

while(x < 10)

x += 2

return x

x = 0

while(x < 10)

x ++

x ++

return x

[PLDI 09]

Page 9: Have Your Verified Compiler And Extend It Too

I ++

I ++

!C

C

I +=2

!CC

PEC Checker1.Convert to CFG2.Guess Sync

Points3.Check w/ SMT

A

B

PEC

SMT Checked

A AA B

while(C ) I += 2

while(C ) I ++ I ++

I ++

C

I +=2I ++

C

A

A

[PLDI 09]

Page 10: Have Your Verified Compiler And Extend It Too

XCert Module

1.Rule in Coq2.SMT Checks

A

B

SMT CheckedA AA B

PEC

Page 11: Have Your Verified Compiler And Extend It Too

Extensible & Correct Compiler

1Rewrite

Rule

PEC

2 XCert

[PLDI 09]

Challenges and Evaluation3

Page 12: Have Your Verified Compiler And Extend It Too

XCert Correctness Proof

Small Step Execute instruction

Step state S to S’

S

S’

Page 13: Have Your Verified Compiler And Extend It Too

Equivalent Executions Initial Equiv Prove Simulation Diagram

CompCert Small Step Library: Sim Diagram Progs

Equiv

L

L’

R

R’

L ~ R

<< L L’

R’

L’ ~ R’: R R’

Final Equiv

XCert Correctness Proof

?

Page 14: Have Your Verified Compiler And Extend It Too

XCert Simulation Diagram

XCert Module

A

A

A

B

A

B

SMT Checked

A AA B

Page 15: Have Your Verified Compiler And Extend It Too

Extensible & Correct Compiler

1Rewrite

Rule

PEC

2 XCert

[PLDI 09]

Challenges and Evaluation3

Page 16: Have Your Verified Compiler And Extend It Too

Challenges (see paper)

XCert Execution Engine CFG pattern matching CFG splicing

XCert Correctness Proof Managing case explosion Verified validation [Tristan and Leroy]

Preserving non-terminating behaviors

Page 17: Have Your Verified Compiler And Extend It Too

Evaluation

Engine : 1,000 lines of Coq functional code

Proof : 3,000 lines of Coq proof script

Trusted Computing Base (TCB) Compcert : Coq + Coq encoding of C sem XCert adds : SMT + SMT encoding of C sem

Page 18: Have Your Verified Compiler And Extend It Too

Evaluation

Extensibility: Support PEC Opts [PLDI 09] No manual proof effort or TCB increase Maintain Compcert end-to-end

correctness

Sample of Optimizations Run:Loop Invariant Code Hoist Loop Peeling

Software Pipelining Conditional Speculation

Loop Unswitching Partial Redundancy Elim

Page 19: Have Your Verified Compiler And Extend It Too

1Rewrite

Rule

PEC

2 XCert

[PLDI 09]

Extensible & Correct Compiler

Thank You!