Overview of program analysis Mooly Sagiv html://www.math.tau.ac.il/~msagiv/courses/wcc03.html.

Slides:



Advertisements
Similar presentations
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Advertisements

DATAFLOW TESTING DONE BY A.PRIYA, 08CSEE17, II- M.s.c [C.S].
Abstract Interpretation Part II
Semantics Static semantics Dynamic semantics attribute grammars
Data-Flow Analysis II CS 671 March 13, CS 671 – Spring Data-Flow Analysis Gather conservative, approximate information about what a program.
8. Static Single Assignment Form Marcus Denker. © Marcus Denker SSA Roadmap  Static Single Assignment Form (SSA)  Converting to SSA Form  Examples.
Lecture 11: Code Optimization CS 540 George Mason University.
Context-Sensitive Interprocedural Points-to Analysis in the Presence of Function Pointers Presentation by Patrick Kaleem Justin.
Compilation 2011 Static Analysis Johnni Winther Michael I. Schwartzbach Aarhus University.
Register Allocation Mooly Sagiv Schrierber Wed 10:00-12:00 html://
Data-Flow Analysis Framework Domain – What kind of solution is the analysis looking for? Ex. Variables have not yet been defined – Algorithm assigns a.
3-Valued Logic Analyzer (TVP) Tal Lev-Ami and Mooly Sagiv.
Some Properties of SSA Mooly Sagiv. Outline Why is it called Static Single Assignment form What does it buy us? How much does it cost us? Open questions.
1 Mooly Sagiv and Greta Yorsh School of Computer Science Tel-Aviv University Modern Compiler Design.
Control Flow Analysis (Chapter 7) Mooly Sagiv (with Contributions by Hanne Riis Nielson)
Introduction to Advanced Topics Chapter 1 Mooly Sagiv Schrierber
Lecture 01 - Introduction Eran Yahav 1. 2 Who? Eran Yahav Taub 734 Tel: Monday 13:30-14:30
1 Static Testing: defect prevention SIM objectives Able to list various type of structured group examinations (manual checking) Able to statically.
1 Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications.
Establishing Local Temporal Heap Safety Properties with Applications to Compile-Time Memory Management Ran Shaham Eran Yahav Elliot Kolodner Mooly Sagiv.
Cpeg421-08S/final-review1 Course Review Tom St. John.
Program analysis Mooly Sagiv html://
Recap Mooly Sagiv. Outline Subjects Studied Questions & Answers.
An Overview on Program Analysis Mooly Sagiv Tel Aviv University Textbook: Principles of Program.
Liveness Analysis Mooly Sagiv Schrierber Wed 10:00-12:00 html://
An Overview on Static Program Analysis Mooly Sagiv Tel Aviv University Textbook: Principles of.
Program analysis Mooly Sagiv html://
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
Data Flow Analysis Compiler Design October 5, 2004 These slides live on the Web. I obtained them from Jeff Foster and he said that he obtained.
Abstract Interpretation Part I Mooly Sagiv Textbook: Chapter 4.
1 Program Analysis Mooly Sagiv Tel Aviv University Textbook: Principles of Program Analysis.
Code Generation Mooly Sagiv html:// Chapter 4.
Pointer and Shape Analysis Seminar Mooly Sagiv Schriber 317 Office Hours Thursday
Compiler Summary Mooly Sagiv html://
Overview of program analysis Mooly Sagiv html://
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
Detecting Memory Errors using Compile Time Techniques Nurit Dor Mooly Sagiv Tel-Aviv University.
1 Program Analysis Systematic Domain Design Mooly Sagiv Tel Aviv University Textbook: Principles.
Program Analysis Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
1 Tentative Schedule u Today: Theory of abstract interpretation u May 5 Procedures u May 15, Orna Grumberg u May 12 Yom Hatzamaut u May.
An Overview on Static Program Analysis Mooly Sagiv.
Data Flow Analysis Compiler Baojian Hua
Department of Computer Science A Static Program Analyzer to increase software reuse Ramakrishnan Venkitaraman and Gopal Gupta.
1 Iterative Program Analysis Abstract Interpretation Mooly Sagiv Tel Aviv University Textbook:
Compiler course 1. Introduction. Outline Scope of the course Disciplines involved in it Abstract view for a compiler Front-end and back-end tasks Modules.
An Overview on Program Analysis Mooly Sagiv Tel Aviv University Textbook: Principles of Program.
Static Program Analyses of DSP Software Systems Ramakrishnan Venkitaraman and Gopal Gupta.
Compiler Principles Fall Compiler Principles Lecture 0: Local Optimizations Roman Manevich Ben-Gurion University.
(Static) Program Analysis 동아대학교 컴퓨터공학과 조장우. Motivation u 컴퓨터 기술자는 무엇을 해야 하는가 ? The production of reliable software, its maintenance, and safe evolution.
Page 1 5/2/2007  Kestrel Technology LLC A Tutorial on Abstract Interpretation as the Theoretical Foundation of CodeHawk  Arnaud Venet Kestrel Technology.
Semantics In Text: Chapter 3.
Program Analysis Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Intermediate Code Representations
1 Control Flow Graphs. 2 Optimizations Code transformations to improve program –Mainly: improve execution time –Also: reduce program size Can be done.
1 Languages and Compilers (SProg og Oversættere) Compiler Optimizations Bent Thomsen Department of Computer Science Aalborg University With acknowledgement.
Introduction to Software Analysis CS Why Take This Course? Learn methods to improve software quality – reliability, security, performance, etc.
Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications Chapter.
Language Implementation Overview John Keyser Spring 2016.
1 Iterative Program Analysis Abstract Interpretation Mooly Sagiv Tel Aviv University Textbook:
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Finding bugs with a constraint solver daniel jackson. mandana vaziri mit laboratory for computer science issta 2000.
Optimization Simone Campanoni
STATIC CODE ANALYSIS. OUTLINE  INTRODUCTION  BACKGROUND o REGULAR EXPRESSIONS o SYNTAX TREES o CONTROL FLOW GRAPHS  TOOLS AND THEIR WORKING  ERROR.
Program Analysis Last Lesson Mooly Sagiv. Goals u Show the significance of set constraints for CFA of Object Oriented Programs u Sketch advanced techniques.
Data Flow Analysis Suman Jana
Mooly Sagiv html://
University Of Virginia
Languages and Compilers (SProg og Oversættere) Compiler Optimizations
Ras Bodik WF 11-12:30 slides adapted from Mooly Sagiv
Presentation transcript:

