Documentation ¶
Overview ¶
Package transform contains transformation passes for the TinyGo compiler. These transformation passes may be optimization passes or lowering passes.
Optimization passes transform the IR in such a way that they increase the performance of the generated code and/or help the LLVM optimizer better do its job by simplifying the IR. This usually means that certain TinyGo-specific runtime calls are removed or replaced with something simpler if that is a valid operation.
Lowering passes are usually required to run. One example is the interface lowering pass, which replaces stub runtime calls to get an interface method with the method implementation (either a direct call or a thunk).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OptimizeAllocs ¶
func OptimizeAllocs(mod llvm.Module)
OptimizeAllocs tries to replace heap allocations with stack allocations whenever possible. It relies on the LLVM 'nocapture' flag for interprocedural escape analysis, and within a function looks whether an allocation can escape to the heap.
func OptimizeMaps ¶
func OptimizeMaps(mod llvm.Module)
OptimizeMaps eliminates created but unused maps.
In the future, this should statically allocate created but never modified maps. This has not yet been implemented, however.
func OptimizeStringToBytes ¶ added in v0.9.0
func OptimizeStringToBytes(mod llvm.Module)
OptimizeStringToBytes transforms runtime.stringToBytes(...) calls into const []byte slices whenever possible. This optimizes the following pattern:
w.Write([]byte("foo"))
where Write does not store to the slice.
Types ¶
This section is empty.