Interprocedural analysis (IPA)¶
GCC builds a “call graph”, recording which functions call which other functions, and it uses this for various optimizations.
It is constructed by the “*build_cgraph_edges” pass.
In case it’s of interest, it is available via the following Python API:
-
gcc.get_callgraph_nodes()¶ Get a list of all
gcc.CallgraphNodeinstances
-
gccutils.callgraph_to_dot()¶ Return the GraphViz source for a rendering of the current callgraph, as a string.
Here’s an example of such a rendering:
-
class
gcc.CallgraphNode¶ -
decl¶ The
gcc.FunctionDeclfor this node within the callgraph
-
callees¶ The function calls made by this function, as a list of
gcc.CallgraphEdgeinstances
-
callers¶ The places that call this function, as a list of
gcc.CallgraphEdgeinstances
Internally, this wraps a struct cgraph_node *
-
-
class
gcc.CallgraphEdge¶ -
caller¶ The function that makes this call, as a
gcc.CallgraphNode
-
callee¶ The function that is called here, as a
gcc.CallgraphNode
-
call_stmt¶ The
gcc.GimpleCallstatememt for the function call
Internally, this wraps a struct cgraph_edge *
-