170
Liveness Based Pointer Analysis Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay October 2012

Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

  • Upload
    others

  • View
    11

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

Liveness Based Pointer Analysis

Uday Khedker

(Joint Work with Alan Mycroft and Prashant Singh Rawat)

Department of Computer Science and Engineering,

Indian Institute of Technology, Bombay

October 2012

Page 2: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Outline 1/38

Outline

• Introduction

• Background

• Formulating LFCPA

(Liveness based Flow and Context Sensitive Points-to Analysis)

• Performing interprocedural analysis

• Measurements

• Conclusions

Reference:Uday P. Khedker, Alan Mycroft, Prashant Singh Rawat. Liveness Based Pointer

Anaysis. SAS 2012.

Uday Khedker IIT Bombay

Page 3: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

Part 1

Introduction

Page 4: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Introduction 2/38

Why Pointer Analysis?

• Pointer analysis collects information about indirect accesses in programs

◮ Enables precise data analysis◮ Enable precise interprocedural control flow analysis

• Needs to scale to large programs for practical usefulness

• Good pointer information could improve many applications of programanalysis significantly

Uday Khedker IIT Bombay

Page 5: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Introduction 3/38

Pointer Analysis Musings

• Two Position Papers

• A Keynote Address

Uday Khedker IIT Bombay

Page 6: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Introduction 3/38

Pointer Analysis Musings

• Two Position Papers

◮ Which Pointer Analysis should I Use?Michael Hind and Anthony Pioli, ISTAA 2000

◮ Pointer Analysis: Haven’t we solved this problem yet?Michael Hind, PASTE 2001

• A Keynote Address

Uday Khedker IIT Bombay

Page 7: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Introduction 3/38

Pointer Analysis Musings

• Two Position Papers

◮ Which Pointer Analysis should I Use?Michael Hind and Anthony Pioli, ISTAA 2000

◮ Pointer Analysis: Haven’t we solved this problem yet?Michael Hind, PASTE 2001

• A Keynote Address

◮ “The Worst thing that has happened to Computer Science is Cbecause it brought pointers with it”Frances Allen, IITK Workshop, 2007

Uday Khedker IIT Bombay

Page 8: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Introduction 3/38

Pointer Analysis Musings

• Two Position Papers

◮ Which Pointer Analysis should I Use?Michael Hind and Anthony Pioli, ISTAA 2000

◮ Pointer Analysis: Haven’t we solved this problem yet?Michael Hind, PASTE 2001

• A Keynote Address

◮ “The Worst thing that has happened to Computer Science is Cbecause it brought pointers with it”Frances Allen, IITK Workshop, 2007

• 2012 . . .

Uday Khedker IIT Bombay

Page 9: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Introduction 4/38

The Mathematics of Pointer Analysis

In the most general situation

• Alias analysis is undecidable.

Landi-Ryder [POPL 1991], Landi [LOPLAS 1992],Ramalingam [TOPLAS 1994]

• Flow insensitive alias analysis is NP-hard

Horwitz [TOPLAS 1997]

• Points-to analysis is undecidable

Chakravarty [POPL 2003]

Uday Khedker IIT Bombay

Page 10: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Introduction 4/38

The Mathematics of Pointer Analysis

In the most general situation

• Alias analysis is undecidable.

Landi-Ryder [POPL 1991], Landi [LOPLAS 1992],Ramalingam [TOPLAS 1994]

• Flow insensitive alias analysis is NP-hard

Horwitz [TOPLAS 1997]

• Points-to analysis is undecidable

Chakravarty [POPL 2003]

Adjust your expectations suitably to avoid disappointments!

Uday Khedker IIT Bombay

Page 11: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Introduction 5/38

The Engineering of Pointer Analysis

So what should we expect?

Uday Khedker IIT Bombay

Page 12: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Introduction 5/38

The Engineering of Pointer Analysis

So what should we expect? To quote Hind [PASTE 2001]

Uday Khedker IIT Bombay

Page 13: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Introduction 5/38

The Engineering of Pointer Analysis

So what should we expect? To quote Hind [PASTE 2001]

• “Fortunately many approximations exist”

Uday Khedker IIT Bombay

Page 14: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Introduction 5/38

The Engineering of Pointer Analysis

So what should we expect? To quote Hind [PASTE 2001]

• “Fortunately many approximations exist”

• “Unfortunately too many approximations exist!”

Uday Khedker IIT Bombay

Page 15: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Introduction 5/38

The Engineering of Pointer Analysis

So what should we expect? To quote Hind [PASTE 2001]

• “Fortunately many approximations exist”

• “Unfortunately too many approximations exist!”

Engineering of pointer analysis is much more dominant than its science

Uday Khedker IIT Bombay

Page 16: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Introduction 6/38

Pointer Analysis: Engineering or Science?

• Engineering view

• Science view

Uday Khedker IIT Bombay

Page 17: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Introduction 6/38

Pointer Analysis: Engineering or Science?

• Engineering view

◮ Build quick approximations◮ The tyranny of (exclusive) OR!

Precision OR Efficiency?

• Science view

Uday Khedker IIT Bombay

Page 18: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Introduction 6/38

Pointer Analysis: Engineering or Science?

• Engineering view

◮ Build quick approximations◮ The tyranny of (exclusive) OR!

Precision OR Efficiency?

• Science view

◮ Build clean abstractions◮ Can we harness the Genius of AND?

Precision AND Efficiency?

Uday Khedker IIT Bombay

Page 19: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Introduction 7/38

The Scope of Our Points-to Analysis

Attribute Range of Options Our Scope

Categories ofdata pointers

Static (Globals)Stack (Locals, Formals)Heap

Static (Globals)Stack (Locals, Formals)

LevelIntraprocedural,Interprocedural Interprocedural

Flow Sensitivity Full, Partial, None Full

Context Sensitivity Full, Partial, None Full

• Heap and address escaping locals are handled conservatively

• Data flow information is safe but may be imprecise

Uday Khedker IIT Bombay

Page 20: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

Part 2

Background

Page 21: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 8/38

An Example of Flow Insensitive Points-to Analysis(Andersen’s Approach aka Inclusion Based Approach)

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

Uday Khedker IIT Bombay

Page 22: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 8/38

An Example of Flow Insensitive Points-to Analysis(Andersen’s Approach aka Inclusion Based Approach)

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x

Points-to Graph

y z u

• x “points-to” y

• y “points-to” z

• z “points-to” u

Constraints onPoints-to Sets

Px ⊇ {y}Py ⊇ {z}Pz ⊇ {u}

Uday Khedker IIT Bombay

Page 23: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 8/38

An Example of Flow Insensitive Points-to Analysis(Andersen’s Approach aka Inclusion Based Approach)

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x

Points-to Graph

y z u

• Pointees of z shouldpoint to pointees of yalso

• u should point to z

Constraints onPoints-to Sets

Px ⊇ {y}Py ⊇ {z}Pz ⊇ {u}

∀w ∈ Pz , Pw ⊇ Py

Uday Khedker IIT Bombay

Page 24: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 8/38

An Example of Flow Insensitive Points-to Analysis(Andersen’s Approach aka Inclusion Based Approach)

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x

Points-to Graph

y z u

Constraints onPoints-to Sets

Px ⊇ {y}Py ⊇ {z}Pz ⊇ {u}

∀w ∈ Pz , Pw ⊇ Py

Uday Khedker IIT Bombay

Page 25: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 8/38

