Pointer Analysis. Outline: What is pointer analysis Intraprocedural pointer analysis Interprocedural pointer analysis. Andersen and Steensgaard

Similar documents
Pointer Analysis. Pointer analysis. Pointer and Alias Analysis. Useful for what? Intraprocedural Points-to Analysis. Kinds of alias information

Data Structures and Algorithms

Parallel Flow-Sensitive Pointer Analysis by Graph-Rewriting

Sam knows that his MP3 player has 40% of its battery life left and that the battery charges by an additional 12 percentage points every 15 minutes.

Data Structures and Algorithms. The material for this lecture is drawn, in part, from The Practice of Programming (Kernighan & Pike) Chapter 2

Petri Nets for Object-Oriented Modeling

COMP26120: Algorithms and Imperative Programming

Efficient Computation of Parameterized Pointer Information for Interprocedural Analyses

A Principled Approach to. MILP Modeling. Columbia University, August Carnegie Mellon University. Workshop on MIP. John Hooker.

4. Minimax and planning problems

NEWTON S SECOND LAW OF MOTION

Midterm Exam Announcements

index.pdf March 17,

AML710 CAD LECTURE 11 SPACE CURVES. Space Curves Intrinsic properties Synthetic curves

Announcements For The Logic of Boolean Connectives Truth Tables, Tautologies & Logical Truths. Outline. Introduction Truth Functions

MOTION DETECTORS GRAPH MATCHING LAB PRE-LAB QUESTIONS

Shortest Path Algorithms. Lecture I: Shortest Path Algorithms. Example. Graphs and Matrices. Setting: Dr Kieran T. Herley.

Network management and QoS provisioning - QoS in Frame Relay. . packet switching with virtual circuit service (virtual circuits are bidirectional);

CENG 477 Introduction to Computer Graphics. Modeling Transformations

Coded Caching with Multiple File Requests

Definition and examples of time series

Implementing Ray Casting in Tetrahedral Meshes with Programmable Graphics Hardware (Technical Report)

Nearest Neighbor Learning

UX260 QUICK START GUIDE

M y. Image Warping. Targil 7 : Image Warping. Image Warping. 2D Geometric Transformations. image filtering: change range of image g(x) = T(f(x))

A Matching Algorithm for Content-Based Image Retrieval

Simple example. Analysis of programs with pointers. Points-to relation. Program model. Points-to graph. Ordering on points-to relation

Dimensions. Electrical connection

Using CANopen Slave Driver

Flow graph/networks MAX FLOW APPLICATIONS. Flow constraints. Max flow problem 4/26/12

NRMI: Natural and Efficient Middleware

geometric transformations

Design of IP Networks with End-to. to- End Performance Guarantees

4.1 3D GEOMETRIC TRANSFORMATIONS

Traditional Rendering (Ray Tracing and Radiosity)

Projection & Interaction

The Roots of Lisp paul graham

Ray Tracing II. Improving Raytracing Speed. Improving Computational Complexity. Raytracing Computational Complexity

4 Error Control. 4.1 Issues with Reliable Protocols

Optics and Light. Presentation

Introduction to Data-Driven Animation: Programming with Motion Capture Jehee Lee

IDEF3 Process Description Capture Method

PART 1 REFERENCE INFORMATION CONTROL DATA 6400 SYSTEMS CENTRAL PROCESSOR MONITOR

THE MOLDFLOW ANALYSE OF THE INJECTION PARTS, AND THE IMPROVEMENT OF THE INJECTION PROCESS.

Forgot to compute the new centroids (-1); error in centroid computations (-1); incorrect clustering results (-2 points); more than 2 errors: 0 points.

Chapter Six Chapter Six

BI-TEMPORAL INDEXING

A new method for 3-dimensional roadway design using visualization techniques

Spline Curves. Color Interpolation. Normal Interpolation. Last Time? Today. glshademodel (GL_SMOOTH); Adjacency Data Structures. Mesh Simplification

Maximum Flows: Polynomial Algorithms

CAMERA CALIBRATION BY REGISTRATION STEREO RECONSTRUCTION TO 3D MODEL

Assignment 2. Due Monday Feb. 12, 10:00pm.

