Top Banner
Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta
58

Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Dec 19, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining Tree-Traversals Orientation using Feedback-Directed Analysis

Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral

University of AlbertaStephen Curial, Kevin Andrusky and José Nelson Amaral

University of Alberta

Page 2: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Why do we need to know the orientation of tree-traversals?Why do we need to know the orientation of tree-traversals?

High Memory Latency Memory Wall

Compilers can improve spatial locality Using data transformations Must know the data access pattern before re-

arranging

High Memory Latency Memory Wall

Compilers can improve spatial locality Using data transformations Must know the data access pattern before re-

arranging

Image Courtesy [1]Image Courtesy [1]

Page 3: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

OverviewOverview

We develop a compiler based analysis to determine the Tree-Traversal Orientation.

Given a program as input, the compiler automatically inserts instrumentation into the the program to create an instrumented executable that will determine an orientation score for each tree in the program.

Page 4: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

OverviewOverview

We develop a compiler based analysis to determine the Tree-Traversal Orientation.

Given a program as input, the compiler automatically inserts instrumentation into the the program to create an instrumented executable that will determine an orientation score for each tree in the program.

Page 5: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

dfs(tree *t){ if(t = NULL)

return; dfs(t->left); dfs(t->right);}

OverviewOverview

Program Source

InstrumentedExecutable

Orientation Score

?

Compiler

Tree Analysis Library

Page 6: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Tree-Traversal Orientation AnalysisTree-Traversal Orientation Analysis

Returns an orientation score [-1,1] 1 is depth-first traversal -1 is breadth first traversal 0 is an unknown traversal

Returns an orientation score [-1,1] 1 is depth-first traversal -1 is breadth first traversal 0 is an unknown traversal

DFSBFS

-1 0 1

Page 7: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

OverviewOverview

struct tree *t1, *t2;init(t1,t2);dfs(t1);bfs(t2);…

… …

t1 t2

orientation score = 1.0 orientation score = -1.0

Page 8: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Calculating the Orientation Score Calculating the Orientation Score

Every memory access to a tree is classified as: Depth-First Breadth-First Both Neither

The orientation score of each tree is calculated as:

Every memory access to a tree is classified as: Depth-First Breadth-First Both Neither

The orientation score of each tree is calculated as:

num _ depth − num _breadth

num _ accesses∈ −1,1[ ]

Page 9: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Calculating the Orientation Score Calculating the Orientation Score

A linked-list access can be classified as both Breadth- and Depth-First.

If a memory access to a 1-arity tree is classified as both Breadth- and Depth-First It will be considered Depth-First. This result will likely be more useful to clients of the

analysis.

A linked-list access can be classified as both Breadth- and Depth-First.

If a memory access to a 1-arity tree is classified as both Breadth- and Depth-First It will be considered Depth-First. This result will likely be more useful to clients of the

analysis.

Page 10: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Depth-First

Determining if a Access is Depth-First

The TAL maintains a stack of choice-points for each tree.

Each choice-point consists of: l the address of a node, t, in the tree, l all n children of t, c1 … cn, and l a boolean value representing if the node has

been visited

The TAL maintains a stack of choice-points for each tree.

Each choice-point consists of: l the address of a node, t, in the tree, l all n children of t, c1 … cn, and l a boolean value representing if the node has

been visited

Page 11: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Depth-First

Determining if a Access is Depth-First

Every time a node is visited, a choice-point for each of its children is pushed onto the stack.

Every time a node is visited, a choice-point for each of its children is pushed onto the stack.

1

2 3

8 9 a b c d e f

7654

Page 12: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Depth-First

Determining if a Access is Depth-First

Every time a node is visited, a choice-point for each of its children is pushed onto the stack.

Every time a node is visited, a choice-point for each of its children is pushed onto the stack.

1

2 3

8 9 a b c d e f

7654

23

Page 13: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Depth-First

Determining if a Access is Depth-First

Every time a node is visited, a choice-point for each of its children is pushed onto the stack.

Every time a node is visited, a choice-point for each of its children is pushed onto the stack.

1

2 3

8 9 a b c d e f

7654

2345

Dark color means visited

Page 14: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Depth-First

Determining if a Access is Depth-First

Every time a node is visited, a choice-point for each of its children is pushed onto the stack.

Every time a node is visited, a choice-point for each of its children is pushed onto the stack.

1

2 3

8 9 a b c d e f

7654

234589

Page 15: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Depth-First

Determining if a Access is Depth-First

Every time a node is visited, a choice-point for each of its children is pushed onto the stack.

Every time a node is visited, a choice-point for each of its children is pushed onto the stack.

1

2 3

8 9 a b c d e f

7654

234589

Page 16: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Depth-First

Determining if a Access is Depth-First

Every time a node is visited, a choice-point for each of its children is pushed onto the stack.

Every time a node is visited, a choice-point for each of its children is pushed onto the stack.

1

2 3

8 9 a b c d e f

7654

234589

Page 17: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Depth-First

Determining if a Access is Depth-First

A choice-point is popped off the stack when a tree node lower in the stack is visited and all of the choice-points above have been visited. All the choice points up to the node that was visited are popped.

A choice-point is popped off the stack when a tree node lower in the stack is visited and all of the choice-points above have been visited. All the choice points up to the node that was visited are popped.

1

2 3

8 9 a b c d e f

7654

234589

Page 18: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Depth-First

Determining if a Access is Depth-First

A choice-point is popped off the stack when a tree node lower in the stack is visited and all of the choice-points above have been visited. All the choice points up the node that was visited are popped.