An Example of Flow Insensitive Points-to Analysis(Andersen’s Approach aka Inclusion Based Approach)

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x

Points-to Graph

y z u

• z should point topointees of y

• z should point to z

Constraints onPoints-to Sets

Px ⊇ {y}Py ⊇ {z}Pz ⊇ {u}

∀w ∈ Pz , Pw ⊇ Py

Pz ⊇ Py

Uday Khedker IIT Bombay

Page 26: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 8/38

An Example of Flow Insensitive Points-to Analysis(Andersen’s Approach aka Inclusion Based Approach)

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x

Points-to Graph

y z u

Constraints onPoints-to Sets

Px ⊇ {y}Py ⊇ {z}Pz ⊇ {u}

∀w ∈ Pz , Pw ⊇ Py

Pz ⊇ Py

Uday Khedker IIT Bombay

Page 27: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 8/38

An Example of Flow Insensitive Points-to Analysis(Andersen’s Approach aka Inclusion Based Approach)

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x

Points-to Graph

y z u

• y should point to xalso

Constraints onPoints-to Sets

Px ⊇ {y}Py ⊇ {z}Pz ⊇ {u}

∀w ∈ Pz , Pw ⊇ Py

Pz ⊇ Py

Py ⊇ {x}

Uday Khedker IIT Bombay

Page 28: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 8/38

An Example of Flow Insensitive Points-to Analysis(Andersen’s Approach aka Inclusion Based Approach)

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x

Points-to Graph

y z u

Constraints onPoints-to Sets

Px ⊇ {y}Py ⊇ {z}Pz ⊇ {u}

∀w ∈ Pz , Pw ⊇ Py

Pz ⊇ Py

Py ⊇ {x}

Uday Khedker IIT Bombay

Page 29: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 8/38

An Example of Flow Insensitive Points-to Analysis(Andersen’s Approach aka Inclusion Based Approach)

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x

Points-to Graph

y z u

• z and its pointeesshould point to newpointee of y also

• u and z should pointto x

Constraints onPoints-to Sets

Px ⊇ {y}Py ⊇ {z}Pz ⊇ {u}

∀w ∈ Pz , Pw ⊇ Py

Pz ⊇ Py

Py ⊇ {x}

Uday Khedker IIT Bombay

Page 30: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 8/38

An Example of Flow Insensitive Points-to Analysis(Andersen’s Approach aka Inclusion Based Approach)

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x

Points-to Graph

y z u

Constraints onPoints-to Sets

Px ⊇ {y}Py ⊇ {z}Pz ⊇ {u}

∀w ∈ Pz , Pw ⊇ Py

Pz ⊇ Py

Py ⊇ {x}

Uday Khedker IIT Bombay

Page 31: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 8/38

An Example of Flow Insensitive Points-to Analysis(Andersen’s Approach aka Inclusion Based Approach)

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x

Points-to Graph

y z u

• Pointees of z shouldpoint to pointees of y

• x should point toitself and z

Constraints onPoints-to Sets

Px ⊇ {y}Py ⊇ {z}Pz ⊇ {u}

∀w ∈ Pz , Pw ⊇ Py

Pz ⊇ Py

Py ⊇ {x}

Uday Khedker IIT Bombay

Page 32: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 8/38

An Example of Flow Insensitive Points-to Analysis(Andersen’s Approach aka Inclusion Based Approach)

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x

Points-to Graph

y z u

Constraints onPoints-to Sets

Px ⊇ {y}Py ⊇ {z}Pz ⊇ {u}

∀w ∈ Pz , Pw ⊇ Py

Pz ⊇ Py

Py ⊇ {x}

Uday Khedker IIT Bombay

Page 33: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 9/38

An Example of Flow Insensitive Points-to Analysis(Steensgaard’s Approach aka Equality Based Approach)

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

• Treat all pointees of apointer as “equivalent”locations

• Transitive closure

Pointees of allequivalent locationsbecome equivalent

Uday Khedker IIT Bombay

Page 34: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 9/38

An Example of Flow Insensitive Points-to Analysis(Steensgaard’s Approach aka Equality Based Approach)

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

Andersen’s Points-to Graph

x y z u

• Treat all pointees of apointer as “equivalent”locations

• Transitive closure

Pointees of allequivalent locationsbecome equivalent

Effective additionalconstraints

Unify (x , y)(pointees of x)

Unify (x , z)(pointees of y)

Unify (x , u)(pointees of z)

Uday Khedker IIT Bombay

Page 35: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 9/38

An Example of Flow Insensitive Points-to Analysis(Steensgaard’s Approach aka Equality Based Approach)

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

Andersen’s Points-to Graph

x y z u

• Treat all pointees of apointer as “equivalent”locations

• Transitive closure

Pointees of allequivalent locationsbecome equivalent

Effective additionalconstraints

Unify (x , y)(pointees of x)

Unify (x , z)(pointees of y)

Unify (x , u)(pointees of z)

⇒ x , y , z , u areequivalent

Uday Khedker IIT Bombay

Page 36: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 9/38

An Example of Flow Insensitive Points-to Analysis(Steensgaard’s Approach aka Equality Based Approach)

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

Steensgaard’s Points-to Graph

x y

z u

• Treat all pointees of apointer as “equivalent”locations

• Transitive closure

Pointees of allequivalent locationsbecome equivalent

Effective additionalconstraints

Unify (x , y)(pointees of x)

Unify (x , z)(pointees of y)

Unify (x , u)(pointees of z)

⇒ x , y , z , u areequivalent

⇒ Complete graph

Uday Khedker IIT Bombay

Page 37: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 10/38

An Example of Flow Sensitive Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

Uday Khedker IIT Bombay

Page 38: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 10/38

An Example of Flow Sensitive Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

Uday Khedker IIT Bombay

Page 39: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 10/38

An Example of Flow Sensitive Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x y z u

Uday Khedker IIT Bombay

Page 40: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 10/38

An Example of Flow Sensitive Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x y z u

x y z u

Uday Khedker IIT Bombay

Page 41: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 10/38

An Example of Flow Sensitive Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x y z u

x y z u x y z u

Uday Khedker IIT Bombay

Page 42: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 10/38

An Example of Flow Sensitive Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x y z u

x y z u x y z u

x y z u

Uday Khedker IIT Bombay

Page 43: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 10/38

An Example of Flow Sensitive Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x y z u

x y z u x y z u

x y z u x y z

Uday Khedker IIT Bombay

Page 44: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 10/38

An Example of Flow Sensitive Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x y z u

x y z u x y z u

x y z u x y z

x y z u

Uday Khedker IIT Bombay

Page 45: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 10/38

An Example of Flow Sensitive Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x y z u

x y z u x y z u

x y z u x y z

x y z u

x y z u

Uday Khedker IIT Bombay

Page 46: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 11/38

Flow Sensitive Points-to Analysis: May and Must Variants

a = &bb = &e1

c = &a2 c = &d3

∗c = &d∗a = &e4

∗c = e5

Uday Khedker IIT Bombay

Page 47: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 11/38

Flow Sensitive Points-to Analysis: May and Must Variants

a = &bb = &e1

c = &a2 c = &d3

∗c = &d∗a = &e4

∗c = e5

• c a b e at the entry of 4

Uday Khedker IIT Bombay

Page 48: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 11/38

Flow Sensitive Points-to Analysis: May and Must Variants

a = &bb = &e1

c = &a2 c = &d3

∗c = &d∗a = &e4

∗c = e5

• c a b e at the entry of 4

