Generalized Points-to Graph: A New Abstraction of Memory in Presence - - PowerPoint PPT Presentation

generalized points to graph a new abstraction of memory
SMART_READER_LITE
LIVE PREVIEW

Generalized Points-to Graph: A New Abstraction of Memory in Presence - - PowerPoint PPT Presentation

Generalized Points-to Graph: A New Abstraction of Memory in Presence of Pointers Pritam Gharat Department of Computer Science and Engineering, Indian Institute of Technology, Bombay September 2018 Disclaimer Some of the slides in Introduction


slide-1
SLIDE 1

Generalized Points-to Graph: A New Abstraction of Memory in Presence of Pointers

Pritam Gharat

Department of Computer Science and Engineering, Indian Institute of Technology, Bombay

September 2018

slide-2
SLIDE 2

Disclaimer

Some of the slides in Introduction are borrowed from CS618 course conducted at IIT Bombay

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 2 / 50

slide-3
SLIDE 3

Outline

Introduction Motivation Generalized Points-to Graph (GPG) as a uniform representation for memory and memory transformer An Overview of GPG optimizations Implementation and Empirical Measurements Future Work

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 3 / 50

slide-4
SLIDE 4

Part I Introduction

slide-5
SLIDE 5

Pointer Analysis

Answers the following questions for indirect accesses: Which data is read? x = ∗y Which data is written? ∗x = y Which procedure is called? p() or x → f () Computationally intensive analyses are ineffective with imprecise points-to analysis, e.g., model checking, interprocedural analyses

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 5 / 50

slide-6
SLIDE 6

Pointer Analysis: Precision versus Scalability

Ideally, an analysis should be Sound Precise Scalable

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 6 / 50

slide-7
SLIDE 7

Pointer Analysis: Precision versus Scalability

Ideally, an analysis should be Sound Precise Scalable The state of the art points-to analyses say that precision and scalability do not go hand-in-hand

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 6 / 50

slide-8
SLIDE 8

Pointer Analysis: Precision versus Scalability

Ideally, an analysis should be Sound Precise Scalable The state of the art points-to analyses say that precision and scalability do not go hand-in-hand Several approximations trade-off precision for scalability

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 6 / 50

slide-9
SLIDE 9

Pointer Analysis: Precision versus Scalability

Ideally, an analysis should be Sound Precise Scalable Main factors enhancing the precision of an analysis Flow sensitivity Context sensitivity

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 6 / 50

slide-10
SLIDE 10

Flow Sensitivity Vs. Flow Insensitivity

0 f0 0 1 f1 1 2 f2 2 3 f3 3 i fi i m fm m Flow Sensitive Start 0 f0 0 1 f1 1 2 f2 2 3 f3 3 . . . i fi i . . . m fm m End Flow Insensitive

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 7 / 50

slide-11
SLIDE 11

Flow Sensitivity Vs. Flow Insensitivity

0 f0 0 1 f1 1 2 f2 2 3 f3 3 i fi i m fm m Flow Sensitive Start 0 f0 0 1 f1 1 2 f2 2 3 f3 3 . . . i fi i . . . m fm m End Flow Insensitive Assumption: Statements can be executed in any order

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 7 / 50

slide-12
SLIDE 12

Flow Sensitivity Vs. Flow Insensitivity

0 f0 0 1 f1 1 2 f2 2 3 f3 3 i fi i m fm m Flow Sensitive Start 0 f0 0 1 f1 1 2 f2 2 3 f3 3 . . . i fi i . . . m fm m End Flow Insensitive Arbitrary compositions of flow functions in any order ⇒ Flow insensitivity

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 7 / 50

slide-13
SLIDE 13

Context Sensitivity Vs. Context Insensitivity

Startr Endr Starts a = &b c = &e Call r z = c Startt c = &d Call r Endt fr

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 8 / 50

slide-14
SLIDE 14

Context Sensitivity Vs. Context Insensitivity

Startr Endr Starts a = &b c = &e Call r z = c Startt c = &d Call r Endt fr

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 8 / 50

slide-15
SLIDE 15

Context Sensitivity Vs. Context Insensitivity

Startr Endr Starts a = &b c = &e Call r z = c Startt c = &d Call r Endt fr

×

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 8 / 50

slide-16
SLIDE 16

Context Sensitivity Vs. Context Insensitivity

Startr Endr Starts a = &b c = &e Call r z = c Startt c = &d Call r Endt fr

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 8 / 50

slide-17
SLIDE 17

Context Sensitivity Vs. Context Insensitivity

Startr Endr Starts a = &b c = &e Call r z = c Startt c = &d Call r Endt fr

×

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 8 / 50

slide-18
SLIDE 18

The Goal of My Ph.D. Work

Most approaches begin with a scalable method and try to increase the precision

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 9 / 50

slide-19
SLIDE 19

The Goal of My Ph.D. Work

Most approaches begin with a scalable method and try to increase the precision My approach begins with a precise method and tries to increase the scalability

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 9 / 50

slide-20
SLIDE 20

The Goal of My Ph.D. Work

Most approaches begin with a scalable method and try to increase the precision My approach begins with a precise method and tries to increase the scalability Improving the scalability of pointer analysis without losing precision

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 9 / 50

slide-21
SLIDE 21

The Goal of My Ph.D. Work

Improving the scalability of pointer analysis without losing precision GPG-based approach hinges on the following observations: Flow- and context-sensitive points-to information is small and sparse even for large programs The real killer of scalability in program analysis is not the amount of data that an analysis computes but the amount of control flow that the data may be subjected to in search of precision. It is the control flow that has the effect of introducing an exponential multiplier in the size of the data If control flow can be minimized carefully, there is a good chance of scaling a program analysis without compromising on precision

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 9 / 50

slide-22
SLIDE 22

Top-down Vs. Bottom-up Interprocedural Analysis

Top-down Analysis for Available Expressions Analysis Startp Startp a ∗ b Call q Endp Endp Startq Startq a = ... b + c Endq Endq Startr Startr c ∗ d Call q Endr Endr

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 10 / 50

slide-23
SLIDE 23

Top-down Vs. Bottom-up Interprocedural Analysis

Top-down Analysis for Available Expressions Analysis Procedure q needs to be processed multiple times Startp Startp a ∗ b Call q Endp Endp Startq Startq a = ... b + c Endq Endq Startr Startr c ∗ d Call q Endr Endr Expression b + c is available in procedure p Expression a ∗ b is not available in procedure p

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 10 / 50

slide-24
SLIDE 24

Top-down Vs. Bottom-up Interprocedural Analysis

Top-down Analysis for Available Expressions Analysis Procedure q needs to be processed multiple times Startp Startp a ∗ b Call q Endp Endp Startq Startq a = ... b + c Endq Endq Startr Startr c ∗ d Call q Endr Endr Expressions b + c and c ∗ d are available in procedure r

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 10 / 50

slide-25
SLIDE 25

Top-down Vs. Bottom-up Interprocedural Analysis

Top-down Analysis for Available Expressions Analysis Bottom-Up Analysis for Available Expressions Analysis Startp Startp a ∗ b Call q Endp Endp Startq Startq a = ... b + c Endq Endq Startr Startr c ∗ d Call q Endr Endr

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 10 / 50

slide-26
SLIDE 26

Top-down Vs. Bottom-up Interprocedural Analysis

Top-down Analysis for Available Expressions Analysis Bottom-Up Analysis for Available Expressions Analysis Call is replaced by procedure summary Startp Startp a ∗ b Gen:b + c Kill:a ∗ b Endp Endp Startq Startq a = ... b + c Endq Endq Startr Startr c ∗ d Gen:b + c Kill:a ∗ b Endr Endr Using procedure summary of g at call sites

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 10 / 50

slide-27
SLIDE 27

Top-down Vs. Bottom-up Interprocedural Analysis

Top-down Analysis for Available Expressions Analysis Bottom-Up Analysis for Available Expressions Analysis Call is replaced by procedure summary Startp Startp a ∗ b Gen:b + c Kill:a ∗ b Endp Endp Startq Startq a = ... b + c Endq Endq Startr Startr c ∗ d Gen:b + c Kill:a ∗ b Endr Endr Expression b + c is available in procedure p Expression a ∗ b is not available in procedure p

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 10 / 50

slide-28
SLIDE 28

Top-down Vs. Bottom-up Interprocedural Analysis

