liveness based pointer analysis

168
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 September 2012

Upload: others

Post on 11-Sep-2021

36 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Liveness Based Pointer Analysis

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

September 2012

Page 2: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

Part 1

Introduction

Page 4: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop LFCPA: Introduction 3/38

Pointer Analysis Musings

• Two Position Papers

• A Keynote Address

Uday Khedker IIT Bombay

Page 6: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop LFCPA: Introduction 5/38

The Engineering of Pointer Analysis

So what should we expect?

Uday Khedker IIT Bombay

Page 12: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop LFCPA: Introduction 6/38

Pointer Analysis: Engineering or Science?

• Engineering view

• Science view

Uday Khedker IIT Bombay

Page 17: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

Part 2

Background

Page 21: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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

Constraints onPoints-to Sets

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

∀w ∈ Pz , Pw ⊇ Py

Pz ⊇ Py

Py ⊇ {x}

Uday Khedker IIT Bombay

Page 34: Liveness Based Pointer Analysis

IMPECS Workshop 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

For each “lhs = rhs”

• Equate the points-tosets of lhs and rhs

Effectively, create newassignment “rhs = lhs”

• In practice, an efficientalgorithm computesthe combined effect

Constraints onPoints-to Sets

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

∀w ∈ Pz , Pw ⊇ Py

Pz ⊇ Py

Py ⊇ {x}New Constraints

∀w ∈ Pz , Pw ⊆ Py

Pz ⊆ Py

Uday Khedker IIT Bombay

Page 35: Liveness Based Pointer Analysis

IMPECS Workshop 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

• For this example, weget a complete graph

Constraints onPoints-to Sets

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

∀w ∈ Pz , Pw ⊇ Py

Pz ⊇ Py

Py ⊇ {x}New Constraints

∀w ∈ Pz , Pw ⊆ Py

Pz ⊆ Py

Uday Khedker IIT Bombay

Page 36: Liveness Based Pointer Analysis

IMPECS Workshop 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 37: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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 39: Liveness Based Pointer Analysis

IMPECS Workshop 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 40: Liveness Based Pointer Analysis

IMPECS Workshop 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 41: Liveness Based Pointer Analysis

IMPECS Workshop 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 42: Liveness Based Pointer Analysis

IMPECS Workshop 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 43: Liveness Based Pointer Analysis

IMPECS Workshop 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 44: Liveness Based Pointer Analysis

IMPECS Workshop 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 45: Liveness Based Pointer Analysis

IMPECS Workshop 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 46: Liveness Based Pointer Analysis

IMPECS Workshop 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 47: Liveness Based Pointer Analysis

IMPECS Workshop 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 48: Liveness Based Pointer Analysis

IMPECS Workshop 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 49: Liveness Based Pointer Analysis

IMPECS Workshop 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 50: Liveness Based Pointer Analysis

IMPECS Workshop 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 51: Liveness Based Pointer Analysis

IMPECS Workshop 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 52: Liveness Based Pointer Analysis

IMPECS Workshop 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 53: Liveness Based Pointer Analysis

IMPECS Workshop 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 54: Liveness Based Pointer Analysis

IMPECS Workshop 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 55: Liveness Based Pointer Analysis

IMPECS Workshop 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 56: Liveness Based Pointer Analysis

IMPECS Workshop 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 57: Liveness Based Pointer Analysis

IMPECS Workshop 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 58: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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 60: Liveness Based Pointer Analysis

IMPECS Workshop 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 61: Liveness Based Pointer Analysis

IMPECS Workshop 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 62: Liveness Based Pointer Analysis

IMPECS Workshop 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 63: Liveness Based Pointer Analysis

IMPECS Workshop 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 64: Liveness Based Pointer Analysis

IMPECS Workshop 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 65: Liveness Based Pointer Analysis

IMPECS Workshop 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 66: Liveness Based Pointer Analysis

IMPECS Workshop 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 67: Liveness Based Pointer Analysis

IMPECS Workshop 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 68: Liveness Based Pointer Analysis

IMPECS Workshop 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 69: Liveness Based Pointer Analysis