• Should a b be killed by assignment

∗c = &d?

Uday Khedker IIT Bombay

Page 49: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 11/38

Flow Sensitive Points-to Analysis: May and Must Variants

a = &bb = &e1

c = &a2 c = &d3

∗c = &d∗a = &e4

∗c = e5

• c a b e at the entry of 4

• Should a b be killed by assignment

∗c = &d?

No because c points to a along path1, 2, 4 but not along path 1, 3, 4

Uday Khedker IIT Bombay

Page 50: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 11/38

Flow Sensitive Points-to Analysis: May and Must Variants

a = &bb = &e1

c = &a2 c = &d3

∗c = &d∗a = &e4

∗c = e5

• c a b eMAYat the entry of 4

• Should a b be killed by assignment

∗c = &d?

No because c points to a along path1, 2, 4 but not along path 1, 3, 4

Uday Khedker IIT Bombay

Page 51: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 11/38

Flow Sensitive Points-to Analysis: May and Must Variants

a = &bb = &e1

c = &a2 c = &d3

∗c = &d∗a = &e4

∗c = e5

• c a b eMAYat the entry of 4

• Should a b be killed by assignment

∗c = &d?

No because c points to a along path1, 2, 4 but not along path 1, 3, 4

• Should b e be killed by assignment

∗a = &e?

Uday Khedker IIT Bombay

Page 52: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 11/38

Flow Sensitive Points-to Analysis: May and Must Variants

a = &bb = &e1

c = &a2 c = &d3

∗c = &d∗a = &e4

∗c = e5

• c a b eMAY MUSTat the entry of 4

• Should a b be killed by assignment

∗c = &d?

No because c points to a along path1, 2, 4 but not along path 1, 3, 4

• Should b e be killed by assignment

∗a = &e?

Yes because a points to b along both thepaths

Uday Khedker IIT Bombay

Page 53: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 11/38

Flow Sensitive Points-to Analysis: May and Must Variants

a = &bb = &e1

c = &a2 c = &d3

∗c = &d∗a = &e4

∗c = e5

• c a b eMAY MUSTat the entry of 4

• Should a b be killed by assignment

∗c = &d?

No because c points to a along path1, 2, 4 but not along path 1, 3, 4

• Should b e be killed by assignment

∗a = &e?

Yes because a points to b along both thepaths

• Must points-to information is required forkilling May points-to information

(and vice-versa)

Uday Khedker IIT Bombay

Page 54: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 12/38

Context Sensitivity in Interprocedural Analysis

Startr

Endr

Starts

a = &b

Ends

Ci

Ri

ci

Startt

c = &d

Endt

Cj

Rj

cj

fr

Uday Khedker IIT Bombay

Page 55: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 12/38

Context Sensitivity in Interprocedural Analysis

Startr

Endr

Starts

a = &b

Ends

Ci

Ri

ci

Startt

c = &d

Endt

Cj

Rj

cj

fr

a b

Uday Khedker IIT Bombay

Page 56: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 12/38

Context Sensitivity in Interprocedural Analysis

Startr

Endr

Starts

a = &b

Ends

Ci

Ri

ci

Startt

c = &d

Endt

Cj

Rj

cj

fr

a b

a b

Uday Khedker IIT Bombay

Page 57: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 12/38

Context Sensitivity in Interprocedural Analysis

Startr

Endr

Starts

a = &b

Ends

Ci

Ri

ci

Startt

c = &d

Endt

Cj

Rj

cj

fr

a b

a b

c d

Uday Khedker IIT Bombay

Page 58: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 12/38

Context Sensitivity in Interprocedural Analysis

Startr

Endr

Starts

a = &b

Ends

Ci

Ri

ci

Startt

c = &d

Endt

Cj

Rj

cj

fr

a b

a b

c d

c d

Uday Khedker IIT Bombay

Page 59: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 12/38

Context Sensitivity in Interprocedural Analysis

Startr

Endr

Starts

a = &b

Ends

Ci

Ri

ci

Startt

c = &d

Endt

Cj

Rj

cj

fr

a b

a b

c d

c d

Uday Khedker IIT Bombay

Page 60: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 12/38

Context Sensitivity in Interprocedural Analysis

Startr

Endr

Starts

a = &b

Ends

Ci

Ri

ci

Startt

c = &d

Endt

Cj

Rj

cj

fr

a b

a b

c d

c d

a b××

Uday Khedker IIT Bombay

Page 61: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 12/38

Context Sensitivity in Interprocedural Analysis

Startr

Endr

Starts

a = &b

Ends

Ci

Ri

ci

Startt

c = &d

Endt

Cj

Rj

cj

fr

a b

a b

c d

c d

Uday Khedker IIT Bombay

Page 62: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 12/38

Context Sensitivity in Interprocedural Analysis

Startr

Endr

Starts

a = &b

Ends

Ci

Ri

ci

Startt

c = &d

Endt

Cj

Rj

cj

fr

a b

a b

c d

c d

c d× ×

Uday Khedker IIT Bombay

Page 63: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 12/38

Context Sensitivity in Interprocedural Analysis

Startr

Endr

Starts

a = &b

Ends

Ci

Ri

ci

Startt

c = &d

Endt

Cj

Rj

cj

fr

a b

a b

c d

c d

a b c d

Uday Khedker IIT Bombay

Page 64: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 13/38

Context Sensitivity in the Presence of Recursion

Starts

Ci

Ri

Ends

call (c)

return (r)

stopcalling (s)

Uday Khedker IIT Bombay

Page 65: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 13/38

Context Sensitivity in the Presence of Recursion

Starts

Ci

Ri

Ends

call (c)

return (r)

stopcalling (s)

• Paths from Starts to Ends shouldconstitute a context free language cnsrn

Uday Khedker IIT Bombay

Page 66: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 13/38

Context Sensitivity in the Presence of Recursion

Starts

Ci

Ri

Ends

call (c)

return (r)

stopcalling (s)

• Paths from Starts to Ends shouldconstitute a context free language cnsrn

• Many interprocedural analyses treatcycle of recursion as an SCC andapproximate paths by a regular languagec∗sr∗

Uday Khedker IIT Bombay

Page 67: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 13/38

Context Sensitivity in the Presence of Recursion

Starts

Ci

Ri

Ends

call (c)

return (r)

stopcalling (s)

• Paths from Starts to Ends shouldconstitute a context free language cnsrn

• Many interprocedural analyses treatcycle of recursion as an SCC andapproximate paths by a regular languagec∗sr∗

• We do not know any practical points-toanalysis that is fully context sensitive

Most context sensitive approaches

Uday Khedker IIT Bombay

Page 68: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 13/38

Context Sensitivity in the Presence of Recursion

Starts

Ci

Ri

Ends

call (c)

return (r)

stopcalling (s)

• Paths from Starts to Ends shouldconstitute a context free language cnsrn

• Many interprocedural analyses treatcycle of recursion as an SCC andapproximate paths by a regular languagec∗sr∗

• We do not know any practical points-toanalysis that is fully context sensitive

Most context sensitive approaches

◮ either do not consider recursion, or

Uday Khedker IIT Bombay

Page 69: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 13/38

Context Sensitivity in the Presence of Recursion

Starts

Ci

Ri

Ends

call (c)

return (r)

stopcalling (s)

• Paths from Starts to Ends shouldconstitute a context free language cnsrn

• Many interprocedural analyses treatcycle of recursion as an SCC andapproximate paths by a regular languagec∗sr∗

