Algorithm 7.2 Interprocedural Context-Insensitive Whole-Program Pointer Analysis
Input: Entry method .
Output: Pointer flow graph and point-to set of and call graph .
1: // work list, initialized as empty
2: // pointer flow graph, initialized as empty
3: // set of reachable statements, initialized as empty
4: // set of reachable methods, initialized as empty
5: // 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: // poinrt-to set of each 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:add to
47:if then
48:add to
49:AddReachable()
50:for each parameter of do
51:AddEdge()
52:end for
53:AddEdge()
54:end if
55:end for
56:end procedure