A choice-point is popped off the stack when a tree node lower in the stack is visited and all of the choice-points above have been visited. All the choice points up the node that was visited are popped.

1

2 3

8 9 a b c d e f

7654

2345

Page 19: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Depth-First

Determining if a Access is Depth-First

A choice-point is popped off the stack when a tree node lower in the stack is visited and all of the choice-points above have been visited. All the choice points up the node that was visited are popped.

A choice-point is popped off the stack when a tree node lower in the stack is visited and all of the choice-points above have been visited. All the choice points up the node that was visited are popped.

1

2 3

8 9 a b c d e f

7654

2345ab

Page 20: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Depth-First

Determining if a Access is Depth-First

An access to tree node t is classified as depth-first if and only if:

l The address of cptop is equal to the address of t; ORl The address of child ci of cptop is equal to the address

of t; ORl There exists and ancestor cpanc of cptop such that the

address of cpanc is equal to the address of t and all of the choice-points on the stack above cpanc have been visited.

An access to tree node t is classified as depth-first if and only if:

l The address of cptop is equal to the address of t; ORl The address of child ci of cptop is equal to the address

of t; ORl There exists and ancestor cpanc of cptop such that the

address of cpanc is equal to the address of t and all of the choice-points on the stack above cpanc have been visited.

cptop

Page 21: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Depth-First

Determining if a Access is Depth-First

An access to tree node t is classified as depth-first if and only if:

l The address of cptop is equal to the address of t; ORl The address of child ci of cptop is equal to the address

of t; ORl There exists and ancestor cpanc of cptop such that the

address of cpanc is equal to the address of t and all of the choice-points on the stack above cpanc have been visited.

An access to tree node t is classified as depth-first if and only if:

l The address of cptop is equal to the address of t; ORl The address of child ci of cptop is equal to the address

of t; ORl There exists and ancestor cpanc of cptop such that the

address of cpanc is equal to the address of t and all of the choice-points on the stack above cpanc have been visited.

cptop

Page 22: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Depth-First

Determining if a Access is Depth-First

An access to tree node t is classified as depth-first if and only if:

l The address of cptop is equal to the address of t; ORl The address of child ci of cptop is equal to the address

of t; ORl There exists and ancestor cpanc of cptop such that the

address of cpanc is equal to the address of t and all of the choice-points on the stack above cpanc have been visited.

An access to tree node t is classified as depth-first if and only if:

l The address of cptop is equal to the address of t; ORl The address of child ci of cptop is equal to the address

of t; ORl There exists and ancestor cpanc of cptop such that the

address of cpanc is equal to the address of t and all of the choice-points on the stack above cpanc have been visited.

cptop

Page 23: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Depth-First

Determining if a Access is Depth-First

An access to tree node t is classified as depth-first if and only if:

l The address of cptop is equal to the address of t; ORl The address of child ci of cptop is equal to the address

of t; ORl There exists and ancestor cpanc of cptop such that the

address of cpanc is equal to the address of t and all of the choice-points on the stack above cpanc have been visited.

An access to tree node t is classified as depth-first if and only if:

l The address of cptop is equal to the address of t; ORl The address of child ci of cptop is equal to the address

of t; ORl There exists and ancestor cpanc of cptop such that the

address of cpanc is equal to the address of t and all of the choice-points on the stack above cpanc have been visited.

cpanc

cptop

Page 24: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Breadth-First

Determining if a Access is Breadth-First

The TAL maintains an open and next list for each tree. They are stored a double-ended bit-vectors.

The TAL maintains an open and next list for each tree. They are stored a double-ended bit-vectors.

1 2 3 4 5 6 7 8 9 a b c d e f

1 2 3 4 5 6 7 8 9 a b c d e f

Open

Next

Page 25: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Breadth-First

Determining if a Access is Breadth-First

When tree node t is accessed: The children of t are added to the next list. If t is in the open list it is removed from the open list

and the access is classified as breadth first. When the open list is empty it is swapped with the

next list.

When tree node t is accessed: The children of t are added to the next list. If t is in the open list it is removed from the open list

and the access is classified as breadth first. When the open list is empty it is swapped with the

next list.

1

2 3

8 9 a b c d e f

7654

Open

Next

Page 26: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Breadth-First

Determining if a Access is Breadth-First

When tree node t is accessed: The children of t are added to the next list. If t is in the open list it is removed from the open list

and the access is classified as breadth first. When the open list is empty it is swapped with the

next list.

When tree node t is accessed: The children of t are added to the next list. If t is in the open list it is removed from the open list

and the access is classified as breadth first. When the open list is empty it is swapped with the

next list.

1

2 3

8 9 a b c d e f

7654

2 3

Open

Next

Page 27: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Breadth-First

Determining if a Access is Breadth-First

When tree node t is accessed: The children of t are added to the next list. If t is in the open list it is removed from the open list

and the access is classified as breadth first. When the open list is empty it is swapped with the

next list.

When tree node t is accessed: The children of t are added to the next list. If t is in the open list it is removed from the open list

and the access is classified as breadth first. When the open list is empty it is swapped with the

next list.

1

2 3

8 9 a b c d e f

7654

2 3Open

Next

Page 28: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Breadth-First

Determining if a Access is Breadth-First

When tree node t is accessed: The children of t are added to the next list. If t is in the open list it is removed from the open list

and the access is classified as breadth first. When the open list is empty it is swapped with the

next list.

When tree node t is accessed: The children of t are added to the next list. If t is in the open list it is removed from the open list

and the access is classified as breadth first. When the open list is empty it is swapped with the

next list.

1

2 3

8 9 a b c d e f

