]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: sort liveness variable reports
authorKeith Randall <khr@golang.org>
Fri, 20 Jan 2023 21:36:51 +0000 (13:36 -0800)
committerKeith Randall <khr@google.com>
Sat, 21 Jan 2023 21:08:00 +0000 (21:08 +0000)
Sort variables before display so that when there are multiple variables
to report, they are in a consistent order.

Otherwise they are ordered in the order they appear in the fn.Dcl list,
which can vary. Particularly, they vary depending on regabi.

Change-Id: I0db380f7cbe6911e87177503a4c3b39851ff1b5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/462898
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/compile/internal/liveness/plive.go
test/live.go
test/live_regabi.go

index 689b5286c6e1e69ce3c967ddda518ddb1a487bbc..e828a6ebb6894917cae55e2a75538a42ed4ddb8c 100644 (file)
@@ -1106,11 +1106,18 @@ func (lv *liveness) showlive(v *ssa.Value, live bitvec.BitVec) {
                s += "indirect call:"
        }
 
+       // Sort variable names for display. Variables aren't in any particular order, and
+       // the order can change by architecture, particularly with differences in regabi.
+       var names []string
        for j, n := range lv.vars {
                if live.Get(int32(j)) {
-                       s += fmt.Sprintf(" %v", n)
+                       names = append(names, n.Sym().Name)
                }
        }
+       sort.Strings(names)
+       for _, v := range names {
+               s += " " + v
+       }
 
        base.WarnfAt(pos, s)
 }
index 6f3b86a35d69c2e1d9a5f3e6b85746eac8b0d8f0..0e015db34c4d31d1be6254cd5515f07bf2912bd9 100644 (file)
@@ -698,9 +698,9 @@ func f41(p, q *int) (r *int) { // ERROR "live at entry to f41: p q$"
        defer func() {
                recover()
        }()
-       printint(0) // ERROR "live at call to printint: q r .autotmp_[0-9]+$"
+       printint(0) // ERROR "live at call to printint: .autotmp_[0-9]+ q r$"
        r = q
-       return // ERROR "live at call to f41.func1: r .autotmp_[0-9]+$"
+       return // ERROR "live at call to f41.func1: .autotmp_[0-9]+ r$"
 }
 
 func f42() {
index 027d476ab206dfd9c1c9318c06b440f54248b640..6a8ff5d68abb091662972fc78da80ca36dac6718 100644 (file)
@@ -693,7 +693,7 @@ func f41(p, q *int) (r *int) { // ERROR "live at entry to f41: p q$"
        defer func() {
                recover()
        }()
-       printint(0) // ERROR "live at call to printint: q .autotmp_[0-9]+ r$"
+       printint(0) // ERROR "live at call to printint: .autotmp_[0-9]+ q r$"
        r = q
        return // ERROR "live at call to f41.func1: .autotmp_[0-9]+ r$"
 }