• We do not know any practical points-toanalysis that is fully context sensitive

Most context sensitive approaches

◮ either do not consider recursion, or◮ do not consider recursive pointer

manipulation (e.g. “p = ∗p”), or

Uday Khedker IIT Bombay

Page 70: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 13/38

Context Sensitivity in the Presence of Recursion

Starts

Ci

Ri

Ends

call (c)

return (r)

stopcalling (s)

• Paths from Starts to Ends shouldconstitute a context free language cnsrn

• Many interprocedural analyses treatcycle of recursion as an SCC andapproximate paths by a regular languagec∗sr∗

• We do not know any practical points-toanalysis that is fully context sensitive

Most context sensitive approaches

◮ either do not consider recursion, or◮ do not consider recursive pointer

manipulation (e.g. “p = ∗p”), or◮ are context insensitive in recursion

Uday Khedker IIT Bombay

Page 71: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 14/38

Pointer Analysis: An Engineer’s Landscape

Flow

Sensitivity

Increases

Context SensitivityIncreases

FI=

FFS

CI FCS

Uday Khedker IIT Bombay

Page 72: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 14/38

Pointer Analysis: An Engineer’s Landscape

Flow

Sensitivity

Increases

Context SensitivityIncreases

CI FCSFI=

FI⊆

FISSA

FSNoKill

FFS

Uday Khedker IIT Bombay

Page 73: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 14/38

Pointer Analysis: An Engineer’s Landscape

Flow

Sensitivity

Increases

Context SensitivityIncreases

FI=

FI⊆

FISSA

FSNoKill

FFS

CI CIOS CSK-lim CSRI FCS

Uday Khedker IIT Bombay

Page 74: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 14/38

Pointer Analysis: An Engineer’s Landscape

Flow

Sensitivity

Increases

Context SensitivityIncreases

FI=

FI⊆

FISSA

FSNoKill

FFS

CI CIOS CSK-lim CSRI FCS

Data Structures: BDDs, probabilistic

Uday Khedker IIT Bombay

Page 75: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 14/38

Pointer Analysis: An Engineer’s Landscape

Flow

Sensitivity

Increases

Context SensitivityIncreases

FI=

FI⊆

FISSA

FSNoKill

FFS

CI CIOS CSK-lim CSRI FCS

Data Structures: BDDs, probabilisticMethods: parallel, on demand, randomized

Uday Khedker IIT Bombay

Page 76: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 14/38

Pointer Analysis: An Engineer’s Landscape

Flow

Sensitivity

Increases

Context SensitivityIncreases

FI=

FI⊆

FISSA

FSNoKill

FFS

CI CIOS CSK-lim CSRI FCS

Data Structures: BDDs, probabilisticMethods: parallel, on demand, randomized

Refinement: Levelwise, bootstrapping

Uday Khedker IIT Bombay

Page 77: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 14/38

Pointer Analysis: An Engineer’s Landscape

Flow

Sensitivity

Increases

Context SensitivityIncreases

FI=

FI⊆

FISSA

FSNoKill

FFS

CI CIOS CSK-lim CSRI FCS

Over Crowed Area

Data Structures: BDDs, probabilisticMethods: parallel, on demand, randomized

Refinement: Levelwise, bootstrapping

Uday Khedker IIT Bombay

Page 78: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 14/38

Pointer Analysis: An Engineer’s Landscape

Flow

Sensitivity

Increases

Context SensitivityIncreases

FI=

FI⊆

FISSA

FSNoKill

FFS

CI CIOS CSK-lim CSRI FCS

Over Crowed Area

StillVacant

Data Structures: BDDs, probabilisticMethods: parallel, on demand, randomized

Refinement: Levelwise, bootstrapping

Uday Khedker IIT Bombay

Page 79: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Background 14/38

Pointer Analysis: An Engineer’s Landscape

Flow

Sensitivity

Increases

Context SensitivityIncreases

FI=

FI⊆

FISSA

FSNoKill

FFS

CI CIOS CSK-lim CSRI FCS

Over Crowed Area

StillVacant

Data Structures: BDDs, probabilisticMethods: parallel, on demand, randomized

Refinement: Levelwise, bootstrapping

That’s thecorner we are trying to

occupy :-)

Uday Khedker IIT Bombay

Page 80: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

Part 3

Formulating LFCPA

Page 81: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 15/38

Our Motivating Example for Intraprocedural Formulation

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x y z u

x y z u x y z u

x y z u x y z

x y z u

x y z u

Uday Khedker IIT Bombay

Page 82: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 16/38

yIs All This Information Useful?y

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x y z u

x y z u

x y z u

x y z u

x y zx y z u

x y z u

Uday Khedker IIT Bombay

Page 83: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 16/38

yIs All This Information Useful?y

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x y z u

x y z u

x y z u

x y z u

x y zx y z u

x y z u

Uday Khedker IIT Bombay

Page 84: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 16/38

yIs All This Information Useful?y

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x y z u

x y z u

x y z u

x y z u

x y zx y z u

x y z u

Uday Khedker IIT Bombay

Page 85: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 16/38

yIs All This Information Useful?y

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x y z u

x y z u

x y z u

x y z u

x y zx y z u

x y z u

Uday Khedker IIT Bombay

Page 86: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 16/38

yIs All This Information Useful?y

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x y z u

x y z u

x y z u

x y z u

x y zx y z u

x y z u

Uday Khedker IIT Bombay

Page 87: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 16/38

yIs All This Information Useful?y

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2 n3 z = y n3

n4

y = &x

use u

use x

n4

x y z u

x y z u

x y z u

x y z u

x y zx y z u

x y z u

Uday Khedker IIT Bombay

Page 88: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 17/38

The L and P of LFCPA

Mutual dependence of liveness and points-to information

• Define points-to information only for live pointers

• For pointer indirections, define liveness information using points-toinformation

Uday Khedker IIT Bombay

Page 89: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 18/38

The F and C of LFCPA

• Use call strings method for full flow and context sensitivity

• Use value based termination of call strings construction for efficiency[Khedker, Karkare. CC 2008]

Uday Khedker IIT Bombay

Page 90: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 19/38

Use of Strong Liveness

• Simple liveness considers every use of a variable as useful

• Strong liveness checks the liveness of the result before declaring theoperands to be live

Uday Khedker IIT Bombay

Page 91: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 19/38

Use of Strong Liveness

• Simple liveness considers every use of a variable as useful

• Strong liveness checks the liveness of the result before declaring theoperands to be live

• Strong liveness is more precise than simple liveness

Uday Khedker IIT Bombay

Page 92: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 20/38

Data Flow Equations

Loutn =

∅ n is Endp⋃

s∈succ(n)

Lins otherwise

Linn =(

Loutn − Killn

)

∪ Refn

Ainn =

Linn×{?} n is Startp

p∈pred(n)

Aoutp

Linn

otherwise

Aoutn =

(

(

Ainn −(

Killn ×V))

∪(

Defn × Pointeen

)

)∣

Loutn

• Lin/Lout : set of Live pointers, Ain/Aout: sets of mAy points-to pairs

Uday Khedker IIT Bombay

Page 93: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 20/38

Data Flow Equations

Loutn =

∅ n is Endp⋃

s∈succ(n)

Lins otherwise

Linn =(

Loutn − Killn

)

∪ Refn

Ainn =

Linn×{?} n is Startp

p∈pred(n)

Aoutp

Linn