7654

2 3Open

Next

Page 29: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Breadth-First

Determining if a Access is Breadth-First

When tree node t is accessed: The children of t are added to the next list. If t is in the open list it is removed from the open list

and the access is classified as breadth first. When the open list is empty it is swapped with the

next list.

When tree node t is accessed: The children of t are added to the next list. If t is in the open list it is removed from the open list

and the access is classified as breadth first. When the open list is empty it is swapped with the

next list.

1

2 3

8 9 a b c d e f

7654

3Open

Next

Page 30: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Breadth-First

Determining if a Access is Breadth-First

When tree node t is accessed: The children of t are added to the next list. If t is in the open list it is removed from the open list

and the access is classified as breadth first. When the open list is empty it is swapped with the

next list.

When tree node t is accessed: The children of t are added to the next list. If t is in the open list it is removed from the open list

and the access is classified as breadth first. When the open list is empty it is swapped with the

next list.

1

2 3

8 9 a b c d e f

7654

3

4 5

Open

Next

Page 31: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Breadth-First

Determining if a Access is Breadth-First

When tree node t is accessed: The children of t are added to the next list. If t is in the open list it is removed from the open list

and the access is classified as breadth first. When the open list is empty it is swapped with the

next list.

When tree node t is accessed: The children of t are added to the next list. If t is in the open list it is removed from the open list

and the access is classified as breadth first. When the open list is empty it is swapped with the

next list.

1

2 3

8 9 a b c d e f

7654

4 5 6 7

Open

Next

Page 32: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Breadth-First

Determining if a Access is Breadth-First

When tree node t is accessed: The children of t are added to the next list. If t is in the open list it is removed from the open list

and the access is classified as breadth first. When the open list is empty it is swapped with the

next list.

When tree node t is accessed: The children of t are added to the next list. If t is in the open list it is removed from the open list

and the access is classified as breadth first. When the open list is empty it is swapped with the

next list.

1

2 3

8 9 a b c d e f

7654

4 5 6 7Open

Next

Page 33: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Determining if a Access is Breadth-First

Determining if a Access is Breadth-First

When tree node t is accessed: The children of t are added to the next list. If t is in the open list it is removed from the open list

and the access is classified as breadth first. When the open list is empty it is swapped with the

next list.

When tree node t is accessed: The children of t are added to the next list. If t is in the open list it is removed from the open list

and the access is classified as breadth first. When the open list is empty it is swapped with the

next list.

1

2 3

8 9 a b c d e f

7654

5 6 7

8 9

Open

Next

Page 34: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

ImplementationImplementationBuilt in the Open Research Compiler (ORC)

Operates on the WHIRL (Winning Hierarchical Intermediate Representation Language) IR.

Analysis requires Interprocedural Analysis (IPA).Automatically identifies link-based tree data structures

using Ghiya and Hendren’s analysis [2] or programmer annotations.

Instrumentation can be inserted into each procedure without IPA.

Built in the Open Research Compiler (ORC) Operates on the WHIRL (Winning Hierarchical

Intermediate Representation Language) IR. Analysis requires Interprocedural Analysis (IPA).

Automatically identifies link-based tree data structures using Ghiya and Hendren’s analysis [2] or programmer annotations.

Instrumentation can be inserted into each procedure without IPA.

Page 35: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

ImplementationImplementation

Calls our Tree Analysis Library (TAL) register_tree_access_with_children()

Takes Parameters: void *addr_deref int tree_id int num_children void *child_addr, …

Calls our Tree Analysis Library (TAL) register_tree_access_with_children()

Takes Parameters: void *addr_deref int tree_id int num_children void *child_addr, …

Page 36: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

ImplementationImplementation

Analysis is safe and will not cause a correct program to fail.

Replace calls to malloc/calloc/realloc with TALs wrapper functions. If memory allocation fails, the analysis is abandoned and

the memory used by the analysis is freed.

Memory address are calculated and accessed for the instrumentation in locations that are safe. i.e. Will not dereference null pointers

if( tree != NULL && tree->data == 1)

Analysis is safe and will not cause a correct program to fail.

Replace calls to malloc/calloc/realloc with TALs wrapper functions. If memory allocation fails, the analysis is abandoned and

the memory used by the analysis is freed.

Memory address are calculated and accessed for the instrumentation in locations that are safe. i.e. Will not dereference null pointers

if( tree != NULL && tree->data == 1)

Page 37: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

How do we identify tree references?How do we identify tree references? Example Code:

/* inorder tree traversal */void inorder_traverse_tree(struct tn *tree_ptr){

if(tree_ptr == NULL) return;

inorder_traverse_tree(tree_ptr->left); tree_ptr->data++; inorder_traverse_tree(tree_ptr->right);

}

Example Code:

/* inorder tree traversal */void inorder_traverse_tree(struct tn *tree_ptr){

if(tree_ptr == NULL) return;

inorder_traverse_tree(tree_ptr->left); tree_ptr->data++; inorder_traverse_tree(tree_ptr->right);

}

Page 38: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

How do we identify tree references?

How do we identify tree references?