Top-down Analysis for Available Expressions Analysis Bottom-Up Analysis for Available Expressions Analysis Call is replaced by procedure summary Startp Startp a ∗ b Gen:b + c Kill:a ∗ b Endp Endp Startq Startq a = ... b + c Endq Endq Startr Startr c ∗ d Gen:b + c Kill:a ∗ b Endr Endr Expressions b + c and c ∗ d are available in procedure r

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 10 / 50

slide-29
SLIDE 29

Top-down Vs. Bottom-up Interprocedural Analysis

Top-down Analysis for Available Expressions Analysis Bottom-Up Analysis for Available Expressions Analysis Startp Startp a ∗ b Gen:b + c Kill:a ∗ b Endp Endp Startq Startq a = ... b + c Endq Endq Startr Startr c ∗ d Gen:b + c Kill:a ∗ b Endr Endr A good procedure summary should be Precise Compact Amenable to efficient application Reusable

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 10 / 50

slide-30
SLIDE 30

Interprocedural Pointer Analysis

Interprocedural Analysis Top-down Approaches

  • ver the

call graph Bottom-up Approaches Pros: Caller’s information available to callee Cons: Procedure is analyzed multiple times Reusable procedure summary is constructed Problems representing indirect accesses of pointees defined in callers

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 11 / 50

slide-31
SLIDE 31

Interprocedural Pointer Analysis

Interprocedural Analysis Top-down Approaches

  • ver the

call graph Bottom-up Approaches Pros: Caller’s information available to callee Cons: Procedure is analyzed multiple times Reusable procedure summary is constructed Problems representing indirect accesses of pointees defined in callers We focus on bottom-up approaches and propose a compact representation of procedure summary for pointer analysis

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 11 / 50

slide-32
SLIDE 32

Interprocedural Pointer Analysis

Interprocedural Analysis Top-down Approaches

  • ver the

call graph Bottom-up Approaches Pros: Caller’s information available to callee Cons: Procedure is analyzed multiple times Reusable procedure summary is constructed Problems representing indirect accesses of pointees defined in callers We focus on bottom-up approaches and propose a compact representation of procedure summary for pointer analysis Our language model is C. In this presentation, we focus only on pointers to scalars

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 11 / 50

slide-33
SLIDE 33

Summarizing a Procedure for Points-to Analysis

A flow-sensitive analysis requires control flow to be recorded between memory updates that share data dependence

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 12 / 50

slide-34
SLIDE 34

Summarizing a Procedure for Points-to Analysis

A flow-sensitive analysis requires control flow to be recorded between memory updates that share data dependence

  • 1. x = &a;
  • 2. y = x;

Data dependence exists ⇒ Can be eliminated and the Control flow between the updates would be redundant

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 12 / 50

slide-35
SLIDE 35

Summarizing a Procedure for Points-to Analysis

A flow-sensitive analysis requires control flow to be recorded between memory updates that share data dependence

  • 1. x = &a;
  • 2. y = x;

⇓ x = &a; y = &a; Data dependence exists ⇒ Can be eliminated and the Control flow between the updates would be redundant

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 12 / 50

slide-36
SLIDE 36

Summarizing a Procedure for Points-to Analysis

A flow-sensitive analysis requires control flow to be recorded between memory updates that share data dependence

  • 1. x = &a;
  • 2. y = &b;
  • 3. x = &b;

Data dependence exists ⇒ Can be eliminated and the Control flow between the updates would be redundant Data dependence does not exist ⇒ Redundant memory updates can be eliminated

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 12 / 50

slide-37
SLIDE 37

Summarizing a Procedure for Points-to Analysis

A flow-sensitive analysis requires control flow to be recorded between memory updates that share data dependence

  • 1. x = &a;
  • 2. y = &b;
  • 3. x = &b;

⇓ y = &b; x = &b; Data dependence exists ⇒ Can be eliminated and the Control flow between the updates would be redundant Data dependence does not exist ⇒ Redundant memory updates can be eliminated

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 12 / 50

slide-38
SLIDE 38

Summarizing a Procedure for Points-to Analysis

A flow-sensitive analysis requires control flow to be recorded between memory updates that share data dependence

  • 1. y = &b;
  • 2. ∗x = &a;

Data dependence exists ⇒ Can be eliminated and the Control flow between the updates would be redundant Data dependence does not exist ⇒ Redundant memory updates can be eliminated Data dependence is unknown ⇒ More information is required Available when inlined at call sites

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 12 / 50

slide-39
SLIDE 39

Summarizing a Procedure for Points-to Analysis

A flow-sensitive analysis requires control flow to be recorded between memory updates that share data dependence

  • 1. y = &b;
  • 2. ∗x = &a;

Data dependence exists ⇒ Can be eliminated and the Control flow between the updates would be redundant Data dependence does not exist ⇒ Redundant memory updates can be eliminated Data dependence is unknown ⇒ More information is required Available when inlined at call sites ◮ Control flow between the updates required

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 12 / 50

slide-40
SLIDE 40

Summarizing a Procedure for Points-to Analysis

A flow-sensitive analysis requires control flow to be recorded between memory updates that share data dependence

  • 1. y = &b;
  • 2. ∗x = &a;

Data dependence exists ⇒ Can be eliminated and the Control flow between the updates would be redundant Data dependence does not exist ⇒ Redundant memory updates can be eliminated Data dependence is unknown ⇒ More information is required Available when inlined at call sites ◮ Control flow between the updates required ◮ Some accesses of pointees have definitions in the callers

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 12 / 50

slide-41
SLIDE 41

Summarizing a Procedure for Points-to Analysis

A flow-sensitive analysis requires control flow to be recorded between memory updates that share data dependence

  • 1. y = &b;
  • 2. ∗x = &a;
  • 3. z = y;

Data dependence exists ⇒ Can be eliminated and the Control flow between the updates would be redundant Data dependence does not exist ⇒ Redundant memory updates can be eliminated Data dependence is unknown ⇒ More information is required Available when inlined at call sites ◮ Control flow between the updates required ◮ Some accesses of pointees have definitions in the callers ◮ Some optimizations need to be postponed

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 12 / 50

slide-42
SLIDE 42

Memory and Memory Transformer

a Memory in absence

  • f pointers

b c x Memory in presence

  • f pointers

y z x Memory Transformer φ1 a

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 13 / 50

slide-43
SLIDE 43

Memory and Memory Transformer

a Memory in absence

  • f pointers

b c x Memory in presence

  • f pointers

y z x Memory Transformer φ1 a For memory transformer, ◮ Blue edges ⇒ information generated ◮ Black edges ⇒ carried forward input information

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 13 / 50

slide-44
SLIDE 44

Memory and Memory Transformer

a Memory in absence

  • f pointers

b c x Memory in presence

  • f pointers

y z x Memory Transformer φ1 a Input Memory x y z Output Memory x y z a

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 13 / 50

slide-45
SLIDE 45

Part II Motivation

slide-46
SLIDE 46

Bottom-up Approaches: The State of the Art

Accesses of pointees that are defined in the callers are represented using placeholders

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 15 / 50

slide-47
SLIDE 47

Bottom-up Approaches: The State of the Art

Accesses of pointees that are defined in the callers are represented using placeholders e.g., x = y ⇒

x φ1 y φ1 is a placeholder

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 15 / 50

slide-48
SLIDE 48

Bottom-up Approaches: The State of the Art

Accesses of pointees that are defined in the callers are represented using placeholders e.g., x = y ⇒

x φ1 y φ1 is a placeholder

Context based analysis [Zhang-PLDI-14, Wilson-PLDI-95] ◮ Use aliases present in the caller ◮ Construct a collection of partial transfer functions (PTFs)

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 15 / 50

slide-49
SLIDE 49

Bottom-up Approaches: The State of the Art

Accesses of pointees that are defined in the callers are represented using placeholders e.g., x = y ⇒

x φ1 y φ1 is a placeholder

Context based analysis [Zhang-PLDI-14, Wilson-PLDI-95] ◮ Use aliases present in the caller ◮ Construct a collection of partial transfer functions (PTFs) Context independent analysis [S˘ alcianu-VMCAI-05, Madhavan-SAS-12] ◮ No aliases assumed in the calling contexts ◮ Construct a single procedure summary

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 15 / 50

slide-50
SLIDE 50

Limitation of Placeholders

