]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: allow OpArgXXXReg comes before LoweredGetClosurePtr
authorCherry Zhang <cherryyz@google.com>
Mon, 12 Apr 2021 23:42:28 +0000 (19:42 -0400)
committerCherry Zhang <cherryyz@google.com>
Tue, 13 Apr 2021 14:13:57 +0000 (14:13 +0000)
Both OpArgXXXReg and LoweredGetClosurePtr must come very early,
because they carry registers that are technically live on entry.
But no need to impose ordering requirement between them.

Change-Id: Iee1db6239a75e5b381e0ad25ba5503169333217b
Reviewed-on: https://go-review.googlesource.com/c/go/+/309629
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/compile/internal/ssagen/ssa.go

index de60cbf390eaf217987c1388ef3548b75a8889cc..60a849db23ea3f2c1f0942ee97259e34bd8c1ac8 100644 (file)
@@ -7097,15 +7097,26 @@ func CheckLoweredPhi(v *ssa.Value) {
        }
 }
 
-// CheckLoweredGetClosurePtr checks that v is the first instruction in the function's entry block.
+// CheckLoweredGetClosurePtr checks that v is the first instruction in the function's entry block,
+// except for incoming in-register arguments.
 // The output of LoweredGetClosurePtr is generally hardwired to the correct register.
 // That register contains the closure pointer on closure entry.
 func CheckLoweredGetClosurePtr(v *ssa.Value) {
        entry := v.Block.Func.Entry
-       // TODO register args: not all the register-producing ops can come first.
-       if entry != v.Block || entry.Values[0] != v {
+       if entry != v.Block {
                base.Fatalf("in %s, badly placed LoweredGetClosurePtr: %v %v", v.Block.Func.Name, v.Block, v)
        }
+       for _, w := range entry.Values {
+               if w == v {
+                       break
+               }
+               switch w.Op {
+               case ssa.OpArgIntReg, ssa.OpArgFloatReg:
+                       // okay
+               default:
+                       base.Fatalf("in %s, badly placed LoweredGetClosurePtr: %v %v", v.Block.Func.Name, v.Block, v)
+               }
+       }
 }
 
 // CheckArgReg ensures that v is in the function's entry block.