aboutsummaryrefslogtreecommitdiffhomepage
path: root/transform
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2023-03-02 14:48:20 +0100
committerRon Evans <[email protected]>2023-03-02 18:47:09 +0100
commit517098c468fa1f8809cd715c70504ab18b3f8392 (patch)
treee4f9b4faab81f80fadf00966fefb94b253a025f0 /transform
parent1cce1ea4239377446426164720f7be43f15f9835 (diff)
downloadtinygo-517098c468fa1f8809cd715c70504ab18b3f8392.tar.gz
tinygo-517098c468fa1f8809cd715c70504ab18b3f8392.zip
transform: fix non-determinism in the interface lowering pass
This non-determinism was introduced in https://github.com/tinygo-org/tinygo/pull/2640. Non-determinism in the compiler is a bug because it makes it harder to find whether a compiler change actually affected the binary. Fixes https://github.com/tinygo-org/tinygo/issues/3504
Diffstat (limited to 'transform')
-rw-r--r--transform/interface-lowering.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/transform/interface-lowering.go b/transform/interface-lowering.go
index e57463715..ebd47ff8f 100644
--- a/transform/interface-lowering.go
+++ b/transform/interface-lowering.go
@@ -302,10 +302,18 @@ func (p *lowerInterfacesPass) run() error {
use.EraseFromParentAsInstruction()
}
+ // Create a sorted list of type names, for predictable iteration.
+ var typeNames []string
+ for name := range p.types {
+ typeNames = append(typeNames, name)
+ }
+ sort.Strings(typeNames)
+
// Remove all method sets, which are now unnecessary and inhibit later
// optimizations if they are left in place.
zero := llvm.ConstInt(p.ctx.Int32Type(), 0, false)
- for _, t := range p.types {
+ for _, name := range typeNames {
+ t := p.types[name]
if !t.methodSet.IsNil() {
initializer := t.typecode.Initializer()
var newInitializerFields []llvm.Value