




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





















*some slides are borrowed from Baishakhi Ray and Ras Bodik
Our Goal Program Analyzer Source code Security bugs Program analyzer must be able to understand program proper?es (e.g., can a variable be NULL at a par?cular program point? ) Must perform control and data flow analysis
Compiler Overview
The Structure of a Compiler 5
Example
NUM(4)
NUM(2) NUM(3)
Parse tree for the example: 4*(2+3) Adopted From UC Berkeley: Prof. Bodik CS 164 Lecture 5 8
Parse tree for example: if (x==y) {a=1;} Adopted From UC Berkeley: Prof. Bodik CS 164 Lecture 5 10
Parse Tree
Abstract Syntax Tree (AST)
C Statement: return a + 2 AST
RepresenBng Control Flow Adopted From U Penn CIS 570: Modern Programming Language Implementa?on (Autumn 2006) High-level representation
Basic Blocks
Basic Block Example 1 2 a := 0 b := a * b 3 L1: c := b/d 4 5 6 if c < x goto L e := b / c f := e + 1 7 L2: g := f 8 9 h := t - g if e > 0 goto L 10 goto L 11 L3: return Leaders?