Placeholders explicate the pointees defined in callers (Low level abstraction of memory)

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 16 / 50

slide-51
SLIDE 51

Limitation of Placeholders

Placeholders explicate the pointees defined in callers (Low level abstraction of memory) This results in ◮ either multiple call-specific procedure summaries, or Reuse of a placeholder for a flow sensitive summary flow function depends on the aliases in the calling contexts

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 16 / 50

slide-52
SLIDE 52

Limitation of Placeholders

Placeholders explicate the pointees defined in callers (Low level abstraction of memory) This results in ◮ either multiple call-specific procedure summaries, or ◮ large number of placeholders Reuse of a placeholder for a flow sensitive summary flow function depends on the aliases in the calling contexts In absence of aliases from the calling contexts, every access is represented by a separate placeholder. Control flow is also required

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 16 / 50

slide-53
SLIDE 53

Part III Generalized Points-to Graphs

slide-54
SLIDE 54

Representing Basic Pointer Assignments using the Generalized Points-to Updates

General Case Specific Examples GPU x i|j − →

s y

x y i −1 j Pointer

GPU

Relevant memory graph assignment after the assignment s : x = &y x 1|0 − − →

s

y x y s : x = y x 1|1 − − →

s

y x y s : x = ∗y x 1|2 − − →

s

y x y s : ∗x = y x 2|1 − − →

s

y x y

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 18 / 50

slide-55
SLIDE 55

Representing Basic Pointer Assignments using the Generalized Points-to Updates

General Case Specific Examples GPU x i|j − →

s y

x y i −1 j Pointer

GPU

Relevant memory graph assignment after the assignment s : x = &y x 1|0 − − →

s

y x y s : x = y x 1|1 − − →

s

y x y s : x = ∗y x 1|2 − − →

s

y x y s : ∗x = y x 2|1 − − →

s

y x y

The direction in a GPU is to distinguish between what is being defined to what is being read For pointer analysis, case i = 0 does not exist classical points-to update is a special case of generalized points-to update with i = 1 and j = 0

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 18 / 50

slide-56
SLIDE 56

Representing Basic Pointer Assignments using the Generalized Points-to Updates

General Case Specific Examples GPU x i|j − →

s y

x y i −1 j Pointer

GPU

Relevant memory graph assignment after the assignment s : x = &y x 1|0 − − →

s

y x y s : x = y x 1|1 − − →

s

y x y s : x = ∗y x 1|2 − − →

s

y x y s : ∗x = y x 2|1 − − →

s

y x y

The direction in a GPU is to distinguish between what is being defined to what is being read For pointer analysis, case i = 0 does not exist classical points-to update is a special case of generalized points-to update with i = 1 and j = 0 GPU represents both memory and memory transformer

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 18 / 50

slide-57
SLIDE 57

Classical Points-to Updates: A Low Level Abstraction of Memory for Points-to Analysis

All variables are global Red nodes are known named locations x y f() { *x = y }

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 19 / 50

slide-58
SLIDE 58

Classical Points-to Updates: A Low Level Abstraction of Memory for Points-to Analysis

All variables are global Red nodes are known named locations Blue nodes are placeholders denoting unknown locations x y f() { *x = y } φ1 φ2

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 19 / 50

slide-59
SLIDE 59

Classical Points-to Updates: A Low Level Abstraction of Memory for Points-to Analysis

All variables are global Red nodes are known named locations Blue nodes are placeholders denoting unknown locations x y f() { *x = y } φ1 φ2 a Information from callers

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 19 / 50

slide-60
SLIDE 60

Classical Points-to Updates: A Low Level Abstraction of Memory for Points-to Analysis

All variables are global Red nodes are known named locations Blue nodes are placeholders denoting unknown locations x y f() { *x = y } φ1 φ2 φ1 a

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 19 / 50

slide-61
SLIDE 61

Classical Points-to Updates: A Low Level Abstraction of Memory for Points-to Analysis

All variables are global Red nodes are known named locations Blue nodes are placeholders denoting unknown locations x y f() { *x = y } φ1 φ2 a

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 19 / 50

slide-62
SLIDE 62

Classical Points-to Updates: A Low Level Abstraction of Memory for Points-to Analysis

All variables are global Red nodes are known named locations Blue nodes are placeholders denoting unknown locations x y f() { *x = y } φ1 φ2 a b Information from callers

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 19 / 50

slide-63
SLIDE 63

Classical Points-to Updates: A Low Level Abstraction of Memory for Points-to Analysis

All variables are global Red nodes are known named locations Blue nodes are placeholders denoting unknown locations x y f() { *x = y } φ1 φ2 a b φ2

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 19 / 50

slide-64
SLIDE 64

Classical Points-to Updates: A Low Level Abstraction of Memory for Points-to Analysis

All variables are global Red nodes are known named locations Blue nodes are placeholders denoting unknown locations x y f() { *x = y } φ1 φ2 a b

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 19 / 50

slide-65
SLIDE 65

Generalized Points-to Updates: A High Level Abstraction of Memory for Points-to Analysis

Blue arrows are low level view of memory in terms of classical points-to facts x y f() { *x = y } φ1 φ2

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 20 / 50

slide-66
SLIDE 66

Generalized Points-to Updates: A High Level Abstraction of Memory for Points-to Analysis

Blue arrows are low level view of memory in terms of classical points-to facts Black arrows are high level view of memory in terms of generalized points-to facts x y f() { *x = y } φ1 φ2

2|1

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 20 / 50

slide-67
SLIDE 67

Generalized Points-to Updates: A High Level Abstraction of Memory for Points-to Analysis

Blue arrows are low level view of memory in terms of classical points-to facts Black arrows are high level view of memory in terms of generalized points-to facts x y f() { *x = y } φ1 φ2

2|1

a

1|0

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 20 / 50

slide-68
SLIDE 68

Generalized Points-to Updates: A High Level Abstraction of Memory for Points-to Analysis

Blue arrows are low level view of memory in terms of classical points-to facts Black arrows are high level view of memory in terms of generalized points-to facts x y f() { *x = y } φ1 φ2

2|1

a

1|0

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 20 / 50

slide-69
SLIDE 69

Generalized Points-to Updates: A High Level Abstraction of Memory for Points-to Analysis

Blue arrows are low level view of memory in terms of classical points-to facts Black arrows are high level view of memory in terms of generalized points-to facts x y f() { *x = y } φ1 φ2 a

1|0 1|1

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 20 / 50

slide-70
SLIDE 70

Generalized Points-to Updates: A High Level Abstraction of Memory for Points-to Analysis

Blue arrows are low level view of memory in terms of classical points-to facts Black arrows are high level view of memory in terms of generalized points-to facts x y f() { *x = y } φ1 φ2 a

1|0 1|1

b

1|0

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 20 / 50

slide-71
SLIDE 71

Generalized Points-to Updates: A High Level Abstraction of Memory for Points-to Analysis

Blue arrows are low level view of memory in terms of classical points-to facts Black arrows are high level view of memory in terms of generalized points-to facts x y f() { *x = y } φ1 φ2 a

1|0 1|1

b

1|0

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 20 / 50

slide-72
SLIDE 72

Generalized Points-to Updates: A High Level Abstraction of Memory for Points-to Analysis

Blue arrows are low level view of memory in terms of classical points-to facts Black arrows are high level view of memory in terms of generalized points-to facts x y f() { *x = y } φ1 φ2 a

1|0

b

1|0 1|0

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 20 / 50

slide-73
SLIDE 73

Generalized Points-to Updates: A High Level Abstraction of Memory for Points-to Analysis

Blue arrows are low level view of memory in terms of classical points-to facts Black arrows are high level view of memory in terms of generalized points-to facts x y f() { *x = y } φ1 φ2 a

1|0

b

1|0 1|0

This abstraction does not introduce any imprecision over the classical points-to graph

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 20 / 50

slide-74
SLIDE 74

GPU Composition

Represented by c ◦ p; performed only when they share a common node called the pivot

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 21 / 50

slide-75
SLIDE 75

GPU Composition

Represented by c ◦ p; performed only when they share a common node called the pivot x = &y; z = ∗x;

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 21 / 50

slide-76
SLIDE 76

GPU Composition

Represented by c ◦ p; performed only when they share a common node called the pivot x y 1|0 p x = &y; z = ∗x; GPG

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 21 / 50

slide-77
SLIDE 77

GPU Composition

