]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: only sort methods/interfaces during export for -d=unifiedquirks
authorMatthew Dempsky <mdempsky@google.com>
Wed, 18 Aug 2021 20:10:04 +0000 (13:10 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 18 Aug 2021 21:19:22 +0000 (21:19 +0000)
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>
src/cmd/compile/internal/typecheck/iexport.go

index 75b4931c310b272096e4a18cf5f87b88d55eee42..75d61157833686cbcc843ef1375df36001789080 100644 (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)