otherwise

Aoutn =

(

(

Ainn −(

Killn ×V))

∪(

Defn × Pointeen

)

)∣

Loutn

• Lin/Lout : set of Live pointers, Ain/Aout: sets of mAy points-to pairs

• Refn, Killn, Defn, and Pointeen are defined in terms of Ainn

Uday Khedker IIT Bombay

Page 94: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 20/38

Data Flow Equations

Loutn =

∅ n is Endp⋃

s∈succ(n)

Lins otherwise

Linn =(

Loutn − Killn

)

∪ Refn

Ainn =

Linn×{?} n is Startp

p∈pred(n)

Aoutp

Linn

otherwise

Aoutn =

(

(

Ainn −(

Killn ×V))

∪(

Defn × Pointeen

)

)∣

Loutn

• Lin/Lout : set of Live pointers, Ain/Aout: sets of mAy points-to pairs

• Refn, Killn, Defn, and Pointeen are defined in terms of Ainn

Refn isdefined in terms

of Loutn

Uday Khedker IIT Bombay

Page 95: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 20/38

Data Flow Equations

Loutn =

∅ n is Endp⋃

s∈succ(n)

Lins otherwise

Linn =(

Loutn − Killn

)

∪ Refn

Ainn =

Linn×{?} n is Startp

p∈pred(n)

Aoutp

Linn

otherwise

Aoutn =

(

(

Ainn −(

Killn ×V))

∪(

Defn × Pointeen

)

)∣

Loutn

• Lin/Lout : set of Live pointers, Ain/Aout: sets of mAy points-to pairs

• Refn, Killn, Defn, and Pointeen are defined in terms of Ainn

Ainn and Aoutnare restricted toLinn and Loutn

Uday Khedker IIT Bombay

Page 96: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 20/38

Data Flow Equations

Loutn =

∅ n is Endp⋃

s∈succ(n)

Lins otherwise

Linn =(

Loutn − Killn

)

∪ Refn

Ainn =

Linn×{?} n is Startp

p∈pred(n)

Aoutp

Linn

otherwise

Aoutn =

(

(

Ainn −(

Killn ×V))

∪(

Defn × Pointeen

)

)∣

Loutn

• Lin/Lout : set of Live pointers, Ain/Aout: sets of mAy points-to pairs

• Refn, Killn, Defn, and Pointeen are defined in terms of Ainn

Uday Khedker IIT Bombay

Page 97: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 21/38

Motivating Example Revisited

• For convenience, we show complete sweeps of liveness and points-toanalysis repeatedly

• This is not required by the computation

• The data flow equations define a single fixed point computation

Uday Khedker IIT Bombay

Page 98: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 22/38

First Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

Uday Khedker IIT Bombay

Page 99: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 22/38

First Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

LivenessAnalysis

Uday Khedker IIT Bombay

Page 100: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 22/38

First Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

LivenessAnalysis

{u, x}

Uday Khedker IIT Bombay

Page 101: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 22/38

First Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

LivenessAnalysis

{u, x}

{u, x}{u, x}

Uday Khedker IIT Bombay

Page 102: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 22/38

First Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

LivenessAnalysis

{u, x}

{u, x}{u, x}

{z} {u, x}

Uday Khedker IIT Bombay

Page 103: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 22/38

First Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

LivenessAnalysis

{u, x}

{u, x}{u, x}

{z} {u, x}

Strong liveness:y is not madelive because zis not live

Uday Khedker IIT Bombay

Page 104: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 22/38

First Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

LivenessAnalysis

{u, x}

{u, x}{u, x}

{z} {u, x}

{u, x , z}

Uday Khedker IIT Bombay

Page 105: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 22/38

First Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

LivenessAnalysis

{u, x}

{u, x}{u, x}

{z} {u, x}

{u, x , z}

{u}

Uday Khedker IIT Bombay

Page 106: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 22/38

First Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

Points-toAnalysis

{u, x}

{u, x}{u, x}

{z} {u, x}

{u, x , z}

{u}

Uday Khedker IIT Bombay

Page 107: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 22/38

First Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

Points-toAnalysis

{u, x}

{u, x}{u, x}

{z} {u, x}

{u, x , z}

{u} u ?

Uday Khedker IIT Bombay

Page 108: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 22/38

First Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

Points-toAnalysis

{u, x}

{u, x}{u, x}

{z} {u, x}

{u, x , z}

{u} u ?

x y z u ?

Uday Khedker IIT Bombay

Page 109: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 22/38

First Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

Points-toAnalysis

{u, x}

{u, x}{u, x}

{z} {u, x}

{u, x , z}

{u} u ?

x y z u ?

x y u ?

Uday Khedker IIT Bombay

Page 110: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 22/38

First Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

Points-toAnalysis

{u, x}

{u, x}{u, x}

{z} {u, x}

{u, x , z}

{u} u ?

x y z u ?

x y u ?

x y u ?

Uday Khedker IIT Bombay

Page 111: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 22/38

First Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

Points-toAnalysis

{u, x}

{u, x}{u, x}

{z} {u, x}

{u, x , z}

{u} u ?

x y z u ?

x y u ?

x y u ?

z u

Uday Khedker IIT Bombay

Page 112: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 22/38

First Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

Points-toAnalysis

{u, x}

{u, x}{u, x}

{z} {u, x}

{u, x , z}

{u} u ?

x y z u ?

x y u ?

x y u ?

z u

??

Uday Khedker IIT Bombay

Page 113: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 22/38

First Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

Points-toAnalysis

{u, x}

{u, x}{u, x}

{z} {u, x}

{u, x , z}

{u} u ?

x y z u ?

x y u ?

x y u ?

z u

??

x y u ?

Uday Khedker IIT Bombay

Page 114: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 23/38

Second Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

{u, x}

{u, x}{u, x}

{u, x}

{u} u ?

x y u ?

x y u ?

{z}z u

{u, x , z} x y z u ?

x y u ?

Uday Khedker IIT Bombay

Page 115: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 23/38

Second Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

LivenessAnalysis

{u, x}

{u, x}{u, x}

{u, x}

{u} u ?

x y u ?

x y u ?

{x , y ,z}

{u, x , z} x y z u ?

z u

x y u ?

Uday Khedker IIT Bombay

Page 116: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 23/38

Second Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

LivenessAnalysis

{u, x}

{u, x}{u, x}

{u, x}

{u} u ?

x y u ?

x y u ?

{x , y ,z}

{u, x , y ,z} x y z u ?

z u

x y u ?

Uday Khedker IIT Bombay

Page 117: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 23/38

Second Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

Points-toAnalysis

{u, x}

{u, x}{u, x}

{u, x}

{u} u ?

x y u ?

x y u ?

{x , y ,z}

{u, x , y ,z} x y z u ?

z u

x y u ?

Uday Khedker IIT Bombay

Page 118: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 23/38

Second Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

Points-toAnalysis

{u, x}

{u, x}{u, x}

{u, x}

{u} u ?

x y u ?

x y u ?

{x , y ,z}

{u, x , y ,z} x y z u ?

x y z u

x y u ?

Uday Khedker IIT Bombay

Page 119: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 23/38

Second Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

Points-toAnalysis

{u, x}

{u, x}{u, x}

{u, x}

{u} u ?

x y u ?

x y u ?

{x , y ,z}

{u, x , y ,z} x y z u ?

x y z u

x y z u

x y u ?

Uday Khedker IIT Bombay

Page 120: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 23/38

Second Round of Liveness Analysis and Points-to Analysis

