From c2bd9ee2dbec88d4fd1b21aefa21cd988d01b880 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Wed, 18 Aug 2021 13:10:04 -0700 Subject: 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 --- src/cmd/compile/internal/typecheck/iexport.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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) -- cgit v1.2.3-54-g00ecf