IMPECS Workshop 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 70: Liveness Based Pointer Analysis

IMPECS Workshop LFCPA: Background 14/38

Pointer Analysis: An Engineer’s Landscape

Flow

Sensitivity

Increases

Context SensitivityIncreases

FI=

FFS

CI FCS

Uday Khedker IIT Bombay

Page 71: Liveness Based Pointer Analysis

IMPECS Workshop 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 72: Liveness Based Pointer Analysis

IMPECS Workshop 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 73: Liveness Based Pointer Analysis

IMPECS Workshop 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 74: Liveness Based Pointer Analysis

IMPECS Workshop 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 75: Liveness Based Pointer Analysis

IMPECS Workshop 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 76: Liveness Based Pointer Analysis

IMPECS Workshop 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 77: Liveness Based Pointer Analysis

IMPECS Workshop 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 78: Liveness Based Pointer Analysis

IMPECS Workshop 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 79: Liveness Based Pointer Analysis

Part 3

Formulating LFCPA

Page 80: Liveness Based Pointer Analysis

IMPECS Workshop 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 81: Liveness Based Pointer Analysis

IMPECS Workshop 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 82: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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 88: Liveness Based Pointer Analysis

IMPECS Workshop 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 89: Liveness Based Pointer Analysis

IMPECS Workshop 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 90: Liveness Based Pointer Analysis

IMPECS Workshop 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 91: Liveness Based Pointer Analysis

IMPECS Workshop 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 92: Liveness Based Pointer Analysis

IMPECS Workshop 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 93: Liveness Based Pointer Analysis

IMPECS Workshop 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 94: Liveness Based Pointer Analysis

IMPECS Workshop 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 95: Liveness Based Pointer Analysis

IMPECS Workshop 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 96: Liveness Based Pointer Analysis

IMPECS Workshop 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 97: Liveness Based Pointer Analysis

IMPECS Workshop 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 98: Liveness Based Pointer Analysis

IMPECS Workshop 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 99: Liveness Based Pointer Analysis

IMPECS Workshop 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 100: Liveness Based Pointer Analysis

IMPECS Workshop 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 101: Liveness Based Pointer Analysis

IMPECS Workshop 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 102: Liveness Based Pointer Analysis

IMPECS Workshop 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 103: Liveness Based Pointer Analysis

IMPECS Workshop 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 104: Liveness Based Pointer Analysis

IMPECS Workshop 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 105: Liveness Based Pointer Analysis

IMPECS Workshop 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 106: Liveness Based Pointer Analysis

IMPECS Workshop 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 107: Liveness Based Pointer Analysis

IMPECS Workshop 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 108: Liveness Based Pointer Analysis

IMPECS Workshop 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 109: Liveness Based Pointer Analysis

IMPECS Workshop 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 110: Liveness Based Pointer Analysis

IMPECS Workshop 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 111: Liveness Based Pointer Analysis

IMPECS Workshop 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: Liveness Based Pointer Analysis

IMPECS Workshop 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 113: Liveness Based Pointer Analysis

IMPECS Workshop 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 114: Liveness Based Pointer Analysis

IMPECS Workshop 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 115: Liveness Based Pointer Analysis

IMPECS Workshop 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 116: Liveness Based Pointer Analysis

IMPECS Workshop 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 117: Liveness Based Pointer Analysis

IMPECS Workshop 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 118: Liveness Based Pointer Analysis

IMPECS Workshop 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 119: Liveness Based Pointer Analysis

IMPECS Workshop 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 120: Liveness Based Pointer Analysis

IMPECS Workshop 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 121: Liveness Based Pointer Analysis

IMPECS Workshop 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 122: Liveness Based Pointer Analysis

IMPECS Workshop 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 123: Liveness Based Pointer Analysis

IMPECS Workshop 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 124: Liveness Based Pointer Analysis

IMPECS Workshop 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 125: Liveness Based Pointer Analysis

IMPECS Workshop 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 126: Liveness Based Pointer Analysis

IMPECS Workshop 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 127: Liveness Based Pointer Analysis

IMPECS Workshop 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 128: Liveness Based Pointer Analysis