Represented by c ◦ p; performed only when they share a common node called the pivot

x y 1|0

x y 1|0 p x = &y; z = ∗x; GPG

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 21 / 50

slide-78
SLIDE 78

GPU Composition

Represented by c ◦ p; performed only when they share a common node called the pivot x = &y; z = ∗x;

x y 1|0

x y 1|0 GPG p

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 21 / 50

slide-79
SLIDE 79

GPU Composition

Represented by c ◦ p; performed only when they share a common node called the pivot x = &y; z = ∗x;

x y 1|0

x y 1|0 GPG p z 1|2 c

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 21 / 50

slide-80
SLIDE 80

GPU Composition

Represented by c ◦ p; performed only when they share a common node called the pivot x = &y; z = ∗x;

x y 1|0

x y 1|0 p z 1|2 c pivot x

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 21 / 50

slide-81
SLIDE 81

GPU Composition

Represented by c ◦ p; performed only when they share a common node called the pivot Reduces the indlev of c by using information from p ◮ Eliminating pivot and creating a reduced GPU r between other two nodes by using pivot as a bridge c ⇒ Consumer GPU, p ⇒ Producer GPU x = &y; z = ∗x;

x y 1|0

x y 1|0 p z 1|2 c

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 21 / 50

slide-82
SLIDE 82

GPU Composition

Represented by c ◦ p; performed only when they share a common node called the pivot Reduces the indlev of c by using information from p ◮ Eliminating pivot and creating a reduced GPU r between other two nodes by using pivot as a bridge c ⇒ Consumer GPU, p ⇒ Producer GPU x = &y; z = ∗x;

x y 1|0

x y 1|0 p z 1|2 c r = c ◦ p

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 21 / 50

slide-83
SLIDE 83

GPU Composition

Represented by c ◦ p; performed only when they share a common node called the pivot Reduces the indlev of c by using information from p ◮ Eliminating pivot and creating a reduced GPU r between other two nodes by using pivot as a bridge Requires the indlev s of the pivot in both the GPUs to be made same x = &y; z = ∗x;

x y 1|0

x y 1|0 p z 1|2 c r = c ◦ p

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 21 / 50

slide-84
SLIDE 84

GPU Composition

Represented by c ◦ p; performed only when they share a common node called the pivot Reduces the indlev of c by using information from p ◮ Eliminating pivot and creating a reduced GPU r between other two nodes by using pivot as a bridge Requires the indlev s of the pivot in both the GPUs to be made same x = &y; z = ∗x;

x y 1|0

x y 1|0 p z 1|2 c r = c ◦ p x y z Memory Graph

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 21 / 50

slide-85
SLIDE 85

GPU Composition

Represented by c ◦ p; performed only when they share a common node called the pivot Reduces the indlev of c by using information from p ◮ Eliminating pivot and creating a reduced GPU r between other two nodes by using pivot as a bridge Requires the indlev s of the pivot in both the GPUs to be made same x = &y; z = ∗x;

x y 1|0

x y 1+1|0+1 p z 1|2 c r = c ◦ p x y z Memory Graph

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 21 / 50

slide-86
SLIDE 86

GPU Composition

Represented by c ◦ p; performed only when they share a common node called the pivot Reduces the indlev of c by using information from p ◮ Eliminating pivot and creating a reduced GPU r between other two nodes by using pivot as a bridge Requires the indlev s of the pivot in both the GPUs to be made same x = &y; z = ∗x;

x y 1|0

x y 2|1 p z 1|2 c r = c ◦ p x y z Memory Graph

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 21 / 50

slide-87
SLIDE 87

GPU Composition

Represented by c ◦ p; performed only when they share a common node called the pivot Reduces the indlev of c by using information from p ◮ Eliminating pivot and creating a reduced GPU r between other two nodes by using pivot as a bridge Requires the indlev s of the pivot in both the GPUs to be made same x = &y; z = ∗x;

x y 1|0

x y 2|1 p z 1|2 c 1|1 r x y z Memory Graph

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 21 / 50

slide-88
SLIDE 88

GPU Composition

Represented by c ◦ p; performed only when they share a common node called the pivot Reduces the indlev of c by using information from p ◮ Eliminating pivot and creating a reduced GPU r between other two nodes by using pivot as a bridge Requires the indlev s of the pivot in both the GPUs to be made same x = &y; z = ∗x;

x y 1|0

x y 1|0 p z 1|2 c 1|1 r p remains unchanged x y z Memory Graph

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 21 / 50

slide-89
SLIDE 89

GPU Composition

Represented by c ◦ p; performed only when they share a common node called the pivot Reduces the indlev of c by using information from p ◮ Eliminating pivot and creating a reduced GPU r between other two nodes by using pivot as a bridge Requires the indlev s of the pivot in both the GPUs to be made same x = &y; z = ∗x;

x y 1|0

x y 1|0 p z 1|2 c 1|1 r Data dependence through x is eliminated. Control flow becomes redundant

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 21 / 50

slide-90
SLIDE 90

GPU Composition

Represented by c ◦ p; performed only when they share a common node called the pivot Reduces the indlev of c by using information from p ◮ Eliminating pivot and creating a reduced GPU r between other two nodes by using pivot as a bridge Requires the indlev s of the pivot in both the GPUs to be made same x = &y; z = ∗x;

x y 1|0

x y 1|0 p z 1|2 c 1|1 r GPUs r and c are equivalent in the context of p

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 21 / 50

slide-91
SLIDE 91

GPU Composition

Represented by c ◦ p; performed only when they share a common node called the pivot Reduces the indlev of c by using information from p ◮ Eliminating pivot and creating a reduced GPU r between other two nodes by using pivot as a bridge Requires the indlev s of the pivot in both the GPUs to be made same x = &y; z = ∗x;

x y 1|0

x y 1|0 p z 1|2 c 1|1 r Strength reduction

  • ptimization replaces

c by r

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 21 / 50

slide-92
SLIDE 92

GPU Composition

Represented by c ◦ p; performed only when they share a common node called the pivot Reduces the indlev of c by using information from p ◮ Eliminating pivot and creating a reduced GPU r between other two nodes by using pivot as a bridge Requires the indlev s of the pivot in both the GPUs to be made same x = &y; z = ∗x;

x y 1|0

x y 1|0 p z 1|2 c 1|1 r GPU reduction is a series of GPU compositions

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 21 / 50

slide-93
SLIDE 93

Generalized Points-to Graphs (GPGs) I

A GPG is a graph with Nodes called as generalized points-to blocks (GPBs) A GPB contains a set of GPUs Edges representing control flow between GPBs

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 22 / 50

slide-94
SLIDE 94

Generalized Points-to Graphs (GPGs) I

A GPG is a graph with Nodes called as generalized points-to blocks (GPBs) A GPB contains a set of GPUs Edges representing control flow between GPBs A GPG is analogous to a CFG of a procedure GPG GPB GPU CFG BB

  • Ptr. Assgn.

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 22 / 50

slide-95
SLIDE 95

Generalized Points-to Graphs (GPGs) I

A GPG is a graph with Nodes called as generalized points-to blocks (GPBs) A GPB contains a set of GPUs Edges representing control flow between GPBs A GPG is analogous to a CFG of a procedure GPG GPB GPU CFG BB

  • Ptr. Assgn.

First difference: GPUs in a GPB represent parallel assignments Assignments in a basic block are sequential

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 22 / 50

slide-96
SLIDE 96

Generalized Points-to Graphs (GPGs) I

A GPG is a graph with Nodes called as generalized points-to blocks (GPBs) A GPB contains a set of GPUs Edges representing control flow between GPBs A GPG is analogous to a CFG of a procedure GPG GPB GPU CFG BB

  • Ptr. Assgn.

Second difference: CFGs contain call basic blocks GPGs do not have call GPBs

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 22 / 50

slide-97
SLIDE 97

Generalized Points-to Graphs (GPGs) II

Construction of Initial GPGs:

Non-pointer assignments and condition tests are removed Each pointer assignment s is transliterated to its GPU (γs) A separate GPB is created for assignment in the CFG GPG edges are induced from the control flow of the CFG GPGs contain only variables that are shared across procedures GPGs then undergo extensive optimizations

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 23 / 50

slide-98
SLIDE 98

The Big Picture View of GPG Construction

Abstractions GPU Operations Data Flow Analysis Optimizations

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 24 / 50

slide-99
SLIDE 99

