Algorithm 8.1 Interprocedural Context-Sensitive Whole-Program Pointer Analysis
Input: Entry method and a context generator Select().
Output: Pointer flow graph and point-to set of and call graph , all context-sensitive.
1: // work list, initialized as empty
2: // context-sensitive pointer flow graph, initialized as empty
3: // set of reachable statements, initialized as empty
4: // set of context-sensitive reachable methods, initialized as empty
5: // context-sensitive call graph, initialized as empty
6:
7:procedure Solve() // main algorithm
8:AddReachable()
9:while is not empty do
10:remove from
11:
12:Propagate()
13:if represents a variable then
14:for each do
15:for each do
16:AddEdge()
17:end for
18:for each do
19:AddEdge()
20:end for
21:ProcessCall()
22:end for
23:end if
24:end while
25:end procedure
26:
27:procedure AddReachable()
28:if then
29:add to
30: // is the set of statements in method .
31:for each pointer do
32: // point-to set of each context-sensitive pointer, initialized as empty
33:end for
34:for each do
35:add to
36:end for
37:for each do
38:AddEdge()
39:end for
40:end if
41:end procedure
42:
43:procedure ProcessCall()
44:for each do
45: Dispatch()
46: Select()
47:add to
48:if then
49:add to
50:AddReachable()
51:for each parameter of do
52:AddEdge()
53:end for
54:AddEdge()
55:end if
56:end for
57:end procedure