Part 4

Interprocedural Analysis

Page 129: Liveness Based Pointer Analysis

IMPECS Workshop 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 130: Liveness Based Pointer Analysis

IMPECS Workshop 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 131: Liveness Based Pointer Analysis

IMPECS Workshop 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 132: Liveness Based Pointer Analysis

IMPECS Workshop LFCPA: Interprocedural Analysis 27/38

Value Based Termination of Call String Construction

Startp

Endp

ProcedureBody

Uday Khedker IIT Bombay

Page 133: Liveness Based Pointer Analysis

IMPECS Workshop 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 134: Liveness Based Pointer Analysis

IMPECS Workshop 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 135: Liveness Based Pointer Analysis

IMPECS Workshop 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 136: Liveness Based Pointer Analysis

IMPECS Workshop 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 137: Liveness Based Pointer Analysis

IMPECS Workshop 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 138: Liveness Based Pointer Analysis

IMPECS Workshop 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 139: Liveness Based Pointer Analysis

IMPECS Workshop 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 140: Liveness Based Pointer Analysis

IMPECS Workshop 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 141: Liveness Based Pointer Analysis

IMPECS Workshop 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 142: Liveness Based Pointer Analysis

IMPECS Workshop 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 143: Liveness Based Pointer Analysis

IMPECS Workshop 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 144: Liveness Based Pointer Analysis

IMPECS Workshop 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 145: Liveness Based Pointer Analysis

Part 5

Measurements

Page 146: Liveness Based Pointer Analysis

IMPECS Workshop 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 147: Liveness Based Pointer Analysis

IMPECS Workshop 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 148: Liveness Based Pointer Analysis

IMPECS Workshop 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 149: Liveness Based Pointer Analysis

IMPECS Workshop 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 150: Liveness Based Pointer Analysis

IMPECS Workshop 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 151: Liveness Based Pointer Analysis

Part 6

Conclusions

Page 152: Liveness Based Pointer Analysis

IMPECS Workshop 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 153: Liveness Based Pointer Analysis

IMPECS Workshop 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 154: Liveness Based Pointer Analysis

IMPECS Workshop 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 155: Liveness Based Pointer Analysis

IMPECS Workshop 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 156: Liveness Based Pointer Analysis

IMPECS Workshop 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 157: Liveness Based Pointer Analysis

IMPECS Workshop LFCPA: Conclusions 37/38

Parting Thoughts: The Larger Perspective

exhaustivecomputation

computationrestrictedto usableinformation

incrementalcomputation

demand drivencomputation

Uday Khedker IIT Bombay

Page 158: Liveness Based Pointer Analysis

IMPECS Workshop LFCPA: Conclusions 37/38

Parting Thoughts: The Larger Perspective

exhaustivecomputation

computationrestrictedto usableinformation

incrementalcomputation

demand drivencomputation

MaximumComputation

MinimumComputation

Uday Khedker IIT Bombay

Page 159: Liveness Based Pointer Analysis

IMPECS Workshop LFCPA: Conclusions 37/38

Parting Thoughts: The Larger Perspective

exhaustivecomputation

computationrestrictedto usableinformation

incrementalcomputation

demand drivencomputation

MaximumComputation

MinimumComputation

EarlyComputation

LateComputation

Uday Khedker IIT Bombay

Page 160: Liveness Based Pointer Analysis

IMPECS Workshop 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 161: Liveness Based Pointer Analysis

IMPECS Workshop 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 162: Liveness Based Pointer Analysis

IMPECS Workshop 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 163: Liveness Based Pointer Analysis

IMPECS Workshop 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 164: Liveness Based Pointer Analysis

IMPECS Workshop 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 165: Liveness Based Pointer Analysis

IMPECS Workshop 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 166: Liveness Based Pointer Analysis

IMPECS Workshop 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 167: Liveness Based Pointer Analysis

IMPECS Workshop 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 168: Liveness Based Pointer Analysis

IMPECS Workshop LFCPA: Conclusions 38/38

Last But Not the Least

Thank You!

Uday Khedker IIT Bombay