The Big Picture View of GPG Construction

Abstractions GPU Operations Data Flow Analysis Optimizations Inlining callee GPGs

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 24 / 50

slide-100
SLIDE 100

The Big Picture View of GPG Construction

Abstractions GPU Operations Data Flow Analysis Optimizations Inlining callee GPGs Strength Reduction Reaching GPUs Analysis without Blocking Reaching GPUs Analysis with Blocking

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 24 / 50

slide-101
SLIDE 101

The Big Picture View of GPG Construction

Abstractions GPU Operations Data Flow Analysis Optimizations Inlining callee GPGs Strength Reduction Reaching GPUs Analysis without Blocking Reaching GPUs Analysis with Blocking GPU Creation GPU Reduction GPU Composition

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 24 / 50

slide-102
SLIDE 102

The Big Picture View of GPG Construction

Abstractions GPU Operations Data Flow Analysis Optimizations Inlining callee GPGs Strength Reduction Reaching GPUs Analysis without Blocking Reaching GPUs Analysis with Blocking GPU Creation GPU Reduction GPU Composition GPU indlev indlist

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 24 / 50

slide-103
SLIDE 103

The Big Picture View of GPG Construction

Abstractions GPU Operations Data Flow Analysis Optimizations Inlining callee GPGs Strength Reduction Dead GPU Elimination Empty GPB Elimination Reaching GPUs Analysis without Blocking Reaching GPUs Analysis with Blocking GPU Creation GPU Reduction GPU Composition GPU indlev indlist

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 24 / 50

slide-104
SLIDE 104

The Big Picture View of GPG Construction

Abstractions GPU Operations Data Flow Analysis Optimizations Inlining callee GPGs Strength Reduction Dead GPU Elimination Empty GPB Elimination GPB Coalescing Reaching GPUs Analysis without Blocking Reaching GPUs Analysis with Blocking Coalescing Analysis GPU Creation GPU Reduction GPU Composition GPU indlev indlist

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 24 / 50

slide-105
SLIDE 105

The Big Picture View of GPG Construction

Abstractions GPU Operations Data Flow Analysis Optimizations Inlining callee GPGs Strength Reduction Dead GPU Elimination Empty GPB Elimination GPB Coalescing Back Edge Removal Redundancy Elimination Reaching GPUs Analysis without Blocking Reaching GPUs Analysis with Blocking Coalescing Analysis Essential Back Edges Analysis GPU Creation GPU Reduction GPU Composition GPU indlev indlist

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 24 / 50

slide-106
SLIDE 106

The Big Picture View of GPG Construction

Abstractions GPU Operations Data Flow Analysis Optimizations Inlining callee GPGs Strength Reduction Dead GPU Elimination Empty GPB Elimination GPB Coalescing Back Edge Removal Redundancy Elimination Reaching GPUs Analysis without Blocking Reaching GPUs Analysis with Blocking Coalescing Analysis Essential Back Edges Analysis GPU Creation GPU Reduction GPU Composition GPU indlev indlist

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 24 / 50

slide-107
SLIDE 107

The Big Picture View of GPG Construction

Abstractions GPU Operations Data Flow Analysis Optimizations Inlining callee GPGs Strength Reduction Dead GPU Elimination Empty GPB Elimination GPB Coalescing Back Edge Removal Redundancy Elimination Reaching GPUs Analysis without Blocking Reaching GPUs Analysis with Blocking Coalescing Analysis Essential Back Edges Analysis GPU Creation GPU Reduction GPU Composition GPU indlev indlist

Published in SAS 2016

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 24 / 50

slide-108
SLIDE 108

The Big Picture View of GPG Construction

Abstractions GPU Operations Data Flow Analysis Optimizations Inlining callee GPGs Strength Reduction Dead GPU Elimination Empty GPB Elimination GPB Coalescing Back Edge Removal Redundancy Elimination Reaching GPUs Analysis without Blocking Reaching GPUs Analysis with Blocking Coalescing Analysis Essential Back Edges Analysis GPU Creation GPU Reduction GPU Composition GPU indlev indlist

Submitted to TOPLAS

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 24 / 50

slide-109
SLIDE 109

GPGs Across Optimizations

x = &a; g(); x = &b; CFG of proc f y = x; CFG of proc g

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 25 / 50

slide-110
SLIDE 110

GPGs Across Optimizations

x = &a; g(); x = &b; CFG of proc f y = x; CFG of proc g x a

1|0 1

ag();b x b

1|0 8

Initial GPG

  • f proc f

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 25 / 50

slide-111
SLIDE 111

GPGs Across Optimizations

x = &a; g(); x = &b; CFG of proc f y = x; CFG of proc g x a

1|0 1

ag();b x b

1|0 8

Initial GPG

  • f proc f

x a

1|0 1

y x

1|1 2

x b

1|0 8

After Call Inlining

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 25 / 50

slide-112
SLIDE 112

GPGs Across Optimizations

x = &a; g(); x = &b; CFG of proc f y = x; CFG of proc g x a

1|0 1

ag();b x b

1|0 8

Initial GPG

  • f proc f

x a

1|0 1

y x

1|1 2

x b

1|0 8

After Call Inlining x a

1|0 1

y a

1|0 2

x b

1|0 8

After Strength Reduction

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 25 / 50

slide-113
SLIDE 113

GPGs Across Optimizations

x = &a; g(); x = &b; CFG of proc f y = x; CFG of proc g x a

1|0 1

ag();b x b

1|0 8

Initial GPG

  • f proc f

x a

1|0 1

y x

1|1 2

x b

1|0 8

After Call Inlining x a

1|0 1

y a

1|0 2

x b

1|0 8

After Strength Reduction y a

1|0 2

x b

1|0 8

After Dead GPU Elimination

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 25 / 50

slide-114
SLIDE 114

GPGs Across Optimizations

x = &a; g(); x = &b; CFG of proc f y = x; CFG of proc g x a

1|0 1

ag();b x b

1|0 8

Initial GPG

  • f proc f

x a

1|0 1

y x

1|1 2

x b

1|0 8

After Call Inlining x a

1|0 1

y a

1|0 2

x b

1|0 8

After Strength Reduction y a

1|0 2

x b

1|0 8

After Dead GPU Elimination y a

1|0 2

x b

1|0 8

After Empty GPB Elimination

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 25 / 50

slide-115
SLIDE 115

GPGs Across Optimizations

x = &a; g(); x = &b; CFG of proc f y = x; CFG of proc g x a

1|0 1

ag();b x b

1|0 8

Initial GPG

  • f proc f

x a

1|0 1

y x

1|1 2

x b

1|0 8

After Call Inlining x a

1|0 1

y a

1|0 2

x b

1|0 8

After Strength Reduction y a

1|0 2

x b

1|0 8

After Dead GPU Elimination y a

1|0 2

x b

1|0 8

After Empty GPB Elimination y a x b

1|0 2 1|0 8

After Coalescing

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 25 / 50

slide-116
SLIDE 116

GPGs Across Optimizations

x = &a; g(); x = &b; CFG of proc f y = x; CFG of proc g x a

1|0 1

ag();b x b

1|0 8

Initial GPG

  • f proc f

x a

1|0 1

y x

1|1 2

x b

1|0 8

After Call Inlining x a

1|0 1

y a

1|0 2

x b

1|0 8

After Strength Reduction y a

1|0 2

x b

1|0 8

After Dead GPU Elimination y a

1|0 2

x b

1|0 8

After Empty GPB Elimination y a x b

1|0 2 1|0 8

After Coalescing All GPGs represent sound and precise summary of procedure f for points-to analysis Structurally, all GPGs are different but their application computes identical results A series of optimizations increases the compactness of GPGs significantly

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 25 / 50

slide-117
SLIDE 117

Factors affecting Scalability

Three issues that cause non-scalability Modelling indirect accesses of pointees that are defined in callers without examining their code ◮ GPUs track indirection levels that relate (transitively indirect) pointees of a variable with those of other variables Preserving data dependence between memory updates ◮ Maintain minimal control flow between memory updates ensuring soundness and precision Incorporating the effect of summaries of the callee procedures transitively ◮ Series of GPG optimizations gives compactness that mitigate the impact of transitive inlining

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 26 / 50

slide-118
SLIDE 118

Part IV Implementation and Empirical Measurements

slide-119
SLIDE 119

Implementation

