From: Matthew Dempsky Date: Wed, 18 Aug 2021 20:10:04 +0000 (-0700) Subject: cmd/compile: only sort methods/interfaces during export for -d=unifiedquirks X-Git-Tag: go1.18beta1~1715 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c2bd9ee2dbec88d4fd1b21aefa21cd988d01b880;p=gostls13.git 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 Run-TryBot: Matthew Dempsky TryBot-Result: Go Bot Reviewed-by: Robert Griesemer --- diff --git a/src/cmd/compile/internal/typecheck/iexport.go b/src/cmd/compile/internal/typecheck/iexport.go index 75b4931c31..75d6115783 100644 --- a/src/cmd/compile/internal/typecheck/iexport.go +++ b/src/cmd/compile/internal/typecheck/iexport.go @@ -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)