CSE 504: Compiler Design. Data Flow Analysis

Similar documents
Lecture 2 Introduction to Data Flow Analysis

Introduction to Data-flow analysis

Optimizations. Optimization Safety. Optimization Safety. Control Flow Graphs. Code transformations to improve program

Why have SSA? Birth Points (cont) Birth Points (a notion due to Tarjan)

Why? A central concept in Computer Science. Algorithms are ubiquitous.

Obfuscation: know your enemy

Using Eclipse CDT/PTP for Static Analysis

gprof: a Call Graph Execution Profiler 1

CIS570 Lecture 4 Introduction to Data-flow Analysis 3

FPGA area allocation for parallel C applications

Measuring the Performance of an Agent

Review; questions Discussion of Semester Project Arbitrary interprocedural control flow Assign (see Schedule for links)

Operations: search;; min;; max;; predecessor;; successor. Time O(h) with h height of the tree (more on later).

Home Page. Data Structures. Title Page. Page 1 of 24. Go Back. Full Screen. Close. Quit

Software Testing & Analysis (F22ST3): Static Analysis Techniques 2. Andrew Ireland

Lecture 9. Semantic Analysis Scoping and Symbol Table

Problems and Measures Regarding Waste 1 Management and 3R Era of public health improvement Situation subsequent to the Meiji Restoration

Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)

Testing Automation for Distributed Applications By Isabel Drost-Fromm, Software Engineer, Elastic

Technical paper review. Program visualization and explanation for novice C programmers by Matthew Heinsen Egan and Chris McDonald.

NP-complete? NP-hard? Some Foundations of Complexity. Prof. Sven Hartmann Clausthal University of Technology Department of Informatics

Unordered Linked Lists

Class notes Program Analysis course given by Prof. Mooly Sagiv Computer Science Department, Tel Aviv University second lecture 8/3/2007

Dataflow approach to testing Java programs supported with DFC

Linked List as an ADT (cont d.)

Big Data looks Tiny from the Stratosphere

High Performance XML Data Retrieval

GameTime: A Toolkit for Timing Analysis of Software

CSCI 253. Object Oriented Programming (OOP) Overview. George Blankenship 1. Object Oriented Design: Java Review OOP George Blankenship.

Master s Project Summary Paper: ACM SIGSPATIAL GIS Cup 2012

Lecture Notes on Static Analysis

VisCG: Creating an Eclipse Call Graph Visualization Plug-in. Kenta Hasui, Undergraduate Student at Vassar College Class of 2015

EECS 583 Class 11 Instruction Scheduling Software Pipelining Intro

Online Construction of Dynamic Object Process Graphs

Software Pipelining - Modulo Scheduling

Cloud Enabled Emergency Navigation Using Faster-than-real-time Simulation

3. The Junction Tree Algorithms

8.1 Min Degree Spanning Tree

CRASHING-RISK-MODELING SOFTWARE (CRMS)

Contents. System Development Models and Methods. Design Abstraction and Views. Synthesis. Control/Data-Flow Models. System Synthesis Models

A Survey of Static Program Analysis Techniques

Finding Fault Location: Combining network topology and end-to-end measurments to locate network problems?

Internet Firewall CSIS Packet Filtering. Internet Firewall. Examples. Spring 2011 CSIS net15 1. Routers can implement packet filtering

Memory Allocation. Static Allocation. Dynamic Allocation. Memory Management. Dynamic Allocation. Dynamic Storage Allocation

Graph Theory Algorithms for Mobile Ad Hoc Networks

Scalable Source Routing

Instruction scheduling

Reductions & NP-completeness as part of Foundations of Computer Science undergraduate course

Sources: On the Web: Slides will be available on:

Visualizing Information Flow through C Programs

Algorithms Chapter 12 Binary Search Trees

Code Coverage Testing Using Hardware Performance Monitoring Support

APPROACHES TO SOFTWARE TESTING PROGRAM VERIFICATION AND VALIDATION

Introduction to Logic in Computer Science: Autumn 2006

How To Trace

Cost Model: Work, Span and Parallelism. 1 The RAM model for sequential computation:

Parallel and Distributed Computing Programming Assignment 1

MapReduce and Distributed Data Analysis. Sergei Vassilvitskii Google Research

WESTMORELAND COUNTY PUBLIC SCHOOLS Integrated Instructional Pacing Guide and Checklist Computer Math

GSPIM: Graphical Visualization Tool for MIPS Assembly

Asking Hard Graph Questions. Paul Burkhardt. February 3, 2014

Enforcing Data Quality Rules for a Synchronized VM Log Audit Environment Using Transformation Mapping Techniques