Implemented in GCC 4.7.2 using the LTO framework Measurements carried out on SPEC CPU2006 benchmarks on a machine with 16 GB RAM with eight 64-bit Intel i7-4770 CPUs running at 3.40GHz We could scale our analysis on benchmarks upto 158kLoC Also implemented flow- and context-insensitive points-to analysis and flow-insensitive and context-sensitive points-to analysis

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 28 / 50

slide-120
SLIDE 120

Effectiveness of GPGs

Compactness of GPGs. Percentage of context independent information (CI) A procedure summary is very useful if it contains high percentage of context-independent information (GPUs with indlev “1|0”).

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 29 / 50

slide-121
SLIDE 121

Effectiveness of GPGs

10 20 30 300 600 20 40 60 80 100 # of GPBs in an optimized GPG Percentage of procedures 20 40 60 120 20 40 60 80 100 # of GPUs in an optimized GPG Percentage of procedures lbm mcf libquantum bzip2 milc sjeng hmmer h264ref gobmk

20 40 60 80 100 10 20 30 40 50 Percentage of context independent information Percentage of procedures lbm mcf libquantum bzip2 milc sjeng hmmer h264ref gobmk

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 29 / 50

slide-122
SLIDE 122

Effectiveness of GPGs

10 20 30 300 600 20 40 60 80 100 # of GPBs in an optimized GPG Percentage of procedures 20 40 60 120 20 40 60 80 100 # of GPUs in an optimized GPG Percentage of procedures lbm mcf libquantum bzip2 milc sjeng hmmer h264ref gobmk

20 40 60 80 100 10 20 30 40 50 Percentage of context independent information Percentage of procedures lbm mcf libquantum bzip2 milc sjeng hmmer h264ref gobmk

GPGs for a large number

  • f procedures

have 0 GPUs Majority of GPGs have 1 to 3 GPBs

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 29 / 50

slide-123
SLIDE 123

Effectiveness of GPGs

10 20 30 300 600 20 40 60 80 100 # of GPBs in an optimized GPG Percentage of procedures 20 40 60 120 20 40 60 80 100 # of GPUs in an optimized GPG Percentage of procedures lbm mcf libquantum bzip2 milc sjeng hmmer h264ref gobmk

20 40 60 80 100 10 20 30 40 50 Percentage of context independent information Percentage of procedures lbm mcf libquantum bzip2 milc sjeng hmmer h264ref gobmk

Number of procedures with a high % of context indepen- dent information is larger in larger benchmarks

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 29 / 50

slide-124
SLIDE 124

Size of GPGs Relative to the Size of Procedures in terms of GPUs and Pointer Assignments

20 40 60 80 100 20 40 60 80 Ratio of GPUs and stmts in GPGs and CFGs after call inlining (in terms of percentage) Percentage of procedures 10 20 30 40 20 40 60 80 Ratio of GPUs and stmts in optimized GPGs and CFGs after call inlining (in terms of percentage) Percentage of procedures lbm mcf libquantum bzip2 milc sjeng hmmer h264ref gobmk 20 40 60 80 100 10 20 30 40 Ratio of GPUs in optimized GPGs and GPGs after call inlining (in terms of percentage) Percentage of procedures lbm mcf libquantum bzip2 milc sjeng hmmer h264ref gobmk

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 30 / 50

slide-125
SLIDE 125

Size of GPGs Relative to the Size of Procedures in terms of GPUs and Pointer Assignments

20 40 60 80 100 20 40 60 80 Ratio of GPUs and stmts in GPGs and CFGs after call inlining (in terms of percentage) Percentage of procedures 10 20 30 40 20 40 60 80 Ratio of GPUs and stmts in optimized GPGs and CFGs after call inlining (in terms of percentage) Percentage of procedures lbm mcf libquantum bzip2 milc sjeng hmmer h264ref gobmk 20 40 60 80 100 10 20 30 40 Ratio of GPUs in optimized GPGs and GPGs after call inlining (in terms of percentage) Percentage of procedures lbm mcf libquantum bzip2 milc sjeng hmmer h264ref gobmk

Smaller the ratio, more is the reduction and more compact are the GPGs

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 30 / 50

slide-126
SLIDE 126

Size of GPGs Relative to the Size of Procedures in terms of control flow edges

20 40 60 80 100 10 20 30 40 50 60 70 Ratio of control flow edges in GPGs and CFGs after call inlining (in terms of percentage) Percentage of procedures 20 40 60 80 100 20 40 60 80 100 Ratio of control flow edges in optimized GPGs and CFGs after call inlining (in terms of percentage) Percentage of procedures lbm mcf libquantum bzip2 milc sjeng hmmer h264ref gobmk 20 40 60 80 100 20 40 60 80 100 Ratio of control flow edges in optimized GPGs and GPGs after call inlining (in terms of percentage) Percentage of procedures lbm mcf libquantum bzip2 milc sjeng hmmer h264ref gobmk

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 31 / 50

slide-127
SLIDE 127

Size of GPGs Relative to the Size of Procedures in terms of control flow edges

20 40 60 80 100 10 20 30 40 50 60 70 Ratio of control flow edges in GPGs and CFGs after call inlining (in terms of percentage) Percentage of procedures 20 40 60 80 100 20 40 60 80 100 Ratio of control flow edges in optimized GPGs and CFGs after call inlining (in terms of percentage) Percentage of procedures lbm mcf libquantum bzip2 milc sjeng hmmer h264ref gobmk 20 40 60 80 100 20 40 60 80 100 Ratio of control flow edges in optimized GPGs and GPGs after call inlining (in terms of percentage) Percentage of procedures lbm mcf libquantum bzip2 milc sjeng hmmer h264ref gobmk

Optimization of control flow is more compared to the optimization

  • f GPUs

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 31 / 50

slide-128
SLIDE 128

Data Measurements

lbm mcf libquantum bzip2 milc sjeng hmmer h264ref gobmk 1 2 15 30 50 80 Benchmark

  • Avg. of points-to pairs per procedure

FSCS FICI FICS

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 32 / 50

slide-129
SLIDE 129

Data Measurements

lbm mcf libquantum bzip2 milc sjeng hmmer h264ref gobmk 1 2 15 30 50 80 Benchmark

  • Avg. of points-to pairs per procedure

FSCS FICI FICS

Average number

  • f points-to pairs

in FSCS is much smaller than FICI and FICS

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 32 / 50

slide-130
SLIDE 130

Part V Points-to Information Computation

slide-131
SLIDE 131

Points-to Information Computation

Traditional bottom-up approach consists of two phases: a bottom-up phase for constructing procedure summaries a top-down phase for computing points-to information using procedure summaries

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 34 / 50

slide-132
SLIDE 132

Points-to Information Computation

Interleaving of strength reduction and call inlining ⇒ The top-down phase redundant Points-to information is computed by bringing the definitions and uses of a pointer to a common context Can be achieved by pushing ◮ a use to a caller ◮ a definition to a caller ◮ both use and definition to a caller ◮ neither (if they are already in the same procedure)

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 34 / 50

slide-133
SLIDE 133

Points-to Information Computation

Startp Startp x a

1|0 5

Call q Endp Endp Startq Startq y x

1|1 2

Endq Endq Startr Startr Call s Starts Starts x b

1|0 8

Ends Ends Call q Endr Endr

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 34 / 50

slide-134
SLIDE 134

Points-to Information Computation

Startp Startp x a

1|0 5

Startq Startq y x

1|1 2

Endq Endq Call q Endp Endp Startr Startr Starts Starts x b

1|0 8

Ends Ends Call s Call q Endr Endr

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 34 / 50

slide-135
SLIDE 135

Points-to Information Computation

Startp Startp x a

1|0 5

Startq Startq y x

1|1 2

Endq Endq y x

1|1 2

Endp Endp Startr Startr Starts Starts x b

1|0 8

Ends Ends x b

1|0 8

y x

1|1 2

Endr Endr After call inlining

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 34 / 50

slide-136
SLIDE 136

Points-to Information Computation

Startp Startp x a

1|0 5

Startq Startq y x

1|1 2

Endq Endq y x

1|1 2

Endp Endp Startr Startr Starts Starts x b

1|0 8

Ends Ends x b

1|0 8

Use pushed towards definition in a caller y x

1|1 2

Endr Endr Use and definition pushed in a common context

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 34 / 50

slide-137
SLIDE 137

