Top Banner
Pointer and Shape Analysis Seminar http://www.cs.tau.ac.il/~msagiv/course s/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16
33

Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Dec 21, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Pointer and Shape Analysis Seminarhttp://www.cs.tau.ac.il/~msagiv/courses/shape.html

Mooly Sagiv

Schriber 317

msagiv@post

Office Hours Thursday 15-16

Page 2: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Outline

1. General information

2. Seminar subject

3. How to give a presentation

Page 3: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

General Information

• Prerequisites– Compilers | Program Analysis– Select 3 topics by Sunday– Participate in 9 seminar talks – Present a paper

Page 4: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Tentative Schedule

• Today: Intro

• Sunday (selection of topic)

• Student lectures

Page 5: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Pointer and Shape Analysis

Page 6: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Program Analysis Statically analyze the program text (w/o input)

Determine conservative information about all (some) program executions

Applications

Verification

Each verified property holds but not all properties can be verified all programs

False alarms

Compiler optimizations

Parallelizations

Garbage collection

Page 7: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Alias Analysis

• Two expressions referring to the same memory location at a given program point on some (all) executions

[1] p = &a;

[2] q = &b;

[3] if (getc())

[4] q = &c

[5] *p = a

*q = c

*q = b

Page 8: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Points-To Analysis

• Determine if a variable points to a variable at some (all) execution paths

[1] p = &a;

[2] q = &b;

[3] if (getc())

[4] q = &c

[5] p a

q c

q b

Page 9: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Shape Analysis• Determine the potential shapes of memory

at a given program point

[1] p = &a;

[2] q = &b;

[3] if (getc())

[4] q = &c

ap *

ap *

bq *

ap *

cq *

ap *

bq *

ap *

cq *

Page 10: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Applications

• “Adapt” other optimizations – Constant propagation

x = 5;*p = 7 ;… x …

• Side-effect analysis *p = *q + * * t

• Verification– No null dereferences– No memory leaks

Page 11: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Iterative Program Analysis

• Start by optimistically assuming that nothing is wrong– No aliases– No points-to set– Empty sets of shape graphs

• At every iteration apply the abstract meaning of programming language statements and add more aliases/points-to/shape graphs

• Stop when no changes occur

Page 12: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Iterative Points-to Analysist= &a

y= &b

z= &c

p= &y p= &z

ta

ta, yb

ta, yb, z c, py

ta, yb, z c

ta, yb, z c, pz

ta, yb, z c, py, pz

ta, yb, z c ta, yb, z c*p= &t

Page 13: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Iterative Points-to Analysist= &a

y= &b

z= &c

p= &y p= &z

ta

ta, yb

ta, yb, z c, py ta, yb, z c, pz

ta, yb, z c, py, pz

*p= &tta, yb, z c, py, pz

ta, yb, z c, py, pz, ya, za ta, yb, z c, py, pz, ya, za

Page 14: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Iterative Points-to Analysist= &a

y= &b

z= &c

p= &y p= &z

ta

ta, yb

ta, yb, z c, py, pz

*p= &tta, yb, z c, py, pz

ta, yb, z c, py, pz, ya, za ta, yb, z c, py, pz, ya, za

ta, yb, z c, py, ya, za ta, yb, z c, pz, ya, za

Page 15: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Iterative Points-to Analysist= &a

y= &b

z= &c

p= &y p= &z

ta

ta, yb

*p= &tta, yb, z c, py, pz, ya, za

ta, yb, z c, py, pz, ya, za ta, yb, z c, py, pz, ya, za

ta, yb, z c, py, ya, za ta, yb, z c, pz, ya, za

ta, yb, z c, py, pz, ya, za

Page 16: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Iterative Shape Analysis

t

x

n

x

t n

x

tn n

xtt

x

ntt

nt

x

t

x

t

xempty

x

tn

n

x

tn

n

n

x

tn

t n

xn

x

tn

nreturn x

x = t

t =malloc(..);

tnext=x;

x = NULL

TF

Page 17: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Soundness

• Every alias is detected

• Every points-to fact is detected

• Every potential shape is detected

• Every potential bug is detected

• Every enabled optimization is correct

Page 18: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Dimensions of program analysis

• Flow sensitive

• Context sensitive

Page 19: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Material on Pointer Analysis

• Alias Analysis

• Points-to Analysis

• Shape Analysis

• Applications

Page 20: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Giving a presentation

Ian Parbery

Page 21: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

How to give a presentation

• What to say and how to say it

• Getting through the audience

• Visual aids

Page 22: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

What to say and how to say it

• Communicate the Key Ideas• Don’t get bogged down in Details

– The best talk make you read the paper

• Structure your talk• Use Top-Down approach

– Introduction– Body– [Technicalities]– The Conclusion

Use Examples

Page 23: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Introduction

• Define the problem

• Motivate the audience

• Introduce terminology

• Discuss earlier work

• Emphasize the contributions

• [Provide a road map]

Use Examples

Page 24: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

The body

• Abstract the major results

• Explain the significance of the results

• Explain the main techniques

• Use enlightening examples

• Demonstrations are welcome

Page 25: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

[Technicalities]

• Expert only part

• Show something really interesting beyond the paper/tool

Page 26: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

The Conclusion

• Hindsight is clearer than Foresight

• Give open problems/further work

• Indicate that your talk is over

Page 27: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Know your audience

• Background

Page 28: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Getting through the Audience

• Use Repetitions

• Remind, don’t assume

• Don’t over-run

• Maintain Eye Contact

• Control your voice

• Control your motion

• Take care of your appearance

Page 29: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Visual Aids

• PowerPoint transparencies

• Don’t overload transparencies

• Don’t use too many transparencies

• Use Overlays Properly

• Use Color Effectively

• Use Pictures and Tables

• The blackboard can be used too

Page 30: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Don’t overload transparencies

• The input of the program can be arbitrary.

• Let x be a prime number, i.e., all the numbers z<x do not divide x. y be the next prime number, i.e., etc.

• Arbitrary input• Prime number x

– The next prime y

Page 31: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Use overlays (im)properly

• Item 1– Item 1.1– Item 1.2

• Item 2– Item 2.1

• Item 2.1.1

Page 32: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

Use colors properly

• Item 1

• Item 2

• Item 3

Page 33: Pointer and Shape Analysis Seminar msagiv/courses/shape.html Mooly Sagiv Schriber 317 msagiv@post Office Hours Thursday 15-16.

http://www.cs.tau.ac.il/~msagiv/courses/shape.html