IT lexicon › Programming › Call graph

Call graph

Programming På svenska → Updated: 2026-11-05

A graph whose nodes are a program's functions and whose edges mean one may call the other.

For direct calls the graph is trivial to build. The hard part is the indirect ones: function pointers, virtual methods, callbacks. There the compiler has to guess conservatively, using class hierarchy analysis or points-to analysis, and every uncertain edge makes the graph bigger and the analyses weaker. A static call graph is therefore an overestimate of what could happen, while a dynamic one, recorded at run time, shows only what happened that particular time.

Interprocedural optimisation walks the graph bottom-up, so each function is analysed after the ones it calls. Recursion shows up as strongly connected components that have to be handled as a lump. Berkeley's gprof profiler in 1982 turned the graph into a tool for ordinary programmers; callgrind and flame graphs are its descendants.

← Back to the lexicon