Points-to Information Computation

Startp Startp x a

1|0 5

Startq Startq y x

1|1 2

Endq Endq y a

1|0 2

Endp Endp Startr Startr Starts Starts x b

1|0 8

Ends Ends x b

1|0 8

y b

1|0 2

Endr Endr After strength reduction optimization

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 34 / 50

slide-138
SLIDE 138

Points-to Information Computation

Startp Startp x a

1|0 5

Startq Startq y x

1|1 2

Endq Endq y a

1|0 2

Endp Endp Startr Startr Starts Starts x b

1|0 8

Ends Ends x b

1|0 8

y b

1|0 2

Endr Endr

  • Stmt. id

Points-to Information 2 {y 1|0 − − →

2

a, y 1|0 − − →

2

b}

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 34 / 50

slide-139
SLIDE 139

Points-to Information Computation

Startp Startp x a

1|0 5

Startq Startq y x

1|1 2

Endq Endq y a

1|0 2

Endp Endp Startr Startr Starts Starts x b

1|0 8

Ends Ends x b

1|0 8

y b

1|0 2

Endr Endr

  • Stmt. id

Points-to Information 2 {y 1|0 − − →

2

a, y 1|0 − − →

2

b} Context-sensitive points-to information for statement 2

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 34 / 50

slide-140
SLIDE 140

Points-to Information Computation

Startp Startp x a

1|0 5

Startq Startq y x

1|1 2

Endq Endq y a

1|0 2

Endp Endp Startr Startr Starts Starts x b

1|0 8

Ends Ends x b

1|0 8

y b

1|0 2

Endr Endr

  • Stmt. id

Points-to Information 2 {y 1|0 − − →

2

a, y 1|0 − − →

2

b} Context-sensitive points-to information for statement 2 Statement ids are unique across procedures

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 34 / 50

slide-141
SLIDE 141

Part VI Future Work

slide-142
SLIDE 142

Future Work

It would be useful to explore the possibilities: Restricting the GPG construction to live pointer variables for scalability. Studying the interactions between GPGs and the abstractions of a client analysis, say property proving application for verification. Extending the scope of GPG-based points-to analysis to concurrent programs such as Java programs containing threads.

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 36 / 50

slide-143
SLIDE 143

Part VII Thank You

slide-144
SLIDE 144

Part VIII Extra Slides

slide-145
SLIDE 145

Part IX Advanced Features of Languages

slide-146
SLIDE 146

Handling Recursion

main p q ∆1

p

∆1

q

∆⊤ ∆2

q

∆2

p

∆3

q

∆3

p

. . . . . . fixed point ∆1

p contains recursive call to q and ∆1 q contains recursive call to p.

∆2

q is constructed from ∆1 q by using ∆⊤ as a summary for call to p.

∆2

p is constructed from ∆1 p by using ∆2 q as a summary for call to q.

∆3

q is constructed from ∆2 q by using ∆2 p as a summary for call to p.

∆3

p is constructed from ∆2 p by using ∆3 q as a summary for call to q.

. . . ⇒ Fixed point.

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 40 / 50

slide-147
SLIDE 147

Handling Recursion

main p q ∆1

p

∆1

q

∆⊤ ∆2

q

∆2

p

∆3

q

∆3

p

. . . . . . fixed point ∆1

p contains recursive call to q and ∆1 q contains recursive call to p.

∆2

q is constructed from ∆1 q by using ∆⊤ as a summary for call to p.

∆2

p is constructed from ∆1 p by using ∆2 q as a summary for call to q.

∆3

q is constructed from ∆2 q by using ∆2 p as a summary for call to p.

∆3

p is constructed from ∆2 p by using ∆3 q as a summary for call to q.

. . . ⇒ Fixed point. Fixed point is reached when the data flow values converge, not when the resultant GPGs converge

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 40 / 50

slide-148
SLIDE 148

Handling Recursion

main p q ∆1

p

∆1

q

∆⊤ ∆2

q

∆2

p

∆3

q

∆3

p

. . . . . . fixed point ∆1

p contains recursive call to q and ∆1 q contains recursive call to p.

∆2

q is constructed from ∆1 q by using ∆⊤ as a summary for call to p.

∆2

p is constructed from ∆1 p by using ∆2 q as a summary for call to q.

∆3

q is constructed from ∆2 q by using ∆2 p as a summary for call to p.

∆3

p is constructed from ∆2 p by using ∆3 q as a summary for call to q.

. . . ⇒ Fixed point. Fixed point is reached in a finite number of steps because the lattice is finite

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 40 / 50

slide-149
SLIDE 149

Handling Function Pointers

x = &a; afp();b x = &a;

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 41 / 50

slide-150
SLIDE 150

Handling Function Pointers

x = &a; afp();b x = &a; If pointees of fp are f and g

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 41 / 50

slide-151
SLIDE 151

Handling Function Pointers

If pointees of fp are f and g x = &a; af ();b ag();b x = &a; Calls to f and g could be recursive or non-recursive

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 41 / 50

slide-152
SLIDE 152

Handling Function Pointers

x = &a; afp();b x = &a; If pointees of fp are not available locally

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 41 / 50

slide-153
SLIDE 153

Handling Function Pointers

If pointees of fp are not available locally x = &a; u fp

1|1

x = &a; Model indirect call as a use statement

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 41 / 50

slide-154
SLIDE 154

Handling Structures

Statement Field-sensitive representation Field-insensitive representation Our choice x = ∗y x

[∗]|[∗,∗]

− − − − →y x

1|2

− − →y x

1|2

− − →y x = y →n x

[∗]|[∗,n]

− − − − →y x

1|2

− − →y x

[∗]|[∗,n]

− − − − →y

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 42 / 50

slide-155
SLIDE 155

Handling Structures

Statement Field-sensitive representation Field-insensitive representation Our choice x = ∗y x

[∗]|[∗,∗]

− − − − →y x

1|2

− − →y x

1|2

− − →y x = y →n x

[∗]|[∗,n]

− − − − →y x

1|2

− − →y x

[∗]|[∗,n]

− − − − →y x

[∗]|[∗,∗]

− − − − →y x

[∗]|[∗,n]

− − − − →y y φ1 φ2 x ∗ ∗ ∗ y xavb xavb φ2 x ∗ n ∗

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 42 / 50

slide-156
SLIDE 156

Handling Structures

Statement Field-sensitive representation Field-insensitive representation Our choice x = ∗y x

[∗]|[∗,∗]

− − − − →y x

1|2

− − →y x

1|2

− − →y x = y →n x

[∗]|[∗,n]

− − − − →y x

1|2

− − →y x

[∗]|[∗,n]

− − − − →y x

[∗]|[∗,∗]

− − − − →y x

[∗]|[∗,n]

− − − − →y y φ1 φ2 x ∗ ∗ ∗ y xavb xavb φ2 x ∗ n ∗ No distinction between dereferences Distinction between dereferences is essential for field sensitivity

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 42 / 50

slide-157
SLIDE 157

Handling Structures

Statement Field-sensitive representation Field-insensitive representation Our choice x = ∗y x

[∗]|[∗,∗]

− − − − →y x

1|2

− − →y x

1|2

− − →y x = y →n x

[∗]|[∗,n]

− − − − →y x

1|2

− − →y x

[∗]|[∗,n]

− − − − →y x

1|2

− − →y x

[∗]|[∗,n]

− − − − →y y φ1 φ2 x ∗ ∗ ∗ y xavb xavb φ2 x ∗ n ∗

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 42 / 50

slide-158
SLIDE 158

Handling Structures

Statement Field-sensitive representation Field-insensitive representation Our choice x = ∗y x

[∗]|[∗,∗]

− − − − →y x

1|2

− − →y x

1|2

− − →y x = y →n x

[∗]|[∗,n]

− − − − →y x

1|2

− − →y x

[∗]|[∗,n]

− − − − →y Imprecise representation

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 42 / 50

slide-159
SLIDE 159

Handling Structures

Statement Field-sensitive representation Field-insensitive representation Our choice x = ∗y x

[∗]|[∗,∗]

− − − − →y x

1|2

− − →y x

1|2

− − →y x = y →n x

[∗]|[∗,n]

− − − − →y x

1|2

− − →y x

[∗]|[∗,n]

− − − − →y List operations are similar to the arithmetic operations performed

  • n indirection levels for GPU composition

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 42 / 50