Dimensions. Electrical connection

Handling uncertainty in semantic information retrieval process

understood as processors that match AST patterns of the source language and translate them into patterns in the target language.

Where We Are. Incorrect Programs. Non-Context-Free Syntax. Goals of Semantic Analysis. Type Information CS412/CS413

Quantitative macro models feature an infinite number of periods A more realistic (?) view of time

Lecture 7: Objects (Chapter 15) CS 1110 Introduction to Computing Using Python

Numerical Solution of ODE

1 œ DRUM SET KEY. 8 Odd Meter Clave Conor Guilfoyle. Cowbell (neck) Cymbal. Hi-hat. Floor tom (shell) Clave block. Cowbell (mouth) Hi tom.

Language Identification for Texts Written in Transliteration

Mobile App Recommendation: Maximize the Total App Downloads

Piecewise Linear Models

Image Content Representation

MOBILE COMPUTING. Wi-Fi 9/20/15. CSE 40814/60814 Fall Wi-Fi:

MOBILE COMPUTING 3/18/18. Wi-Fi IEEE. CSE 40814/60814 Spring 2018

Functions. 6.1 Modular Programming. 6.2 Defining and Calling Functions. Gaddis: 6.1-5,7-10,13,15-16 and 7.7

Chapter 4 Sequential Instructions

Jacobian Range Space

Introduction to Computer Graphics 10. Curves and Surfaces

CS 152 Computer Architecture and Engineering. Lecture 7 - Memory Hierarchy-II

AUTOMATIC PARAMETER ESTIMATION IN MRF BASED SUPER RESOLUTION MAPPING

Extended Node-Arc Formulation for the K-Edge-Disjoint Hop-Constrained Network Design Problem

Welcome - CSC 301. CSC 301- Foundations of Programming Languages

Michiel Helder and Marielle C.T.A Geurts. Hoofdkantoor PTT Post / Dutch Postal Services Headquarters

Geometry Transformation

Optimal Crane Scheduling

Landmarks: A New Model for Similarity-Based Pattern Querying in Time Series Databases

Neural Network Enhancement of the Los Alamos Force Deployment Estimator

Outerjoins, Constraints, Triggers

A New Supervised Clustering Algorithm Based on Min-Max Modular Network with Gaussian-Zero-Crossing Functions

Dimensions. Electrical connection

Exercise 3: Bluetooth BR/EDR

Motor Control. 5. Control. Motor Control. Motor Control

Streamline Pathline Eulerian Lagrangian

Systems & Biomedical Engineering Department. Transformation

Effects needed for Realism. Ray Tracing. Ray Tracing: History. Outline. Foundations of Computer Graphics (Fall 2012)

Lecture 18: Mix net Voting Systems

Automatic Calculation of Coverage Profiles for Coverage-based Testing

MATH Differential Equations September 15, 2008 Project 1, Fall 2008 Due: September 24, 2008

An improved distributed version of Han s method for distributed MPC of canal systems

Representing Non-Manifold Shapes in Arbitrary Dimensions

A Petrel Plugin for Surface Modeling

Why not experiment with the system itself? Ways to study a system System. Application areas. Different kinds of systems

Dimensions. Electrical connection

Shape Analysis with Structural Invariant Checkers

A METHOD OF MODELING DEFORMATION OF AN OBJECT EMPLOYING SURROUNDING VIDEO CAMERAS

Distance Weighted Discrimination and Second Order Cone Programming

It is easier to visualize plotting the curves of cos x and e x separately: > plot({cos(x),exp(x)},x = -5*Pi..Pi,y = );

Xisa: Extensible Inductive Shape Analysis

Transcription:

Poiner anaysis

Poiner Anaysis Ouine: Wha is oiner anaysis Inrarocedura oiner anaysis Inerrocedura oiner anaysis Andersen and Seensgaard

Poiner and Aias Anaysis Aiases: wo exressions ha denoe he same memory ocaion. Aiases are inroduced by: oiners ca-by-reference array indexing C unions

