This module defines a call graph and related functions. The call
graph is a static view of the calls between functions in a
Module. The nodes of the graph are global functions and the
edges are calls made to other functions.
This call graph attempts to provide as much information as possible about calls through function pointers. Direct calls have a single outgoing edge. Indirect calls that can be augmented with information from a points-to analysis can induce many IndirectCall edges.
For now, all indirect calls also induce an UnknownCall edge, under the assumption that externally-obtained function pointers may also be called somehow. This restriction will eventually be lifted and indirect calls that can be identified as completely internal will not have the UnknownCall edge. The preconditions for this will be:
Modulemust have an entry point (otherwise it is a library)
- The function pointer must not be able to alias the result of a dlopen or similar call
Again, the more sophisticated callgraph is still pending.
- data CallGraph
- callGraph :: PointsToAnalysis a => Module -> a -> [Function] -> CallGraph
- callValueTargets :: CallGraph -> Value -> [Value]
- callSiteTargets :: CallGraph -> Instruction -> [Value]
- callGraphFunctions :: CallGraph -> [Function]
- functionCallees :: CallGraph -> Function -> [Value]
- allFunctionCallees :: CallGraph -> Function -> [Value]
- functionCallers :: CallGraph -> Function -> [Value]
- allFunctionCallers :: CallGraph -> Function -> [Value]
An opaque wrapper for the callgraph. The nodes are functions and the edges are calls between them.
|:: PointsToAnalysis a|
A points-to analysis (to resolve function pointers)
The entry points to the
Build a call graph for the given
Module using a pre-computed
points-to analysis. The String parameter identifies the program
entryPoint is not respected.
FIXME: Function pointers can be bitcasted - be sure to respect those when adding indirect edges.
Given the value called by a Call or Invoke instruction, return all of the possible Functions or ExternalFunctions that it could be.
Given a Call or Invoke instruction, return the list of possible callees. All returned Values will be either Functions or ExternalFunctions.
Passing a non-call/invoke instruction will trigger a noisy pattern matching failure.
Get all of the functions defined in this module from the CallGraph