]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.ssa] cmd/compile: unify and check LoweredGetClosurePtr
authorJosh Bleecher Snyder <josharian@gmail.com>
Sun, 3 Jul 2016 20:40:03 +0000 (13:40 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Mon, 4 Jul 2016 01:29:28 +0000 (01:29 +0000)
The comments were mostly duplicated; unify them.
Add a check that the required invariant holds.

Change-Id: I42fe09dcd1fac76d3c4e191f7a58c591c5ce429b
Reviewed-on: https://go-review.googlesource.com/24719
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/amd64/ssa.go
src/cmd/compile/internal/arm/ssa.go
src/cmd/compile/internal/gc/ssa.go

index acb4c2b26fcdded3eb744c560feb9b575b92505f..94c7c47afe253d774c96ebd8d9e37a619ca4772c 100644 (file)
@@ -720,11 +720,8 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
        case ssa.OpArg:
                // input args need no code
        case ssa.OpAMD64LoweredGetClosurePtr:
-               // Output is hardwired to DX only,
-               // and DX contains the closure pointer on
-               // closure entry, and this "instruction"
-               // is scheduled to the very beginning
-               // of the entry block.
+               // Closure pointer is DX.
+               gc.CheckLoweredGetClosurePtr(v)
        case ssa.OpAMD64LoweredGetG:
                r := gc.SSARegNum(v)
                // See the comments in cmd/internal/obj/x86/obj6.go
index 0bdeba9203bc6f791474301e3598ddbaf5dce1b4..bb7f6c5957ec7269f12af2b5094a10be3879b4d1 100644 (file)
@@ -708,12 +708,8 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                ssa.OpARMLoweredSelect1:
                // nothing to do
        case ssa.OpARMLoweredGetClosurePtr:
-               // Output is hardwired to R7 (arm.REGCTXT) only,
-               // and R7 contains the closure pointer on
-               // closure entry, and this "instruction"
-               // is scheduled to the very beginning
-               // of the entry block.
-               // nothing to do here.
+               // Closure pointer is R7 (arm.REGCTXT).
+               gc.CheckLoweredGetClosurePtr(v)
        default:
                v.Unimplementedf("genValue not implemented: %s", v.LongString())
        }
index b384136faba8960f646604aad54cc969f33f7b7c..90f48dcab40fcd167449966f99715fa179f7f52a 100644 (file)
@@ -4281,6 +4281,16 @@ func CheckLoweredPhi(v *ssa.Value) {
        }
 }
 
+// CheckLoweredGetClosurePtr checks that v is the first instruction in the function's entry block.
+// 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
+       if entry != v.Block || entry.Values[0] != v {
+               Fatalf("badly placed LoweredGetClosurePtr: %v %v", v.Block, v)
+       }
+}
+
 // AutoVar returns a *Node and int64 representing the auto variable and offset within it
 // where v should be spilled.
 func AutoVar(v *ssa.Value) (*Node, int64) {