Usefu for wha? Imrove he recision of anayses ha require knowing wha is modified or referenced (eg cons ro, CSE ) Eiminae redundan oads/sores and dead sores. x := *;... y := *; // reace wih y := x? *x :=...; // is *x dead? Paraeizaion of code can recursive cas o quick_sor be run in arae? Yes, rovided ha hey reference disinc regions of he array. Idenify objecs o be racked in error deecion oos x.ock();... y.unock(); // same objec as x?

Kinds of aias informaion Poins-o informaion (mus or may versions) a rogram oin, comue a se of airs of he form! x, where oins o x. can reresen his informaion in a oins-o grah Aias airs a each rogram oin, comue he se of of a airs (e 1,e 2 ) where e 1 and e 2 mus/may reference he same memory. x y z Sorage shae anaysis a each rogram oin, comue an absrac descriion of he oiner srucure.

Inrarocedura Poins-o Anaysis Wan o comue may-oins-o informaion Laice:

Fow funcions in x := k F x := k (in) = ou in x := a + b F x := a+b (in) = ou

Fow funcions in x := y F x := y (in) = ou in x := &y F x := &y (in) = ou

Fow funcions in x := *y F x := *y (in) = ou in *x := y F *x := y (in) = ou

Inrarocedura Poins-o Anaysis Fow funcions:

Poiners o dynamicay-aocaed memory Hande saemens of he form: x := new T One idea: generae a new variabe each ime he new saemen is anayzed o sand for he new ocaion:

Exame := new Cons := := new Cons * := :=

Exame soved := new Cons := V1 V1 V2 := new Cons V1 V2 V1 V2 V3 * := V1 V2 V1 V2 V3 := V1 V2 V1 V2 V3

Wha wen wrong? Laice infiniey a! We were esseniay running he rogram Insead, we need o summarize he infiniey many aocaed objecs in a finie way New Idea: inroduce summary nodes, which wi sand for a whoe cass of aocaed objecs.

Wha wen wrong? Exame: For each new saemen wih abe L, inroduce a summary node oc L, which sands for he memory aocaed by saemen L. Summary nodes can use oher crierion for merging.

Exame revisied : := new Cons := : := new Cons * := :=

Exame revisied & soved : := new Cons Ier 1 Ier 2 Ier 3 := : := new Cons * := :=

Exame revisied & soved : := new Cons Ier 1 Ier 2 Ier 3 := : := new Cons * := :=

Array aiasing, and oiners o arrays Array indexing can cause aiasing: a[i] aiases b[j] if: a aiases b and i = j a and b overa, and i = j + k, where k is he amoun of overa. Can have oiners o eemens of an array := &a[i];...; ++; How can arrays be modeed? Coud rea he whoe array as one ocaion. Coud ry o reason abou he array index exressions: array deendence anaysis.

Fieds Can summarize fieds using er fied summary for each fied F, kee a oins-o node caed F ha summarizes a ossibe vaues ha can ever be sored in F Can aso use aocaion sies for each fied F, and each aocaion sie S, kee a oins-o node caed (F, S) ha summarizes a ossibe vaues ha can ever be sored in he fied F of objecs aocaed a sie S.

Summary We jus saw: inrarocedura oins-o anaysis handing dynamicay aocaed memory handing oiners o arrays Bu, inrarocedura oiner anaysis is no enough. Sharing daa srucures across muie rocedures is one he big benefis of oiners: insead of assing he whoe daa srucures around, jus ass oiners o hem (eg C ass by reference). So oiners end u oining o srucures shared across rocedures. If you don do an inerroc anaysis, you have o make conservaive assumions funcions enries and funcion cas.

Conservaive aroximaion on enry Say we don have inerrocedura oiner anaysis. Wha shoud he informaion be a he inu of he foowing rocedure: goba g; void (x,y) { x y g... }

Conservaive aroximaion on enry Here are a few souions: goba g; void (x,y) { }... x y g ocaions from aoc sies rior o his invocaion x,y,g & ocaions from aoc sies rior o his invocaion They are a very conservaive! We can ry o do beer.

Inerrocedura oiner anaysis Main difficuy in erforming inerrocedura oiner anaysis is scaing One can use a o-down summary based aroach (Wison & Lam 95), bu even hese are hard o scae

Exame revisied : := new Cons Cos: sace: sore one fac a each rog oin ime: ieraion Ier 1 Ier 2 Ier 3 := : := new Cons * := :=

