Skip to content

Commit

Permalink
analyzer: use the memory-optimized version of CHA
Browse files Browse the repository at this point in the history
Passing nil as the "initial" argument of vta.CallGraph uses the new
internal version of the cha algorithm which stores its output graph
implicitly.  This saves time and memory for large callgraphs.
  • Loading branch information
jcd committed Nov 24, 2024
1 parent 386e081 commit 7561484
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions analyzer/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (

cpb "github.com/google/capslock/proto"
"golang.org/x/tools/go/callgraph"
"golang.org/x/tools/go/callgraph/cha"
"golang.org/x/tools/go/callgraph/vta"
"golang.org/x/tools/go/packages"
"golang.org/x/tools/go/ssa"
Expand Down Expand Up @@ -205,9 +204,8 @@ func buildGraph(pkgs []*packages.Package, populateSyntax bool) (*callgraph.Graph
}
ssaProg, _ := ssautil.AllPackages(pkgs, ssaBuilderMode)
ssaProg.Build()
graph := cha.CallGraph(ssaProg)
allFunctions := ssautil.AllFunctions(ssaProg)
graph = vta.CallGraph(allFunctions, graph)
graph := vta.CallGraph(allFunctions, nil)
return graph, ssaProg, allFunctions
}

Expand Down

0 comments on commit 7561484

Please sign in to comment.