git @ Cat's Eye Technologies SixtyPical / 894fb1a
Refine the callgraph algorithm. Still incomplete though. Chris Pressey 3 years ago
1 changed file(s) with 20 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
5050 sys.stdout.write("\n")
5151
5252 if options.dump_callgraph:
53 graph = {}
54
5355 for routine in program.routines:
54 sys.stdout.write('-----------\n')
55 sys.stdout.write('{}\n'.format(routine.name))
56 potentially_calls = []
5657 for called_routine in routine.called_routines:
57 sys.stdout.write(' {}\n'.format(called_routine.name))
58 # TODO if called_routine is a vector, this should be all routines which can be assigned to this vector
59 potentially_calls.append(called_routine.name)
60 graph[routine.name] = {
61 'potentially-calls': potentially_calls,
62 }
63
64 # Reflexive closure
65
66 for routine in program.routines:
67 potentially_called_by = []
68 for (name, node) in graph.items():
69 potential_calls = node['potentially-calls']
70 if routine.name in potential_calls:
71 potentially_called_by.append(name)
72 graph[routine.name]['potentially-called-by'] = potentially_called_by
73
74 sys.stdout.write(json.dumps(graph, indent=4, sort_keys=True, separators=(',', ':')))
5875
5976 compilation_roster = None
6077 if options.optimize_fallthru: