aboutsummaryrefslogtreecommitdiffhomepage
path: root/transform/interface-lowering.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2022-04-19 15:31:23 +0200
committerRon Evans <[email protected]>2022-05-30 07:53:28 +0200
commit777d3f3ea5a570615b615e323c977f73d6674507 (patch)
treeac5bf4b4e169f37b81cec5dfcddfc6e1b0814899 /transform/interface-lowering.go
parentea3b5dc68979da59e6a62ed64bce7369ad1f0e22 (diff)
downloadtinygo-777d3f3ea5a570615b615e323c977f73d6674507.tar.gz
tinygo-777d3f3ea5a570615b615e323c977f73d6674507.zip
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.
Diffstat (limited to 'transform/interface-lowering.go')
-rw-r--r--transform/interface-lowering.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/transform/interface-lowering.go b/transform/interface-lowering.go
index d2d4b4f48..7a01c2ea7 100644
--- a/transform/interface-lowering.go
+++ b/transform/interface-lowering.go
@@ -101,19 +101,23 @@ type lowerInterfacesPass struct {
// before LLVM can work on them. This is done so that a few cleanup passes can
// run before assigning the final type codes.
func LowerInterfaces(mod llvm.Module, config *compileopts.Config) error {
+ targetData := llvm.NewTargetData(mod.DataLayout())
+ defer targetData.Dispose()
p := &lowerInterfacesPass{
mod: mod,
config: config,
builder: mod.Context().NewBuilder(),
ctx: mod.Context(),
- uintptrType: mod.Context().IntType(llvm.NewTargetData(mod.DataLayout()).PointerSize() * 8),
+ uintptrType: mod.Context().IntType(targetData.PointerSize() * 8),
types: make(map[string]*typeInfo),
signatures: make(map[string]*signatureInfo),
interfaces: make(map[string]*interfaceInfo),
}
+ defer p.builder.Dispose()
if config.Debug() {
p.dibuilder = llvm.NewDIBuilder(mod)
+ defer p.dibuilder.Destroy()
defer p.dibuilder.Finalize()
p.difiles = make(map[string]llvm.Metadata)
}