Something went wrong. Try again.
🌱 A minimal programming language and compiler. git.urbach.dev/cli/q
high-performance programming-language compiler
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536package optimizer
import ( "git.urbach.dev/cli/q/src/ssa" "git.urbach.dev/cli/q/src/types")
// RemoveCopies replaces copies with their actual values.func RemoveCopies(ir *ssa.IR) { for _, block := range ir.Blocks { for i, value := range block.Instructions { copy, isCopy := value.(*ssa.Copy)
if !isCopy { continue }
typ := copy.Value.Type()
if copy.Typ != typ { continue }
_, isResource := typ.(*types.Resource)
if isResource { continue }
ir.ReplaceAll(copy, copy.Value) block.RemoveAt(i) }
block.RemoveNilValues() }}