Skip to content

Commit

Permalink
transform: fix non-determinism in the interface lowering pass
Browse files Browse the repository at this point in the history
This non-determinism was introduced in
#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 #3504
  • Loading branch information
aykevl authored and deadprogram committed Mar 2, 2023
1 parent 1cce1ea commit 517098c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion transform/interface-lowering.go
Expand Up @@ -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
Expand Down

0 comments on commit 517098c

Please sign in to comment.