n1

x = &y

y = &z

z = &u

n1

n2 ∗z = y n2n3 z = y n3

n4

y = &x

use u

use x

n4

Points-toAnalysis

{u, x}

{u, x}{u, x}

{u, x}

{u} u ?

x y u ?

x y u ?

{x , y ,z}

{u, x , y ,z} x y z u ?

x y z u

x y z u

x y z u ?

Uday Khedker IIT Bombay

Page 121: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 24/38

Discovering Must Points-to Information from May Points-toInformation

a = &bb = &e1

c = &a2 c = &d3

∗c = &d∗a = &e4

∗c = e5

Uday Khedker IIT Bombay

Page 122: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 24/38

Discovering Must Points-to Information from May Points-toInformation

a = &bb = &e1

c = &a2 c = &d3

∗c = &d∗a = &e4

∗c = e5

• c is live at program entry

Uday Khedker IIT Bombay

Page 123: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 24/38

Discovering Must Points-to Information from May Points-toInformation

a = &bb = &e1

c = &a2 c = &d3

∗c = &d∗a = &e4

∗c = e5

c ?

• c is live at program entry

• Assume that c points to “?” atprogram entry

Uday Khedker IIT Bombay

Page 124: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 24/38

Discovering Must Points-to Information from May Points-toInformation

a = &bb = &e1

c = &a2 c = &d3

∗c = &d∗a = &e4

∗c = e5

c ?

c ?

a b e• c is live at program entry

• Assume that c points to “?” atprogram entry

• Perform usual may points-toanalysis

Uday Khedker IIT Bombay

Page 125: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 24/38

Discovering Must Points-to Information from May Points-toInformation

a = &bb = &e1

c = &a2 c = &d3

∗c = &d∗a = &e4

∗c = e5

c ?

c ?

a b e

c ?

a b e• c is live at program entry

• Assume that c points to “?” atprogram entry

• Perform usual may points-toanalysis

Uday Khedker IIT Bombay

Page 126: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 24/38

Discovering Must Points-to Information from May Points-toInformation

a = &bb = &e1

c = &a2 c = &d3

∗c = &d∗a = &e4

∗c = e5

c ?

c ?

a b e

c ?

a b e

c a b e

?

• c is live at program entry

• Assume that c points to “?” atprogram entry

• Perform usual may points-toanalysis

Uday Khedker IIT Bombay

Page 127: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 24/38

Discovering Must Points-to Information from May Points-toInformation

a = &bb = &e1

c = &a2 c = &d3

∗c = &d∗a = &e4

∗c = e5

c ?

c ?

a b e

c ?

a b e

c a b e

?

• c is live at program entry

• Assume that c points to “?” atprogram entry

• Perform usual may points-toanalysis

• Since c has multiple pointees, itis a MAY relation

Uday Khedker IIT Bombay

Page 128: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Formulating LFCPA 24/38

Discovering Must Points-to Information from May Points-toInformation

a = &bb = &e1

c = &a2 c = &d3

∗c = &d∗a = &e4

∗c = e5

c ?

c ?

a b e

c ?

a b e

c a b e

?

• c is live at program entry

• Assume that c points to “?” atprogram entry

• Perform usual may points-toanalysis

• Since c has multiple pointees, itis a MAY relation

• Since a has a single pointee, itis a MUST relation

Uday Khedker IIT Bombay

Page 129: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

Part 4

Interprocedural Analysis

Page 130: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Interprocedural Analysis 25/38

Call Strings Method Using Value Based Termination

• The classical Sharir-Pnueli call string method with a small change inthe termination criteria

◮ Classical approach [Sharir, Pnueli. 1981]Construct all call strings upto the length K · (|L|+ 1)2

◦ L is the lattice of data flow values and K is the maximum number ofdistinct call sites in any call chain

◦ This bound is for general frameworks. For simpler frameworks suchas separable or bit vector frameworks, the bounds are smaller

◮ Our approach [Khedker, Karkare. 2008]Use equivalence of data flow values

Uday Khedker IIT Bombay

Page 131: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Interprocedural Analysis 26/38

A Points-to Analysis Example to Show the Difference

main()

{ x = &y;

z = &x;

y = &z;

p(); /* C1 */

}

p()

{ if (...)

{ p(); /* C2 */

x = *x;

}

}

• Number of distinct call sites in a call chainK = 2.

• Number of variables: 3

• Number of distinct points-to pairs: 3× 3 = 9

• L is powerset of all points-to pairs

• | L |= 29

• Length of the longest call string inSharir-Pnueli method2× (|L|+ 1)2 = 219 + 210 + 1 = 5, 25, 313

• All call strings upto this length must beconstructed by the Sharir-Pnueli method!

Uday Khedker IIT Bombay

Page 132: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Interprocedural Analysis 26/38

A Points-to Analysis Example to Show the Difference

main()

{ x = &y;

z = &x;

y = &z;

p(); /* C1 */

}

p()

{ if (...)

{ p(); /* C2 */

x = *x;

}

}

• Value based termination requires only threecall strings: λ, c1, and c1c2

Uday Khedker IIT Bombay

Page 133: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Interprocedural Analysis 27/38

Value Based Termination of Call String Construction

Startp

Endp

ProcedureBody

Uday Khedker IIT Bombay

Page 134: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Interprocedural Analysis 27/38

Value Based Termination of Call String Construction

Startp

Endp

σ0,x0

σ0,y0

• Context sensitive analysis retainsdistinct data values for eachcontext reaching a procedure

Uday Khedker IIT Bombay

Page 135: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Interprocedural Analysis 27/38

Value Based Termination of Call String Construction

Startp

Endp

σ0,x0

σ0,y0

σ1,x1

σ1,y1

• Context sensitive analysis retainsdistinct data values for eachcontext reaching a procedure

Uday Khedker IIT Bombay

Page 136: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Interprocedural Analysis 27/38

Value Based Termination of Call String Construction

Startp

Endp

σ0,x0

σ0,y0

σ1,x1

σ1,y1

x2

y2

σ2,x1

σ2,y1

• Context sensitive analysis retainsdistinct data values for eachcontext reaching a procedure

Uday Khedker IIT Bombay

Page 137: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Interprocedural Analysis 27/38

Value Based Termination of Call String Construction

Startp

Endp

σ0,x0

σ0,y0

σ1,x1

σ1,y1

x2

y2

σ2,x1

σ2,y1

σ3,x1

σ3,y1

• Context sensitive analysis retainsdistinct data values for eachcontext reaching a procedure

Uday Khedker IIT Bombay

Page 138: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Interprocedural Analysis 27/38

Value Based Termination of Call String Construction

Startp

Endp

σ0,x0

σ0,y0

σ1,x1

σ1,y1

x2

y2

σ2,x1

σ2,y1

σ3,x1

σ3,y1

σ4,x2

σ4,y2

• Context sensitive analysis retainsdistinct data values for eachcontext reaching a procedure

Uday Khedker IIT Bombay

Page 139: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Interprocedural Analysis 27/38

Value Based Termination of Call String Construction

Startp

Endp

σ0,x0

σ0,y0

σ1,x1

σ1,y1

x2

y2

σ2,x1

σ2,y1

σ3,x1

σ3,y1

σ4,x2

σ4,y2

• Context sensitive analysis retainsdistinct data values for eachcontext reaching a procedure

• Many data flow values could beidentical

Uday Khedker IIT Bombay

Page 140: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Interprocedural Analysis 27/38

