internal/load: use alias slice for determinism

Previously aliases were stored in a map which was causing
non-deterministic code generation (see recent build failures). This diff
changes to a slice to avoid this problem.

Updates #50
This commit is contained in:
Michael McLoughlin
2019-01-20 23:06:42 -08:00
parent 2d7a9ddb6c
commit 02ecaad4e4
4 changed files with 61 additions and 53 deletions

View File

@@ -74,15 +74,19 @@ func (l *Loader) Load() ([]inst.Instruction, error) {
im[e.Opcode] = e
}
// Apply list of aliases.
for from, to := range aliases {
if existing, found := im[from]; found {
im[to].Forms = append(im[to].Forms, existing.Forms...)
// Merge aliased forms. This is primarily for MOVQ (issue #50).
for _, a := range aliases {
if existing, found := im[a.From]; found {
im[a.To].Forms = append(im[a.To].Forms, existing.Forms...)
}
cpy := *im[to]
cpy.Opcode = from
cpy.AliasOf = to
im[from] = &cpy
}
// Apply list of aliases.
for _, a := range aliases {
cpy := *im[a.To]
cpy.Opcode = a.From
cpy.AliasOf = a.To
im[a.From] = &cpy
}
// Dedupe forms.