slide-160
SLIDE 160

Miscellaneous Features

Our heap abstraction consists of:

  • allocation-site-based-abstraction
  • k-limited indirection lists

Arrays, pointer arithmetic, address escaped variables undergo weak

  • updates. Hence their effect is over-approximated

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 43 / 50

slide-161
SLIDE 161

Is Flow and Context Sensitivity Important? (I)

Articles [Hind and Pioli 1998;2000; Hind 2001] claim that the better precision is not worth the price one has to pay for flow sensitivity

This claim is criticized because [Staiger-St¨

  • hr 2013]:

◮ Study performed on relatively small programs ◮ Indirect strong updates not supported ◮ Field-insensitive analyses

Work by Hardekopf and Lin [2009, 2011] with very good results for flow-sensitive pointer analysis supports Staiger-St¨

  • hr’s theory

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 44 / 50

slide-162
SLIDE 162

Is Flow and Context Sensitivity Important? (II)

Lack of flow sensitivity in race detection algorithm [Naik-Aiken 2006] affects the synchronization idioms that the approach can handle precisely The pointer-flow used for taint analysis is ineffective without context sensitivity [Tripp-Pistoia 2009] A context sensitive call graph is more precise [Grove-Chambers 2001]

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 45 / 50

slide-163
SLIDE 163

Is Flow and Context Sensitivity Important? (III)

Jens Palsberg in his key note talk [SAS 2012] says that context-sensitive analysis improved the precision of “May Happen in Parallel Analysis” Object sensitivity [Milanova-Ryder 2005] shows significant improvement in the precision of side-effect analysis and call graph construction compared to a context-insensitive analysis

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 46 / 50

slide-164
SLIDE 164

Context Based Bottom-up Approach

The need of multiple partial transfer functions (PTFs) Example:

  • 1. x = ∗y;
  • 2. ∗z = q;
  • 3. p = ∗y;

Two dereferences of y are separated by a possibly side-effect causing statement through z

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 47 / 50

slide-165
SLIDE 165

Context Based Bottom-up Approach

The need of multiple partial transfer functions (PTFs) Example:

  • 1. x = ∗y;
  • 2. ∗z = q;
  • 3. p = ∗y;

∗z is aliased to y y φ1 φ2 x z q φ3 φ4 p z is aliased to y y φ1 φ2 x z q φ3 p z and y are not related y φ1 φ2 x z q φ3 φ4 p Red edges ⇒ killed information Blue edges ⇒ information generated Black edges ⇒ carried forward input information

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 47 / 50

slide-166
SLIDE 166

Context Based Bottom-up Approach

The need of multiple partial transfer functions (PTFs) Example:

  • 1. x = ∗y;
  • 2. ∗z = q;
  • 3. p = ∗y;

∗z is aliased to y y φ1 φ2 x z q φ3 φ4 p z is aliased to y y φ1 φ2 x z q φ3 p z and y are not related y φ1 φ2 x z q φ3 φ4 p Only relevant aliases are considered Statement 2 will cause a side effect and p will point to what is related to q and not what is related to x

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 47 / 50

slide-167
SLIDE 167

Context Based Bottom-up Approach

The need of multiple partial transfer functions (PTFs) Example:

  • 1. x = ∗y;
  • 2. ∗z = q;
  • 3. p = ∗y;

∗z is aliased to y y φ1 φ2 x z q φ3 φ4 p z is aliased to y y φ1 φ2 x z q φ3 p z and y are not related y φ1 φ2 x z q φ3 φ4 p Only relevant aliases are considered Statement 2 will NOT cause a side effect and p will point to what is related to x and not what is related to q

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 47 / 50

slide-168
SLIDE 168

Context Based Bottom-up Approach

The need of multiple partial transfer functions (PTFs) Example:

  • 1. x = ∗y;
  • 2. ∗z = q;
  • 3. p = ∗y;

∗z is aliased to y y φ1 φ2 x z q φ3 φ4 p z is aliased to y y φ1 φ2 x z q φ3 p z and y are not related y φ1 φ2 x z q φ3 φ4 p Only relevant aliases are considered Alias information eliminates data dependence, hence no control flow required

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 47 / 50

slide-169
SLIDE 169

Context Based Bottom-up Approach

The need of multiple partial transfer functions (PTFs) Example:

  • 1. x = ∗y;
  • 2. ∗z = q;
  • 3. p = ∗y;

∗z is aliased to y y φ1 φ2 x z q φ3 φ4 p z is aliased to y y φ1 φ2 x z q φ3 p z and y are not related y φ1 φ2 x z q φ3 φ4 p Only relevant aliases are considered Pre-processing required for discovering aliases in the callers Multiple summaries for a procedure

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 47 / 50

slide-170
SLIDE 170

Context Independent Bottom-up Approach

Construction of a single flow-sensitive procedure summary Example:

  • 1. x = ∗y;
  • 2. ∗z = q;
  • 3. p = ∗y;

y φ1 φ2 x z q φ5 φ3 φ6 φ7 p Different accesses of the same variable may require different placeholders

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 48 / 50

slide-171
SLIDE 171

Context Independent Bottom-up Approach

Construction of a single flow-sensitive procedure summary Example:

  • 1. x = ∗y;
  • 2. ∗z = q;
  • 3. p = ∗y;

y φ1 φ2 x z q φ5 φ3 φ6 φ7 p Different accesses of the same variable may require different placeholders Large number of placeholders ⇒ size of procedure summary may be proportional to the # of statements A flow-insensitive version may require fewer placeholders ⇒ affects precision

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 48 / 50

slide-172
SLIDE 172

Context Independent Bottom-up Approach

Construction of a single flow-sensitive procedure summary Example:

  • 1. x = ∗y;
  • 2. ∗z = q;
  • 3. p = ∗y;

y φ1 φ2 x z q φ5 φ3 φ6 φ7 p Ordering of generated edges is important

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 48 / 50

slide-173
SLIDE 173

Context Independent Bottom-up Approach

Construction of a single flow-sensitive procedure summary Example:

  • 1. x = ∗y;
  • 2. ∗z = q;
  • 3. p = ∗y;

y φ1 φ2 x z q φ5 φ3 φ6 φ7 p Ordering of generated edges is important If φ5 − →φ3 is considered before x − →φ2, it will amount to swapping statements 1 and 2 Hence, x and p will be always be aliased ignoring the possible side-effect of statement 2

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 48 / 50

slide-174
SLIDE 174

Strong and Weak Updates in Strength Reduction Optimization

Kill occurs only when a single pointer is defined We call it a strong update

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 49 / 50

slide-175
SLIDE 175

Strong and Weak Updates in Strength Reduction Optimization

x = &y; x = &z; ∗x = w; Weak Update

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 49 / 50

slide-176
SLIDE 176

Strong and Weak Updates in Strength Reduction Optimization

x = &y; x = &z; ∗x = w; Weak Update x = &y; x = &y; ∗x = w; Strong Update

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 49 / 50

slide-177
SLIDE 177

Strong and Weak Updates in Strength Reduction Optimization

x = &y; x = &z; ∗x = w; Weak Update x = &y; x = &y; ∗x = w; Strong Update x = &y; ∗x = w; ?

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 49 / 50

slide-178
SLIDE 178

Strong and Weak Updates in Strength Reduction Optimization

x = &y; x = &z; ∗x = w; Weak Update x = &y; x = &y; ∗x = w; Strong Update x = &y; ∗x = w; Definition-free path for x Possibly weak update

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 49 / 50

slide-179
SLIDE 179

Strong and Weak Updates in Strength Reduction Optimization

x = &y; x = &z; ∗x = w; Weak Update x = &y; x = &y; ∗x = w; Strong Update x = &y; ∗x = w; Possibly weak update Definition-free path distinguishes between strong and weak updates

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 49 / 50

slide-180
SLIDE 180

GPU Composition for Structures

x y a

1|2 22 1|0 34 1|1 34

x y a

[∗]|[∗, n] 22 [∗]|[ ] 34 [∗]|[n] 34

Difference of indlev of y (2 − 1) is computed. Difference (2 − 1) is positive. Add the difference to indlev of a. Remainder of indlist of y (remainder ([∗], [∗, n])) is computed. [∗] is prefix of [∗, n]. Append the remainder to indlist of a.

Pritam Gharat ( IIT Bombay) Generalized Points-to Graphs September 2018 50 / 50