Documentation
¶
Overview ¶
Package goescape analyzes Go storage lifetimes before LLVM lowering. The location graph and solver adapt Go 1.27.3's cmd/compile/internal/escape/{graph,solve,leaks}.go to a frontend-independent representation. SSA construction and backend placement are separate layers.
Index ¶
- Constants
- func ValidSummary(fn *ssa.Function, s Summary) bool
- type Cache
- type Config
- type Decision
- type Effect
- type Parameter
- type Result
- func (r *Result) CaptureByValue(v *ssa.FreeVar) bool
- func (r *Result) ComponentKey(fn *ssa.Function) string
- func (r *Result) Decision(site ssa.Instruction) Decision
- func (r *Result) LookupDecision(site ssa.Instruction) (Decision, bool)
- func (r *Result) StackBytes(fn *ssa.Function) uint64
- func (r *Result) Summary(fn *ssa.Function) (Summary, bool)
- func (r *Result) WriteReport(w io.Writer, level func(*ssa.Function) int) error
- type Summary
Constants ¶
const MaxCacheBytes = 64 << 20
const Version = 22
Version participates in package fingerprints, including compiler API users that do not supply a development compiler hash. Bump when semantic contracts or placement proofs change incompatibly with previously emitted archives.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
Namespace string
// BodyKey optionally identifies the exact source/transforms of fn. It must
// change whenever its SSA operations or operands change. Empty keys use the
// complete SSA dump. Types, layout policies and dependencies remain hashed.
BodyKey func(fn *ssa.Function) string
Load func(key string) ([]byte, error)
Store func(key string, data []byte) error
Event func(hit bool)
}
Cache is optional local build-cache storage. I/O errors and invalid records fall back to analysis. Callbacks run on the coordinator, never backend workers.
type Config ¶
type Config struct {
// Cache optionally persists complete, validated facts for this program.
Cache *Cache
// Inspect must reject bodies replaced by linkname, source patches, native
// declarations or intrinsics unless the replacement itself is being analyzed.
Inspect func(*ssa.Function) bool
// External provides a validated summary for an uninspectable function.
// Missing contracts conservatively publish every argument.
External func(*ssa.Function) (Summary, bool)
// ExternalKey identifies the validated component that compiled an opaque
// dependency. It keeps callers' component keys stable when only bodies
// have been replaced by exported contracts.
ExternalKey func(*ssa.Function) string
// IndirectInterface describes the actual interface data representation.
// The default uses two-word Go function values, as LLGo does.
IndirectInterface func(types.Type) bool
// ForceHeap runs before solving, so pointers inside forced-heap storage
// also escape. An empty reason permits ordinary lifetime analysis.
ForceHeap func(ssa.Instruction, types.Type) string
// StackLayout describes newly introduced stack storage. Zero size needs
// no reservation; alignment must be a positive power of two.
StackLayout func(ssa.Instruction, types.Type) (size, alignment uint64)
// LocalStackLayout accounts for newly required root slots of storage
// already local in Go SSA. The original object bytes are not new storage.
LocalStackLayout func(ssa.Instruction, types.Type) (size, alignment uint64)
// MaxStackBytes bounds new storage per function, before final call effects.
// Zero leaves the target's existing per-object policy unchanged.
MaxStackBytes uint64
}
Config supplies the backend's representation and resolved call contracts. Callbacks run synchronously during Analyze. Results do not retain them.
type Effect ¶
type Effect uint16
Effect describes a minimum indirection depth. Zero means absent; a positive value encodes depth+1. Keeping this encoding makes the zero Summary useful as the initial element of the recursive-group fixed point.
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result is immutable after Analyze returns and may be read by backend workers.
func Analyze ¶
Analyze follows inspectable static callees and nested functions from roots. Each call SCC reaches a monotone summary fixed point before its callers.
func (*Result) CaptureByValue ¶
CaptureByValue reports whether lowering must store the captured value rather than its variable's address. The shared SSA itself is never rewritten.
func (*Result) LookupDecision ¶
func (r *Result) LookupDecision(site ssa.Instruction) (Decision, bool)
LookupDecision distinguishes analyzed objects from bodies that were excluded because their symbols use another ABI or have a replacement implementation.
func (*Result) StackBytes ¶
StackBytes is a conservative reservation for the function's promoted Go objects. Lowering helpers can reserve additional storage from the same budget.
func (*Result) WriteReport ¶
WriteReport prints deterministic frontend storage decisions. level selects functions and verbosity: zero disables output, one prints placements, and higher values include reasons. LLVM may subsequently remove more storage.