LOC 1 94 void inorder_traverse_tree(struct tn *tree_ptr) LOC 1 95 {FUNC_ENTRY <1,25,inorder_traverse_tree> IDNAME 0 <2,1,tree_ptr>BODY BLOCK END_BLOCK BLOCK END_BLOCK BLOCK PRAGMA 0 120 <null-st> 0 (0x0) # PREAMBLE_END LOC 1 96 if(tree_ptr == NULL) IF U8U8LDID 0 <2,1,tree_ptr> T<32,anon_ptr.,8> U8INTCONST 0 (0x0) I4U8EQ THEN BLOCK LOC 1 97 return; RETURN END_BLOCK ELSE LOC 1 96 BLOCK END_BLOCK END_IF

LOC 1 94 void inorder_traverse_tree(struct tn *tree_ptr) LOC 1 95 {FUNC_ENTRY <1,25,inorder_traverse_tree> IDNAME 0 <2,1,tree_ptr>BODY BLOCK END_BLOCK BLOCK END_BLOCK BLOCK PRAGMA 0 120 <null-st> 0 (0x0) # PREAMBLE_END LOC 1 96 if(tree_ptr == NULL) IF U8U8LDID 0 <2,1,tree_ptr> T<32,anon_ptr.,8> U8INTCONST 0 (0x0) I4U8EQ THEN BLOCK LOC 1 97 return; RETURN END_BLOCK ELSE LOC 1 96 BLOCK END_BLOCK END_IF

LOC 1 100 LOC 1 101 inorder_traverse_tree(tree_ptr->left); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 8 T<30,tn,8> T<31,anon_ptr.,8> <field_id:2> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags 0x7e LOC 1 102 tree_ptr->data++; U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4I4ILOAD 0 T<30,tn,8> T<31,anon_ptr.,8> <field_id:1> I4INTCONST 1 (0x1) I4ADD U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4ISTORE 0 T<31,anon_ptr.,8> <field_id:1> LOC 1 103 inorder_traverse_tree(tree_ptr->right); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 16 T<30,tn,8> T<31,anon_ptr.,8> <field_id:3> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags 0x7e RETURN END_BLOCK

Page 39: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

How do we identify tree references?

How do we identify tree references?

LOC 1 94 void inorder_traverse_tree(struct tn *tree_ptr) LOC 1 95 {FUNC_ENTRY <1,25,inorder_traverse_tree> IDNAME 0 <2,1,tree_ptr>BODY BLOCK END_BLOCK BLOCK END_BLOCK BLOCK PRAGMA 0 120 <null-st> 0 (0x0) # PREAMBLE_END LOC 1 96 if(tree_ptr == NULL) IF U8U8LDID 0 <2,1,tree_ptr> T<32,anon_ptr.,8> U8INTCONST 0 (0x0) I4U8EQ THEN BLOCK LOC 1 97 return; RETURN END_BLOCK ELSE LOC 1 96 BLOCK END_BLOCK END_IF

LOC 1 94 void inorder_traverse_tree(struct tn *tree_ptr) LOC 1 95 {FUNC_ENTRY <1,25,inorder_traverse_tree> IDNAME 0 <2,1,tree_ptr>BODY BLOCK END_BLOCK BLOCK END_BLOCK BLOCK PRAGMA 0 120 <null-st> 0 (0x0) # PREAMBLE_END LOC 1 96 if(tree_ptr == NULL) IF U8U8LDID 0 <2,1,tree_ptr> T<32,anon_ptr.,8> U8INTCONST 0 (0x0) I4U8EQ THEN BLOCK LOC 1 97 return; RETURN END_BLOCK ELSE LOC 1 96 BLOCK END_BLOCK END_IF

LOC 1 100 LOC 1 101 inorder_traverse_tree(tree_ptr->left); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 8 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:2> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags

0x7e LOC 1 102 tree_ptr->data++; U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4I4ILOAD 0 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:1> I4INTCONST 1 (0x1) I4ADD U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4ISTORE 0 T<31,anon_ptr.,8> <field_id:1> LOC 1 103 inorder_traverse_tree(tree_ptr->right); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 16 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:3> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags

0x7e RETURN END_BLOCK

FUNC_ENTRY(inorder_traverse_tree)

IDNAME(tree_ptr)

BLOCK BLOCK BLOCK

LOC 1 94 void inorder_traverse_tree(struct tn *tree_ptr)

LOC 1 95 {

FUNC_ENTRY <1,25,inorder_traverse_tree>

IDNAME 0 <2,1,tree_ptr>

BODY

BLOCK

END_BLOCK

BLOCK

END_BLOCK

BLOCK

void inorder_traverse_tree(struct tn *tree_ptr)

Page 40: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

How do we identify tree references?

How do we identify tree references?

LOC 1 94 void inorder_traverse_tree(struct tn *tree_ptr) LOC 1 95 {FUNC_ENTRY <1,25,inorder_traverse_tree> IDNAME 0 <2,1,tree_ptr>BODY BLOCK END_BLOCK BLOCK END_BLOCK BLOCK PRAGMA 0 120 <null-st> 0 (0x0) # PREAMBLE_END LOC 1 96 if(tree_ptr == NULL) IF U8U8LDID 0 <2,1,tree_ptr> T<32,anon_ptr.,8> U8INTCONST 0 (0x0) I4U8EQ THEN BLOCK LOC 1 97 return; RETURN END_BLOCK ELSE LOC 1 96 BLOCK END_BLOCK END_IF

LOC 1 94 void inorder_traverse_tree(struct tn *tree_ptr) LOC 1 95 {FUNC_ENTRY <1,25,inorder_traverse_tree> IDNAME 0 <2,1,tree_ptr>BODY BLOCK END_BLOCK BLOCK END_BLOCK BLOCK PRAGMA 0 120 <null-st> 0 (0x0) # PREAMBLE_END LOC 1 96 if(tree_ptr == NULL) IF U8U8LDID 0 <2,1,tree_ptr> T<32,anon_ptr.,8> U8INTCONST 0 (0x0) I4U8EQ THEN BLOCK LOC 1 97 return; RETURN END_BLOCK ELSE LOC 1 96 BLOCK END_BLOCK END_IF

LOC 1 100 LOC 1 101 inorder_traverse_tree(tree_ptr->left); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 8 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:2> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags

0x7e LOC 1 102 tree_ptr->data++; U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4I4ILOAD 0 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:1> I4INTCONST 1 (0x1) I4ADD U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4ISTORE 0 T<31,anon_ptr.,8> <field_id:1> LOC 1 103 inorder_traverse_tree(tree_ptr->right); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 16 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:3> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags

0x7e RETURN END_BLOCK

FUNC_ENTRY(inorder_traverse_tree)

IDNAME(tree_ptr)

BLOCK BLOCK BLOCK

IF

EQ

LDID(tree_ptr)

INTCONST 0x0

RETURN

BLOCK(then)

LOC 1 96 if(tree_ptr == NULL)

IF

U8U8LDID 0 <2,1,tree_ptr> T<32,anon_ptr.,8>

U8INTCONST 0 (0x0)

I4U8EQ

THEN

BLOCK

LOC 1 97 return;

RETURN

END_BLOCK

if(tree_ptr == NULL)

Page 41: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

How do we identify tree references?

How do we identify tree references?

LOC 1 94 void inorder_traverse_tree(struct tn *tree_ptr) LOC 1 95 {FUNC_ENTRY <1,25,inorder_traverse_tree> IDNAME 0 <2,1,tree_ptr>BODY BLOCK END_BLOCK BLOCK END_BLOCK BLOCK PRAGMA 0 120 <null-st> 0 (0x0) # PREAMBLE_END LOC 1 96 if(tree_ptr == NULL) IF U8U8LDID 0 <2,1,tree_ptr> T<32,anon_ptr.,8> U8INTCONST 0 (0x0) I4U8EQ THEN BLOCK LOC 1 97 return; RETURN END_BLOCK ELSE LOC 1 96 BLOCK END_BLOCK END_IF

LOC 1 94 void inorder_traverse_tree(struct tn *tree_ptr) LOC 1 95 {FUNC_ENTRY <1,25,inorder_traverse_tree> IDNAME 0 <2,1,tree_ptr>BODY BLOCK END_BLOCK BLOCK END_BLOCK BLOCK PRAGMA 0 120 <null-st> 0 (0x0) # PREAMBLE_END LOC 1 96 if(tree_ptr == NULL) IF U8U8LDID 0 <2,1,tree_ptr> T<32,anon_ptr.,8> U8INTCONST 0 (0x0) I4U8EQ THEN BLOCK LOC 1 97 return; RETURN END_BLOCK ELSE LOC 1 96 BLOCK END_BLOCK END_IF

LOC 1 100 LOC 1 101 inorder_traverse_tree(tree_ptr->left); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 8 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:2> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags

0x7e LOC 1 102 tree_ptr->data++; U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4I4ILOAD 0 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:1> I4INTCONST 1 (0x1) I4ADD U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4ISTORE 0 T<31,anon_ptr.,8> <field_id:1> LOC 1 103 inorder_traverse_tree(tree_ptr->right); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 16 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:3> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags

0x7e RETURN END_BLOCK

BLOCK

VCALL

PARAM

ILOAD (offset 8)

LDID(tree_ptr)

LOC 1 101 inorder_traverse_tree(tree_ptr->left); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 8 T<30,tn,8> T<31,anon_ptr.,8> <field_id:2> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags 0x7e

inorder_traverse_tree(tree_ptr->left);

Page 42: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

How do we identify tree references?

How do we identify tree references?

LOC 1 94 void inorder_traverse_tree(struct tn *tree_ptr) LOC 1 95 {FUNC_ENTRY <1,25,inorder_traverse_tree> IDNAME 0 <2,1,tree_ptr>BODY BLOCK END_BLOCK BLOCK END_BLOCK BLOCK PRAGMA 0 120 <null-st> 0 (0x0) # PREAMBLE_END LOC 1 96 if(tree_ptr == NULL) IF U8U8LDID 0 <2,1,tree_ptr> T<32,anon_ptr.,8> U8INTCONST 0 (0x0) I4U8EQ THEN BLOCK LOC 1 97 return; RETURN END_BLOCK ELSE LOC 1 96 BLOCK END_BLOCK END_IF

LOC 1 94 void inorder_traverse_tree(struct tn *tree_ptr) LOC 1 95 {FUNC_ENTRY <1,25,inorder_traverse_tree> IDNAME 0 <2,1,tree_ptr>BODY BLOCK END_BLOCK BLOCK END_BLOCK BLOCK PRAGMA 0 120 <null-st> 0 (0x0) # PREAMBLE_END LOC 1 96 if(tree_ptr == NULL) IF U8U8LDID 0 <2,1,tree_ptr> T<32,anon_ptr.,8> U8INTCONST 0 (0x0) I4U8EQ THEN BLOCK LOC 1 97 return; RETURN END_BLOCK ELSE LOC 1 96 BLOCK END_BLOCK END_IF

LOC 1 100 LOC 1 101 inorder_traverse_tree(tree_ptr->left); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 8 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:2> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags

0x7e LOC 1 102 tree_ptr->data++; U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4I4ILOAD 0 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:1> I4INTCONST 1 (0x1) I4ADD U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4ISTORE 0 T<31,anon_ptr.,8> <field_id:1> LOC 1 103 inorder_traverse_tree(tree_ptr->right); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 16 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:3> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags

0x7e RETURN END_BLOCK

BLOCK

VCALL

PARAM

ILOAD (offset 8)

LDID(tree_ptr)

ISTORE (offset 8)

LDID(tree_ptr)

ADD

INTCONST 0x1

ILOAD (offset 0)

LDID(tree_ptr)

LOC 1 102 tree_ptr->data++; U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4I4ILOAD 0 T<30,tn,8> T<31,anon_ptr.,8> <field_id:1> I4INTCONST 1 (0x1) I4ADD U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4ISTORE 0 T<31,anon_ptr.,8> <field_id:1>

tree_ptr->data++;

Page 43: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

How do we identify tree references?

How do we identify tree references?

LOC 1 94 void inorder_traverse_tree(struct tn *tree_ptr) LOC 1 95 {FUNC_ENTRY <1,25,inorder_traverse_tree> IDNAME 0 <2,1,tree_ptr>BODY BLOCK END_BLOCK BLOCK END_BLOCK BLOCK PRAGMA 0 120 <null-st> 0 (0x0) # PREAMBLE_END LOC 1 96 if(tree_ptr == NULL) IF U8U8LDID 0 <2,1,tree_ptr> T<32,anon_ptr.,8> U8INTCONST 0 (0x0) I4U8EQ THEN BLOCK LOC 1 97 return; RETURN END_BLOCK ELSE LOC 1 96 BLOCK END_BLOCK END_IF

LOC 1 94 void inorder_traverse_tree(struct tn *tree_ptr) LOC 1 95 {FUNC_ENTRY <1,25,inorder_traverse_tree> IDNAME 0 <2,1,tree_ptr>BODY BLOCK END_BLOCK BLOCK END_BLOCK BLOCK PRAGMA 0 120 <null-st> 0 (0x0) # PREAMBLE_END LOC 1 96 if(tree_ptr == NULL) IF U8U8LDID 0 <2,1,tree_ptr> T<32,anon_ptr.,8> U8INTCONST 0 (0x0) I4U8EQ THEN BLOCK LOC 1 97 return; RETURN END_BLOCK ELSE LOC 1 96 BLOCK END_BLOCK END_IF

LOC 1 100 LOC 1 101 inorder_traverse_tree(tree_ptr->left); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 8 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:2> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags

0x7e LOC 1 102 tree_ptr->data++; U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4I4ILOAD 0 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:1> I4INTCONST 1 (0x1) I4ADD U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4ISTORE 0 T<31,anon_ptr.,8> <field_id:1> LOC 1 103 inorder_traverse_tree(tree_ptr->right); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 16 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:3> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags

0x7e RETURN END_BLOCK

BLOCK

VCALL

PARAM

ILOAD (offset 8)

LDID(tree_ptr)

VCALL

PARAM

ILOAD (offset 16)

LDID(tree_ptr)

ISTORE (offset 8)

LDID(tree_ptr)

ADD

INTCONST 0x1

ILOAD (offset 0)

LDID(tree_ptr)

LOC 1 103 inorder_traverse_tree(tree_ptr->right); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 16 T<30,tn,8> T<31,anon_ptr.,8> <field_id:3> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags 0x7e

inorder_traverse_tree(tree_ptr->right);

Page 44: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

How do we identify tree references?

How do we identify tree references?

LOC 1 94 void inorder_traverse_tree(struct tn *tree_ptr) LOC 1 95 {FUNC_ENTRY <1,25,inorder_traverse_tree> IDNAME 0 <2,1,tree_ptr>BODY BLOCK END_BLOCK BLOCK END_BLOCK BLOCK PRAGMA 0 120 <null-st> 0 (0x0) # PREAMBLE_END LOC 1 96 if(tree_ptr == NULL) IF U8U8LDID 0 <2,1,tree_ptr> T<32,anon_ptr.,8> U8INTCONST 0 (0x0) I4U8EQ THEN BLOCK LOC 1 97 return; RETURN END_BLOCK ELSE LOC 1 96 BLOCK END_BLOCK END_IF

LOC 1 94 void inorder_traverse_tree(struct tn *tree_ptr) LOC 1 95 {FUNC_ENTRY <1,25,inorder_traverse_tree> IDNAME 0 <2,1,tree_ptr>BODY BLOCK END_BLOCK BLOCK END_BLOCK BLOCK PRAGMA 0 120 <null-st> 0 (0x0) # PREAMBLE_END LOC 1 96 if(tree_ptr == NULL) IF U8U8LDID 0 <2,1,tree_ptr> T<32,anon_ptr.,8> U8INTCONST 0 (0x0) I4U8EQ THEN BLOCK LOC 1 97 return; RETURN END_BLOCK ELSE LOC 1 96 BLOCK END_BLOCK END_IF

LOC 1 100 LOC 1 101 inorder_traverse_tree(tree_ptr->left); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 8 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:2> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags

0x7e LOC 1 102 tree_ptr->data++; U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4I4ILOAD 0 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:1> I4INTCONST 1 (0x1) I4ADD U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4ISTORE 0 T<31,anon_ptr.,8> <field_id:1> LOC 1 103 inorder_traverse_tree(tree_ptr->right); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 16 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:3> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags

0x7e RETURN END_BLOCK

BLOCK

VCALL

PARAM

ILOAD (offset 8)

LDID(tree_ptr)

VCALL

PARAM

ILOAD (offset 16)

LDID(tree_ptr)

ISTORE (offset 8)

LDID(tree_ptr)

ADD

INTCONST 0x1

ILOAD (offset 0)

LDID(tree_ptr)

FUNC_ENTRY(inorder_traverse_tree)

IDNAME(tree_ptr)

BLOCK BLOCK

IF

EQ

LDID INTCONST 0x0

RETURN

BLOCK(then)

Page 45: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

How do we identify tree references?

How do we identify tree references?

LOC 1 94 void inorder_traverse_tree(struct tn *tree_ptr) LOC 1 95 {FUNC_ENTRY <1,25,inorder_traverse_tree> IDNAME 0 <2,1,tree_ptr>BODY BLOCK END_BLOCK BLOCK END_BLOCK BLOCK PRAGMA 0 120 <null-st> 0 (0x0) # PREAMBLE_END LOC 1 96 if(tree_ptr == NULL) IF U8U8LDID 0 <2,1,tree_ptr> T<32,anon_ptr.,8> U8INTCONST 0 (0x0) I4U8EQ THEN BLOCK LOC 1 97 return; RETURN END_BLOCK ELSE LOC 1 96 BLOCK END_BLOCK END_IF

LOC 1 94 void inorder_traverse_tree(struct tn *tree_ptr) LOC 1 95 {FUNC_ENTRY <1,25,inorder_traverse_tree> IDNAME 0 <2,1,tree_ptr>BODY BLOCK END_BLOCK BLOCK END_BLOCK BLOCK PRAGMA 0 120 <null-st> 0 (0x0) # PREAMBLE_END LOC 1 96 if(tree_ptr == NULL) IF U8U8LDID 0 <2,1,tree_ptr> T<32,anon_ptr.,8> U8INTCONST 0 (0x0) I4U8EQ THEN BLOCK LOC 1 97 return; RETURN END_BLOCK ELSE LOC 1 96 BLOCK END_BLOCK END_IF

LOC 1 100 LOC 1 101 inorder_traverse_tree(tree_ptr->left); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 8 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:2> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags

0x7e LOC 1 102 tree_ptr->data++; U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4I4ILOAD 0 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:1> I4INTCONST 1 (0x1) I4ADD U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4ISTORE 0 T<31,anon_ptr.,8> <field_id:1> LOC 1 103 inorder_traverse_tree(tree_ptr->right); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 16 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:3> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags

0x7e RETURN END_BLOCK

BLOCK

VCALL

PARAM

VCALL

PARAM

ISTORE (offset 8)

LDID(tree_ptr)

ADD

INTCONST 0x1

FUNC_ENTRY(inorder_traverse_tree)

IDNAME(tree_ptr)

BLOCK BLOCK

IF

EQ

LDID INTCONST 0x0

RETURN

BLOCK(then)

Where do we access trees in memory?

ILOAD (offset 8)

LDID(tree_ptr)

ILOAD (offset 16)

LDID(tree_ptr)

ILOAD (offset 0)

LDID(tree_ptr)

Page 46: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

How do we identify tree references?

How do we identify tree references?

LOC 1 94 void inorder_traverse_tree(struct tn *tree_ptr) LOC 1 95 {FUNC_ENTRY <1,25,inorder_traverse_tree> IDNAME 0 <2,1,tree_ptr>BODY BLOCK END_BLOCK BLOCK END_BLOCK BLOCK PRAGMA 0 120 <null-st> 0 (0x0) # PREAMBLE_END LOC 1 96 if(tree_ptr == NULL) IF U8U8LDID 0 <2,1,tree_ptr> T<32,anon_ptr.,8> U8INTCONST 0 (0x0) I4U8EQ THEN BLOCK LOC 1 97 return; RETURN END_BLOCK ELSE LOC 1 96 BLOCK END_BLOCK END_IF

LOC 1 94 void inorder_traverse_tree(struct tn *tree_ptr) LOC 1 95 {FUNC_ENTRY <1,25,inorder_traverse_tree> IDNAME 0 <2,1,tree_ptr>BODY BLOCK END_BLOCK BLOCK END_BLOCK BLOCK PRAGMA 0 120 <null-st> 0 (0x0) # PREAMBLE_END LOC 1 96 if(tree_ptr == NULL) IF U8U8LDID 0 <2,1,tree_ptr> T<32,anon_ptr.,8> U8INTCONST 0 (0x0) I4U8EQ THEN BLOCK LOC 1 97 return; RETURN END_BLOCK ELSE LOC 1 96 BLOCK END_BLOCK END_IF

LOC 1 100 LOC 1 101 inorder_traverse_tree(tree_ptr->left); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 8 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:2> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags

0x7e LOC 1 102 tree_ptr->data++; U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4I4ILOAD 0 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:1> I4INTCONST 1 (0x1) I4ADD U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> I4ISTORE 0 T<31,anon_ptr.,8> <field_id:1> LOC 1 103 inorder_traverse_tree(tree_ptr->right); U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 16 T<30,tn,8> T<31,anon_ptr.,8>

<field_id:3> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,25,inorder_traverse_tree> # flags

0x7e RETURN END_BLOCK

BLOCK

VCALL

PARAM

VCALL

PARAM

ISTORE (offset 8)

LDID(tree_ptr)

ADD

INTCONST 0x1

FUNC_ENTRY(inorder_traverse_tree)

IDNAME(tree_ptr)

BLOCK BLOCK

IF

EQ

LDID INTCONST 0x0

RETURN

BLOCK(then)

This is where our extension to the ORC inserts code into the WHIRL Tree.

ILOAD (offset 8)

LDID(tree_ptr)

ILOAD (offset 16)

LDID(tree_ptr)

ILOAD (offset 0)

LDID(tree_ptr)

Page 47: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

The Nodes we Insert Into WHIRLThe Nodes we Insert Into WHIRL

U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8PARM 2 T<31,anon_ptr.,8> # by_value U4INTCONST 1 (0x1) U4PARM 2 T<8,.predef_U4,4> # by_value U4INTCONST 2 (0x2) U4PARM 2 T<8,.predef_U4,4> # by_value U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 8 T<31,anon_ptr.,8> T<34,anon_ptr.,8> U8PARM 2 T<31,anon_ptr.,8> # by_value U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 16 T<31,anon_ptr.,8> T<34,anon_ptr.,8> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,21,register_access_with_children> # flags 0x7e

U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8PARM 2 T<31,anon_ptr.,8> # by_value U4INTCONST 1 (0x1) U4PARM 2 T<8,.predef_U4,4> # by_value U4INTCONST 2 (0x2) U4PARM 2 T<8,.predef_U4,4> # by_value U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 8 T<31,anon_ptr.,8> T<34,anon_ptr.,8> U8PARM 2 T<31,anon_ptr.,8> # by_value U8U8LDID 0 <2,1,tree_ptr> T<31,anon_ptr.,8> U8U8ILOAD 16 T<31,anon_ptr.,8> T<34,anon_ptr.,8> U8PARM 2 T<31,anon_ptr.,8> # by_value VCALL 126 <1,21,register_access_with_children> # flags 0x7e

Page 48: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

The Nodes we Insert Into WHIRLThe Nodes we Insert Into WHIRL

VCALL(register_tree_access_with_children)

ILOAD(offset 16)

ILOAD(offset 8)

PARM PARM PARM PARM

INTCONST0x1

INTCONST0x2

LDID(tree_ptr)

LDID(tree_ptr)

PARM

LDID(tree_ptr)

Page 49: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Experimental SetupExperimental Setup

Open Research Compiler v2.1 Optimization level -O3

1.3 GHz Itanium21 GB of RAM

Open Research Compiler v2.1 Optimization level -O3

1.3 GHz Itanium21 GB of RAM

Page 50: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Analysis Results (Synthetic Benchmark)

Analysis Results (Synthetic Benchmark)

BenchmarkOrientation Score

Expected ExperimentalRandom Depth 1.0 1.000000Breadth-First -1.0 -0.999992Depth-Breadth 0.0 0.000000Non-Standard 0.0 0.136381Multi Depth 1.0 0.999974Breadth Search -1.0 -0.995669Binary Search 1.0 0.941225

Page 51: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Analysis Results (Olden Benchmark)

Analysis Results (Olden Benchmark)

BenchmarkOrientation Score

Expected ExperimentalBH 0.0 0.010266Bisort 0.0 -0.001014Health 1.0 0.807330MST Low positive 0.335852 Perimeter Low positive 0.195177Power 1.0 0.991617Treeadd 1.0 1.000000TSP Low positive 0.173267

Page 52: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Runtime Overhead (Synthetic Benchmark)

Runtime Overhead (Synthetic Benchmark)

BenchmarkRuntime (s)

Original InstrumentedRandom Depth 0.90 10.72Breadth-First 1.09 1.81Depth-Breadth 1.33 7.84Non-Standard 0.36 2.68Multi Depth 0.47 3.94 Breadth Search 0.36 1.83Binary Search 0.20 2.75

Page 53: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Runtime Overhead (Olden Benchmark)

Runtime Overhead (Olden Benchmark)

BenchmarkRuntime (s)

Original InstrumentedBH 0.45 6.88Bisort 0.03 1.01Health 0.05 12.06MST 5.71 11.42Perimeter 0.02 1.55Power 1.35 1.60Treeadd 0.13 6.35TSP 0.01 1.40

Page 54: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Memory Overhead (Synthetic Benchmark)

Memory Overhead (Synthetic Benchmark)

BenchmarkMemory Usage (kbytes)

Original InstrumentedRandom Depth 854 976 855 040 Breadth-First 424 928 441 328 Depth-Breadth 220 112 252 896Non-Standard 420 800 420 912Multi Depth 529 344 652 288Breadth Search 30 192 47 408Binary Search 224 192 224 320

Page 55: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Memory Overhead (Olden Benchmark)

Memory Overhead (Olden Benchmark)

BenchmarkMemory Usage (kbytes)

Original InstrumentedBH 3 520 3 520Bisort 3 008 3 040Health 8 448 8 624MST 4 752 6 272Perimeter 6 064 6 528Power 3 648 3 712Treeadd 3 008 3 008TSP 3 024 3 040

Page 56: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

ConclusionConclusion

Developed an efficient analysis to automatically determine the orientation of tree traversals Instrumented applications only require 7%

more memory

Developed an efficient analysis to automatically determine the orientation of tree traversals Instrumented applications only require 7%

more memory

Page 57: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

Questions?Questions?

Page 58: Determining Tree-Traversals Orientation using Feedback-Directed Analysis Stephen Curial, Kevin Andrusky and José Nelson Amaral University of Alberta Stephen.

ReferencesReferences

[1] Jason Patterson. Modern Microprocessors A 90 Minute Guide! http://www.pattosoft.com.au/Articles/ModernMicroprocessors/

[2] R. Ghiya, L. J. Hendren. Is it a tree, a dag, or a cyclic graph? A shape analysis for heap directed pointers in C. POPL 1996

[1] Jason Patterson. Modern Microprocessors A 90 Minute Guide! http://www.pattosoft.com.au/Articles/ModernMicroprocessors/

[2] R. Ghiya, L. J. Hendren. Is it a tree, a dag, or a cyclic graph? A shape analysis for heap directed pointers in C. POPL 1996