A tool that prints the SSA representation of packages and/or functions.
Install the tool:
go install github.com/stealthrocket/ssa@latest
Print a summary of members in a package
ssa path/to/go/package
Print the SSA form of one or more functions/methods in a package:
ssa path/to/go/package Function SomeOtherFunction SomeOtherMethod
This prints the golang.org/x/tools/go/ssa
representation,
which is not the same as the SSA form that the Go compiler
uses (cmd/compile/internal/ssa
).
See:
- https://pkg.go.dev/golang.org/x/tools/go/ssa
- https://github.com/golang/go/blob/master/src/cmd/compile/README.md
A related tool is x/tools/cmd/callgraph, which prints the callgraph for a set of packages. It uses the same SSA form for its analysis.
go install golang.org/x/tools/cmd/callgraph@latest