diff options
author | Ayke van Laethem <[email protected]> | 2021-01-31 20:52:18 +0100 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-03-21 11:51:35 +0100 |
commit | e2f532709f97b37575d4216c9605323221b63b93 (patch) | |
tree | fae98b6b8ba8870b5b20d323184adf31fd8d90b0 /transform | |
parent | dc1ff80e10b8d4ec414d7a7491477f1768917ddc (diff) | |
download | tinygo-e2f532709f97b37575d4216c9605323221b63b93.tar.gz tinygo-e2f532709f97b37575d4216c9605323221b63b93.zip |
builder, compiler: compile and cache packages in parallel
This commit switches from the previous behavior of compiling the whole
program at once, to compiling every package in parallel and linking the
LLVM bitcode files together for further whole-program optimization.
This is a small performance win, but it has several advantages in the
future:
- There are many more things that can be done per package in parallel,
avoiding the bottleneck at the end of the compiler phase. This
should speed up the compiler futher.
- This change is a necessary step towards a non-LTO build mode for
fast incremental builds that only rebuild the changed package, when
compiler speed is more important than binary size.
- This change refactors the compiler in such a way that it will be
easier to inspect the IR for one package only. Inspecting this IR
will be very helpful for compiler developers.
Diffstat (limited to 'transform')
-rw-r--r-- | transform/interface-lowering.go | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/transform/interface-lowering.go b/transform/interface-lowering.go index 6aa3bb134..19546c589 100644 --- a/transform/interface-lowering.go +++ b/transform/interface-lowering.go @@ -173,11 +173,12 @@ func (p *lowerInterfacesPass) run() error { // Only the name of the global is relevant, the object itself is // discarded afterwards. name := global.Name() - t := &typeInfo{ - name: name, - typecode: global, + if _, ok := p.types[name]; !ok { + p.types[name] = &typeInfo{ + name: name, + typecode: global, + } } - p.types[name] = t case typeInInterfacePtr: // Count per type how often it is put in an interface. Also, collect // all methods this type has (if it is named). @@ -185,7 +186,15 @@ func (p *lowerInterfacesPass) run() error { initializer := global.Initializer() typecode := llvm.ConstExtractValue(initializer, []uint32{0}) methodSet := llvm.ConstExtractValue(initializer, []uint32{1}) - t := p.types[typecode.Name()] + typecodeName := typecode.Name() + t := p.types[typecodeName] + if t == nil { + t = &typeInfo{ + name: typecodeName, + typecode: typecode, + } + p.types[typecodeName] = t + } p.addTypeMethods(t, methodSet) // Count the number of MakeInterface instructions, for sorting the |