Binary Search Trees. A Generic Tree. Binary Trees. Nodes in a binary search tree ( B-S-T) are of the form. P parent. Key. Satellite data L R

Hunting Vulnerabilities with Graph Databases

Ensuring Code Quality in Multi-threaded Applications

Module 10. Coding and Testing. Version 2 CSE IIT, Kharagpur

A Dynamic Multimodal Route Planner for Rome. Luca Allulli Damiano Morosi Roma Servizi per la Mobilità

GRID SEARCHING Novel way of Searching 2D Array

2.0. Specification of HSN 2.0 JavaScript Static Analyzer

The Basics of Graphical Models

Lab Introduction to Web Services

A Fresh Look at Optimizing Array Bound Checking

Practical Memory Leak Detection using Guarded Value-Flow Analysis

Oracle Big Data Spatial & Graph Social Network Analysis - Case Study

Giving life to today s media distribution services

How To Prevent An Sql Injection Attack

Static Analysis. Find the Bug! : Analysis of Software Artifacts. Jonathan Aldrich. disable interrupts. ERROR: returning with interrupts disabled

BPEL disadvantage: more time to product BPEL advantage: better reusability, analysis

Masters in Advanced Computer Science

Simulation-Based Security with Inexhaustible Interactive Turing Machines

Graph Theory Origin and Seven Bridges of Königsberg -Rhishikesh

Data Structures Using C++ 2E. Chapter 5 Linked Lists

Transcription:

Data Flow Analysis Pradipta De pradipta.de@sunykorea.ac.kr

Current Topic Iterative Data Flow Analysis LiveOut sets Static Single Assignment (SSA) Form

Data Flow Analysis Techniques to reason about runtime flow of values in the program Uses static analysis (or compile time reasoning) of the code to infer runtime behavior Useful in global optimization Data Flow Analysis techniques solves a set of simultaneous equations defined over sets associated with the nodes and edges of a CFG

Dominance Information In a flow graph with entry node b0, node bi dominates node bj, written bi >> bj, if and only if bi lies on every path from b0 to bj. By definition, bi >> bi Nodes B0, B1, B5, B6 lie on every path from B0 to B6 DOM(B6) is {B0, B1, B5, B6}

How to compute DOM sets Solve the equation: Initial Condition: Dom(n0) = {n0}, and Dom(n) = {N}, where n not = n0 Dom(n) is computed as a function of its predecessors forward data flow problem Computing Dom Sets: 1. Build a CFG (Control Flow Graph) 2. Gather initial information for each block 1. Only information required is the block id, e.g. id i for a block Bi 3. Solve the equations to produce the DOM sets for each block

Iterative Solver for DOM sets Traverse the nodes in ascending order of their id, compute DOM iteratively till there is no change.

Algorithm Property Does the algorithm always terminate? Iterative calculation of the Dom sets halts because the sets that approximate Dom shrink monotonically throughout the computation Does it compute the correct DOM sets? Forms a fixed point solution to the dominance equations Can be proved that fixed point exists for each equation and it is unique Does the order of traversal in the algorithm matter? Depending on the order of traversal, the algorithm can take less number of iterations

Liveness Analysis Finding potential use of uninitialized variables can be found using liveness analysis A variable v is live at point p if and only if there exists a path in the CFG from p to a use of v along which v is not redefined Liveout(b): encode live information by computing all variables that are live on exit from a block b For each node n in the CFG, Liveout(n) is defined by an equation that uses Liveout sets of n s successors in the CFG, and two sets UEVar(n) and VarKill(n)

Liveout Equation UEVar(m) contains variables used in m before any redefinition in m upward exposed variables VarKill(m) contains all variables that are defined in m the equation contains the complement of the set, i.e. all variables that are NOT defined in m Liveout(n) is union of those variables that are live at the head of some block m, that immediately follows n, in the CFG backward data flow problem Three steps: 1. Build a CFG 2. Gather initial information 1. Compute UEVar and VarKill for each block b 3. Solve the Liveout equations for each block b

Computing UEVar and VarKill

Finding Uninitialized Variables If v ϵ Liveout(n0), then there is a path from n0 to a use of v along which v is not defined Uninitialized variable v May lead to false positives identify variables as uninitialized although they are initialized

Limitations If v is accessible through another name and initialized through that name, live analysis cannot connect the two names If v exists before the current procedure is invoked, then it may have been initialized before Static variables within current scope Variables declared outside current scope Static analysis can discover a path from procedure entry to use of v, but the path never used at runtime In C, variables are initialized by default

Use of Live variables Useful in global register allocation Need not keep value in register if not live Compiler can use live variable information to discover useless store operations If v is not live, no need to store v back to memory