Value Based Termination of Call String Construction

Startp

Endp

σ0,x0

σ0,y0

σ1,x1

y1

x2

y2

σ2,x1

y1

σ3,x1

y1

σ4,x2

σ4,y2

• Context sensitive analysis retainsdistinct data values for eachcontext reaching a procedure

• Many data flow values could beidentical

• It is sufficient to propagate asingle representative data flowvalue

Uday Khedker IIT Bombay

Page 141: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Interprocedural Analysis 27/38

Value Based Termination of Call String Construction

Startp

Endp

σ0,x0

σ0,y0

σ1,x1

σ1,y1

x2

y2

σ2,x1

σ2,y1

σ3,x1

σ3,y1

σ4,x2

σ4,y2

• Context sensitive analysis retainsdistinct data values for eachcontext reaching a procedure

• Many data flow values could beidentical

• It is sufficient to propagate asingle representative data flowvalue

• We only need to regenerate themissing contexts

Uday Khedker IIT Bombay

Page 142: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Interprocedural Analysis 27/38

Value Based Termination of Call String Construction

Startp

Endp

σ0,x0

σ0,y0

σ1,x1

σ1,y1

x2

y2

σ2,x1

σ2,y1

σ3,x1

σ3,y1

σ4,x2

σ4,y2

• Context sensitive analysis retainsdistinct data values for eachcontext reaching a procedure

• Many data flow values could beidentical

• It is sufficient to propagate asingle representative data flowvalue

• We only need to regenerate themissing contexts

• Much fewer call strings are passedon to the callees

Uday Khedker IIT Bombay

Page 143: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Interprocedural Analysis 27/38

Value Based Termination of Call String Construction

Startp

Endp

σ0,x0

σ0,y0

σ1,x1

σ1,y1

x2

y2

σ2,x1

σ2,y1

σ3,x1

σ3,y1

σ4,x2

σ4,y2

• Context sensitive analysis retainsdistinct data values for eachcontext reaching a procedure

• Many data flow values could beidentical

• It is sufficient to propagate asingle representative data flowvalue

• We only need to regenerate themissing contexts

• Much fewer call strings are passedon to the callees

The number of call strings is reduced without any loss of precision

Uday Khedker IIT Bombay

Page 144: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Interprocedural Analysis 28/38

Value Based Termination of Call String Construction

• Seem straight forward for non-recursive procedures

• What if a procedure is recursive?

Uday Khedker IIT Bombay

Page 145: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Interprocedural Analysis 28/38

Value Based Termination of Call String Construction

• Seem straight forward for non-recursive procedures

• What if a procedure is recursive?

• Read our CC 2008 paper, or my book, or my extra slides

Uday Khedker IIT Bombay

Page 146: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Interprocedural Analysis 28/38

Value Based Termination of Call String Construction

• Seem straight forward for non-recursive procedures

• What if a procedure is recursive?

• Read our CC 2008 paper, or my book, or my extra slides

• If none of it seems possible, invite me for another talk

Uday Khedker IIT Bombay

Page 147: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

Part 5

Measurements

Page 148: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Measurements 29/38

Implementation

• LTO framework of GCC 4.6.0

• Naive prototype implementation

(Points-to sets implemented using linked lists)

• Implemented FCPA without liveness for comparison

• Comparison with GCC’s flow and context insensitive method

• SPEC 2006 benchmarks

Uday Khedker IIT Bombay

Page 149: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Measurements 30/38

Analysis Time

Program kLoCCallSites

Time in millisecondsL-FCPA

FCPA GPTALiveness Points-to

lbm 0.9 33 0.55 0.52 1.9 5.2

mcf 1.6 29 1.04 0.62 9.5 3.4

libquantum 2.6 258 2.0 1.8 5.6 4.8

bzip2 3.7 233 4.5 4.8 28.1 30.2

parser 7.7 1123 1.2×103 145.6 4.3×105 422.12

sjeng 10.5 678 858.2 99.0 3.2×104 38.1

hmmer 20.6 1292 90.0 62.9 2.9×105 246.3

h264ref 36.0 1992 2.2×105 2.0×105 ? 4.3×103

Uday Khedker IIT Bombay

Page 150: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Measurements 31/38

Unique Points-to Pairs

Program kLoCCallSites

Unique points-to pairs

L-FCPA FCPA GPTA

lbm 0.9 33 12 507 1911

mcf 1.6 29 41 367 2159

libquantum 2.6 258 49 119 2701

bzip2 3.7 233 60 210 8.8×104

parser 7.7 1123 531 4196 1.9×104

sjeng 10.5 678 267 818 1.1×104

hmmer 20.6 1292 232 5805 1.9×106

h264ref 36.0 1992 1683 ? 1.6×107

Uday Khedker IIT Bombay

Page 151: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Measurements 32/38

Precise Context Information is Small and Sparse

Total No. and percentage of functions for call-string counts

Program no. of 0 call strings 1-4 call strings 5-8 call strings 9+ call strings

functions L-FCPA FCPA L-FCPA FCPA L-FCPA FCPA L-FCPA FCPA

lbm 2216 3 6 19

0 0 0 0(72.7%) (13.6%) (27.3%) (86.4%)

mcf 2516 3 9 22

0 0 0 0(64.0%) (12.0%) (36.0%) (88.0%)

bzip2 10088 38 12 62

0 0 0 0(88.0%) (38.0%) (12.0%) (62.0%)

libquantum 118100 56 17 62 1

0 0 0(84.7%) (47.5%) (14.4%) (52.5%) (0.8%)

sjeng 15196 37 43 45 12 15

054

(63.6%) (24.5%) (28.5%) (29.8%) (7.9%) (9.9%) (35.8%)

hmmer 584548 330 32 175 4 26

053

(93.8%) (56.5%) (5.5%) (30.0%) (0.7%) (4.5%) (9.1%)

parser 372246 76 118 135 4 63 4 98

(66.1%) (20.4%) (31.7%) (36.3%) (1.1%) (16.9%) (1.1%) (26.3%)

9+ call strings in L-FCPA: Tot 4, Min 10, Max 52, Mean 32.5, Median 29, Mode 10

h264ref 624351

?240

?14

?19

?(56.2%) (38.5%) (2.2%) (3.0%)

9+ call strings in L-FCPA: Tot 14, Min 9, Max 56, Mean 27.9, Median 24, Mode 9

Uday Khedker IIT Bombay

Page 152: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Measurements 33/38

Precise Usable Pointer Information is Small and Sparse

Total No. and percentage of basic blocks (BBs) for points-to (pt) pair counts

Program no. of 0 pt pairs 1-4 pt pairs 5-8 pt pairs 9+ pt pairs

BBs L-FCPA FCPA L-FCPA FCPA L-FCPA FCPA L-FCPA FCPA

lbm 252229 61 23 82

066

043

(90.9%) (24.2%) (9.1%) (32.5%) (26.2%) (17.1%)

mcf 472356 160 116 2

01

0309

(75.4%) (33.9%) (24.6%) (0.4%) (0.2%) (65.5%)

libquantum 16421520 793 119 796 3 46

07

(92.6%) (48.3%) (7.2%) (48.5%) (0.2%) (2.8%) (0.4%)

bzip2 27462624 1085 118 12 3 12 1 1637

(95.6%) (39.5%) (4.3%) (0.4%) (0.1%) (0.4%) (0.0%) (59.6%)

