]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.ssa] cmd/compile: provide better errors for regnum and localOffset failures
authorJosh Bleecher Snyder <josharian@gmail.com>
Wed, 5 Aug 2015 23:06:39 +0000 (16:06 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Thu, 6 Aug 2015 17:11:29 +0000 (17:11 +0000)
Change-Id: I2667b0923e17df7cbf08e34ebec1b69a0f2f02b2
Reviewed-on: https://go-review.googlesource.com/13265
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/ssa.go

index b63b66212622386c27b10d10abb89e77d5e490fa..5c56b370bd24be545a138de9a52e94a6a8156f17 100644 (file)
@@ -2398,8 +2398,14 @@ func regMoveAMD64(width int64) int {
 // regnum returns the register (in cmd/internal/obj numbering) to
 // which v has been allocated.  Panics if v is not assigned to a
 // register.
+// TODO: Make this panic again once it stops happening routinely.
 func regnum(v *ssa.Value) int16 {
-       return ssaRegToReg[v.Block.Func.RegAlloc[v.ID].(*ssa.Register).Num]
+       reg := v.Block.Func.RegAlloc[v.ID]
+       if reg == nil {
+               v.Unimplementedf("nil regnum for value: %s\n%s\n", v.LongString(), v.Block.Func)
+               return 0
+       }
+       return ssaRegToReg[reg.(*ssa.Register).Num]
 }
 
 // localOffset returns the offset below the frame pointer where
@@ -2410,7 +2416,7 @@ func localOffset(v *ssa.Value) int64 {
        reg := v.Block.Func.RegAlloc[v.ID]
        slot, ok := reg.(*ssa.LocalSlot)
        if !ok {
-               v.Unimplementedf("localOffset of non-LocalSlot value: %s", v.LongString())
+               v.Unimplementedf("localOffset of non-LocalSlot value: %s\n%s\n", v.LongString(), v.Block.Func)
                return 0
        }
        return slot.Idx