mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-12 15:03:41 +00:00
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:
committed by
Ron Evans
parent
ea3b5dc689
commit
777d3f3ea5
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user