New idea: sore one daafow fac Sore one daafow fac for he whoe rogram Each saemen udaes his one daafow fac use he revious fow funcions, bu now hey ake he whoe rogram daafow fac, and reurn an udaed version of i. Process each saemen once, ignoring he order of he saemens This is caed a fow-insensiive anaysis.

Fow insensiive oiner anaysis : := new Cons := : := new Cons * := :=

Fow insensiive oiner anaysis : := new Cons := : := new Cons * := :=

Fow sensiive vs. insensiive : := new Cons Fow-sensiive Son Fow-insensiive Son := : := new Cons * := :=

Wha wen wrong? Wha haened o he ink beween and? Can do srong udaes anymore! Need o remove a he ki ses from he fow funcions. Wha haened o he sef oo on? We si have o ierae!

Fow insensiive oiner anaysis: fixed : := new Cons := : := new Cons * := :=

Fow insensiive oiner anaysis: fixed This is Andersen s agorihm 94 Fina resu : := new Cons Ier 1 Ier 2 Ier 3 := : := new Cons * := := L2 L1 L2

Fow sensiive vs. insensiive, again : := new Cons Fow-sensiive Son Fow-insensiive Son := : := new Cons * := :=

Fow insensiive oss of recision Fow insensiive anaysis eads o oss of recision! main() { x := &y; }... x := &z; Fow insensiive anaysis es us ha x may oin o z here! However: uses ess memory (memory can be a big boeneck o running on arge rograms) runs faser

In Cass Exercise! : := new Cons : q := new Cons * = q r = &q *q = r *q = s = r s = *r = s

In Cass Exercise! soved : := new Cons : q := new Cons * = q r = &q *q = r *q = q r s s = r s = *r = s

Wors case comexiy of Andersen x y *x = y x y a b c d e f a b c d e f Wors case: N 2 er saemen, so a eas N 3 for he whoe rogram. Andersen is in fac O(N 3 )

New idea: one successor er node Make each node have ony one successor. This is an invarian ha we wan o mainain. x y *x = y x y a,b,c d,e,f a,b,c d,e,f

More genera case for *x = y x y *x = y

More genera case for *x = y x y x y x y *x = y

Handing: x = *y x y x = *y

Handing: x = *y x y x y x y x = *y

Handing: x = y (wha abou y = x?) x y x = y Handing: x = &y x y x = &y

Handing: x = y (wha abou y = x?) x y x y x y x = y ge he same for y = x Handing: x = &y x y x = &y x y x y,

Our favorie exame, once more! : := new Cons 1 := 2 : := new Cons 3 * := 4 := 5

Our favorie exame, once more! : := new Cons := 2 1 1 2 3 : := new Cons 3 4 5 * := 4 := 5,

Fow insensiive oss of recision : := new Cons Fow-sensiive Subse-based Fow-insensiive Subse-based Fow-insensiive Unificaionbased := : := new Cons * :=, :=

Anoher exame bar() { 1 i := &a; 2 j := &b; 3 foo(&i); 4 foo(&j); // i ns o wha? *i :=...; } void foo(in* ) { rinf( %d,*); }

Anoher exame bar() { 1 i := &a; 2 j := &b; 3 foo(&i); 4 foo(&j); // i ns o wha? *i :=...; i 1 2 a i a 4 j b 3 i a j b } void foo(in* ) { rinf( %d,*); } i a j b i,j a,b

Amos inear ime Time comexiy: O(Nα(N, N)) inverse Ackermann funcion So sow-growing, i is basicay inear in racice For he curious: node merging imemened using UNION-FIND srucure, which aows se union wih amorized cos of O(α(N, N)) er o. Take CSE 202 o earn more!

In Cass Exercise! : := new Cons : q := new Cons * = q r = &q *q = r *q = s = r s = *r = s

In Cass Exercise! soved : := new Cons : q := new Cons Seensgaard q,,s2 * = q r s r = &q *q = r s = r *q = s = Andersen q *r = s r s

Advanced Poiner Anaysis Combine fow-sensiive/fow-insensiive Cever daa-srucure design Conex-sensiiviy