Overview of program analysis Mooly Sagiv html://

Exam Format (Moed A 02) Compile- vs Run-time events (25) American style question (10) Handling new language feature in TC (40) Understanding (25)

Outline What is (static) program analysis Examples Undecidability Algorithms

Static Analysis Automatic derivation of static properties which hold on every execution leading to a program location Usages –Compiler optimizations –Code quality tools Identify bugs Prove absence of certain bugs

Example Static Analysis Problem Find variables with constant value at a given program location int p(int x){ return x *x ; } void main() { int z; if (getc()) z = p(6) + 8; else z = p(5) + 7; printf (z); } int p(int x){ return (x *x) ; } void main() { int z; if (getc()) z = p(3) + 1; else z = p(-2) + 6; printf (z); }

Example Static Analysis Problem Find variables which are live at a given program location

A Simple Example /* c */ L0: a := 0 /* ac */ L1:b := a + 1 /* bc */ c := c + b /* bc */ a := b * 2 /* ac */ if c < N goto L1 /* c */ return c ab c

List reverse(Element  head) { List rev, n; rev = NULL; while (head != NULL) { n = head  next; head  next = rev; head = n; rev = head; } return rev; } Memory Leakage leakage of address pointed to by head

Memory Leakage Element  reverse(Element  head) { Element  rev,  n; rev = NULL; while (head != NULL) { n = head  next; head  next = rev; rev = head; head = n; } return rev; } ✔ No memory leaks

Compiler Scheme String Scanner Parser Semantic Analysis Code Generator Static analysis Transformations Tokens source-program tokens AST IR IR +information

Undecidability issues It is impossible to compute exact static information Finding if a program point is reachable Difficulty of interesting data properties

Undecidabily A variable is live at a given point in the program –if its current value is used after this point prior to a definition in some execution path It is undecidable if a variable is live at a given program location

Proof Sketch Pr L: x := y Is y live at L?

Conservative (Sound) The compiler need not generate the optimal code Can use more registers (“spill code”) than necessary Find an upper approximation of the live variables Err on the safe side A superset of edges in the interference graph Not too many superfluous live variables

Conservative Software Quality Tools Can never miss an error Buy may produce false alarms –Warning on non existing errors

Iterative computation of conservative static information Construct a control flow graph Optimistically start with the best value at every node “Interpret” every statement in a conservative way Stop when no changes occur

/* c */ L0: a := 0 /* ac */ L1:b := a + 1 /* bc */ c := c + b /* bc */ a := b * 2 /* ac */ if c < N goto L1 /* c */ return c a := 0 ; b := a +1 ; c := c +b ; a := b*2 ; c <N goto L1 return c ;

a := 0 ; b := a +1 ; c := c +b ; a := b*2 ; c <N goto L1 return c ;      

a := 0 ; b := a +1 ; c := c +b ; a := b*2 ; c <N goto L1 return c ;  {c}    

a := 0 ; b := a +1 ; c := c +b ; a := b*2 ; c <N goto L1 return c ;  {c}   

a := 0 ; b := a +1 ; c := c +b ; a := b*2 ; c <N goto L1 return c ;  {c} {c, b}  

a := 0 ; b := a +1 ; c := c +b ; a := b*2 ; c <N goto L1 return c ;  {c} {c, b} 

a := 0 ; b := a +1 ; c := c +b ; a := b*2 ; c <N goto L1 return c ;  {c} {c, b} {c, a} {c, b}

a := 0 ; b := a +1 ; c := c +b ; a := b*2 ; c <N goto L1 return c ;  {c, a} {c} {c, b} {c, a} {c, b}

a := 0 ; b := a +1 ; c := c +b ; a := b*2 ; c <N goto L1 return c ;  {c, a} {c, b} {c, a} {c, b}

Summary Program analysis provides non-trivial insights on the runtime executions of the program Mathematically justified –Operational semantics –Abstract interpretation (lattice theory) Employed in compilers Will be employed in software quality tools But the course in TAU is theoretical