aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-08-18 13:10:04 -0700
committerMatthew Dempsky <mdempsky@google.com>2021-08-18 21:19:22 +0000
commitc2bd9ee2dbec88d4fd1b21aefa21cd988d01b880 (patch)
treeab4850839807d6a09e79a33792d9d38fde38001a
parent8f0578ef39a97c3a20032db799b97763e44274b0 (diff)
downloadgo-c2bd9ee2dbec88d4fd1b21aefa21cd988d01b880.tar.gz
go-c2bd9ee2dbec88d4fd1b21aefa21cd988d01b880.zip
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>
-rw-r--r--src/cmd/compile/internal/typecheck/iexport.go10
1 files 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)