9+ pt pairs in L-FCPA: Tot 1, Min 12, Max 12, Mean 12.0, Median 12, Mode 12

sjeng 60004571 3239 1208 12 221 41

02708

(76.2%) (54.0%) (20.1%) (0.2%) (3.7%) (0.7%) (45.1%)

hmmer 1441813483 8357 896 21 24 91 15 5949

(93.5%) (58.0%) (6.2%) (0.1%) (0.2%) (0.6%) (0.1%) (41.3%)

9+ pt pairs in L-FCPA: Tot 6, Min 10, Max 16, Mean 13.3, Median 13, Mode 10

parser 68754823 1821 1591 25 252 154 209 4875

(70.2%) (26.5%) (23.1%) (0.4%) (3.7%) (2.2%) (3.0%) (70.9%)

9+ pt pairs in L-FCPA: Tot 13, Min 9, Max 53, Mean 27.9, Median 18, Mode 9

h264ref 2131513729

?4760

?2035

?791

?(64.4%) (22.3%) (9.5%) (3.7%)

9+ pt pairs in L-FCPA: Tot 44, Min 9, Max 98, Mean 36.3, Median 31, Mode 9

Uday Khedker IIT Bombay

Page 153: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

Part 6

Conclusions

Page 154: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Conclusions 34/38

Observations

• Usable pointer information is very small and sparse

• Data flow propagation in real programs seems to involve only a smallsubset of all possible data flow values

• Earlier approaches reported inefficiency and non-scalability because theycomputed far more information than the actual usable information

Uday Khedker IIT Bombay

Page 155: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Conclusions 35/38

Conclusions

• Building quick approximations and compromising on precision may not benecessary for efficiency

• Building clean abstractions to separate the necessary information fromredundant information is much more significant

Uday Khedker IIT Bombay

Page 156: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Conclusions 35/38

Conclusions

• Building quick approximations and compromising on precision may not benecessary for efficiency

• Building clean abstractions to separate the necessary information fromredundant information is much more significant

Our experience of points-to analysis shows that

◮ Use of liveness reduced the pointer information . . .◮ which reduced the number of contexts required . . .◮ which reduced the liveness and pointer information . . .

Uday Khedker IIT Bombay

Page 157: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Conclusions 35/38

Conclusions

• Building quick approximations and compromising on precision may not benecessary for efficiency

• Building clean abstractions to separate the necessary information fromredundant information is much more significant

Our experience of points-to analysis shows that

◮ Use of liveness reduced the pointer information . . .◮ which reduced the number of contexts required . . .◮ which reduced the liveness and pointer information . . .

• Approximations should come after building abstractions rather than before

Uday Khedker IIT Bombay

Page 158: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Conclusions 36/38

Future Work

• Redesign data structures by hiding them behind APIsCurrent version uses linked lists and linear search

• Incremental version

• Using precise pointer information in other passes in GCC

• Extend it to precise alias analysis of heap data

Uday Khedker IIT Bombay

Page 159: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Conclusions 37/38

Parting Thoughts: The Larger Perspective

exhaustivecomputation

computationrestrictedto usableinformation

incrementalcomputation

demand drivencomputation

Uday Khedker IIT Bombay

Page 160: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Conclusions 37/38

Parting Thoughts: The Larger Perspective

exhaustivecomputation

computationrestrictedto usableinformation

incrementalcomputation

demand drivencomputation

MaximumComputation

MinimumComputation

Uday Khedker IIT Bombay

Page 161: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Conclusions 37/38

Parting Thoughts: The Larger Perspective

exhaustivecomputation

computationrestrictedto usableinformation

incrementalcomputation

demand drivencomputation

MaximumComputation

MinimumComputation

EarlyComputation

LateComputation

Uday Khedker IIT Bombay

Page 162: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Conclusions 37/38

Parting Thoughts: The Larger Perspective

exhaustivecomputation

computationrestrictedto usableinformation

incrementalcomputation

demand drivencomputation

MaximumComputation

MinimumComputation

EarlyComputation

LateComputation

What should be computed?

When should it be computed?

Uday Khedker IIT Bombay

Page 163: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Conclusions 37/38

Parting Thoughts: The Larger Perspective

exhaustivecomputation

computationrestrictedto usableinformation

incrementalcomputation

demand drivencomputation

MaximumComputation

MinimumComputation

EarlyComputation

LateComputation

What should be computed?

When should it be computed?

Do not compute what you don’t need!

Who defines what is needed?

Uday Khedker IIT Bombay

Page 164: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Conclusions 37/38

Parting Thoughts: The Larger Perspective

exhaustivecomputation

computationrestrictedto usableinformation

incrementalcomputation

demand drivencomputation

MaximumComputation

MinimumComputation

EarlyComputation

LateComputation

What should be computed?

When should it be computed?

Do not compute what you don’t need!

Who defines what is needed? Client

Uday Khedker IIT Bombay

Page 165: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Conclusions 37/38

Parting Thoughts: The Larger Perspective

exhaustivecomputation

computationrestrictedto usableinformation

incrementalcomputation

demand drivencomputation

MaximumComputation

MinimumComputation

EarlyComputation

LateComputation

What should be computed?

When should it be computed?

Do not compute what you don’t need!

Who defines what is needed? Algorithm, Data Structure

Uday Khedker IIT Bombay

Page 166: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Conclusions 37/38

Parting Thoughts: The Larger Perspective

exhaustivecomputation

computationrestrictedto usableinformation

incrementalcomputation

demand drivencomputation

MaximumComputation

MinimumComputation

EarlyComputation

LateComputation

What should be computed?

When should it be computed?

Do not compute what you don’t need!

Who defines what is needed? Algorithm, Data Structure

Avoid computing some values because

• they have been computed before, or

• they can just be “adjusted”, or

• they are equivalent to some other values

E.g. Value based termination of call strings,Work list based methods, BDDs

Uday Khedker IIT Bombay

Page 167: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Conclusions 37/38

Parting Thoughts: The Larger Perspective

exhaustivecomputation

computationrestrictedto usableinformation

incrementalcomputation

demand drivencomputation

MaximumComputation

MinimumComputation

EarlyComputation

LateComputation

What should be computed?

When should it be computed?

Do not compute what you don’t need!

Who defines what is needed? Definition of Analysis

Uday Khedker IIT Bombay

Page 168: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Conclusions 37/38

Parting Thoughts: The Larger Perspective

exhaustivecomputation

computationrestrictedto usableinformation

incrementalcomputation

demand drivencomputation

MaximumComputation

MinimumComputation

EarlyComputation

LateComputation

What should be computed?

When should it be computed?

Do not compute what you don’t need!

Who defines what is needed? No One!

Uday Khedker IIT Bombay

Page 169: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Conclusions 37/38

Parting Thoughts: The Larger Perspective

exhaustivecomputation

computationrestrictedto usableinformation

incrementalcomputation

demand drivencomputation

MaximumComputation

MinimumComputation

EarlyComputation

LateComputation

What should be computed?

When should it be computed?

Do not compute what you don’t need!

Who defines what is needed?These seem orthogonaland may be used together

Uday Khedker IIT Bombay

Page 170: Uday Khedker (Joint Work with Alan Mycroft and Prashant ...uday/soft-copies/lipta.pdf · Uday Khedker (Joint Work with Alan Mycroft and Prashant Singh Rawat) Department of Computer

IIT Delhi LFCPA: Conclusions 38/38

Last But Not the Least

Thank You!

Uday Khedker IIT Bombay