Open adonovan opened 1 week ago
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Change https://go.dev/cl/609281 mentions this issue: go/callgraph/cha: make CHA, VTA faster and more precise
... // First, we tabulate a set of initial functions and runtime types // from each package in the program.
I guess you mean pkgs
here?
... // For best results, provide a Program constructed with the // [ssa.InstantiateGenerics] mode flag. func Reachable(pkgs []ssa.Package) (functions map[ssa.Function]bool, runtimeTypes *typeutil.Map)
Ditto?
Change https://go.dev/cl/610939 mentions this issue: go/ssa: extract type recursion into a helper package
Change https://go.dev/cl/611535 mentions this issue: internal/callgraph/chautil: add Reachable function
This proposal has been added to the active column of the proposals project and will now be reviewed at the weekly proposal review meetings. — rsc for the proposal review group
Background: The existing
ssautil.AllFunctions
helper performs a reachability analysis starting from all the packages in a Go SSA program, and returns the set of functions it encounters:Unfortunately it is poorly defined and its implementation is a bit of a historical mess; it is complicated and delivers results that are simultaneously "too much" (imprecise) and "too little" (unsound).
An example of imprecision is that it searches the body of every function in the ssa.Program for MakeInterface operations, when only those functions that are reachable from the entry points need be considered. Another example is that it uses all packages of the program as roots for reachability, even though typically the program consists of all dependencies of a few packages of interest.
An example of unsoundness is that it doesn't consider all of the types derivable from the public API of a package as potential dynamic call targets.
Furthermore, its traversal is a lost opportunity to to track information ("address-taken" status of functions) that would be useful to CHA and VTA.
Proposal: We propose to add a new function
ssautil.Reachable
that:We plan to redefine the existing
AllFunctions
as a shallow wrapper around the new function.@timothy-king @zpavlinovic