1
0
mirror of https://github.com/golang/go synced 2024-11-22 20:24:47 -07:00

cmd/compile: only sort methods/interfaces during export for -d=unifiedquirks

These sorts are only important for 'toolstash -cmp' testing of unified
IR against -G=0 mode, but they were added before I added
-d=unifiedquirks to allow altering small "don't care" output details
like this.

This CL should help mitigate issues with #44195 until package
objectpath is updated and deployed.

Change-Id: Ia3dcf359481ff7abad5ddfca8e673fd2bb30ae01
Reviewed-on: https://go-review.googlesource.com/c/go/+/343390
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Matthew Dempsky 2021-08-18 13:10:04 -07:00
parent 8f0578ef39
commit c2bd9ee2db

View File

@ -578,7 +578,9 @@ func (p *iexporter) doDecl(n *ir.Name) {
// Sort methods, for consistency with types2.
methods := append([]*types.Field(nil), t.Methods().Slice()...)
sort.Sort(types.MethodsByName(methods))
if base.Debug.UnifiedQuirks != 0 {
sort.Sort(types.MethodsByName(methods))
}
w.uint64(uint64(len(methods)))
for _, m := range methods {
@ -978,8 +980,10 @@ func (w *exportWriter) doTyp(t *types.Type) {
// Sort methods and embedded types, for consistency with types2.
// Note: embedded types may be anonymous, and types2 sorts them
// with sort.Stable too.
sort.Sort(types.MethodsByName(methods))
sort.Stable(types.EmbeddedsByName(embeddeds))
if base.Debug.UnifiedQuirks != 0 {
sort.Sort(types.MethodsByName(methods))
sort.Stable(types.EmbeddedsByName(embeddeds))
}
w.startType(interfaceType)
w.setPkg(t.Pkg(), true)