builder: free LLVM objects after use

This reduces the TinyGo memory consumption when running

  make tinygo-test

from 5.8GB to around 2GB on my laptop.
This commit is contained in:
Ayke van Laethem
2022-04-19 15:31:23 +02:00
committed by Ron Evans
parent ea3b5dc689
commit 777d3f3ea5
13 changed files with 49 additions and 6 deletions
+4 -2
View File
@@ -161,10 +161,12 @@ func LowerReflect(mod llvm.Module) {
})
// Assign typecodes the way the reflect package expects.
uintptrType := mod.Context().IntType(llvm.NewTargetData(mod.DataLayout()).PointerSize() * 8)
targetData := llvm.NewTargetData(mod.DataLayout())
defer targetData.Dispose()
uintptrType := mod.Context().IntType(targetData.PointerSize() * 8)
state := typeCodeAssignmentState{
fallbackIndex: 1,
uintptrLen: llvm.NewTargetData(mod.DataLayout()).PointerSize() * 8,
uintptrLen: targetData.PointerSize() * 8,
namedBasicTypes: make(map[string]int),
namedNonBasicTypes: make(map[string]int),
arrayTypes: make(map[string]int),