From 6357e7985863fa1240d8448ef861c9f14158fa59 Mon Sep 17 00:00:00 2001 From: Chris O'Hara Date: Fri, 22 Sep 2023 09:08:49 -0700 Subject: [PATCH] Improve call graph --- compiler/compile.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/compile.go b/compiler/compile.go index 1b0f4ec..1bcd4eb 100644 --- a/compiler/compile.go +++ b/compiler/compile.go @@ -14,6 +14,7 @@ import ( "golang.org/x/tools/go/ast/astutil" "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" "golang.org/x/tools/go/ssa/ssautil" @@ -117,11 +118,11 @@ func (c *compiler) compile(path string) error { } log.Printf("building SSA program") - prog, _ := ssautil.Packages(pkgs, ssa.InstantiateGenerics|ssa.GlobalDebug) + prog, _ := ssautil.AllPackages(pkgs, ssa.InstantiateGenerics|ssa.GlobalDebug) prog.Build() log.Printf("building call graph") - cg := cha.CallGraph(prog) + cg := vta.CallGraph(ssautil.AllFunctions(prog), cha.CallGraph(prog)) log.Printf("finding generic yield instantiations") var coroutinePkg *packages.Package