]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.ssa] cmd/compile: convert localOffset panic to unimplemented
authorJosh Bleecher Snyder <josharian@gmail.com>
Fri, 24 Jul 2015 18:43:25 +0000 (11:43 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Fri, 24 Jul 2015 20:43:53 +0000 (20:43 +0000)
This prevents panics while attempting to generate code
for the runtime package. Now:

<unknown line number>: internal compiler error: localOffset of non-LocalSlot value: v10 = ADDQconst <*m> [256] v22

Change-Id: I20ed6ec6aae2c91183b8c826b8ebcc98e8ceebff
Reviewed-on: https://go-review.googlesource.com/12655
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/ssa.go

index e7772a92bb76feed5f994892aa74714269671567..2b6962a9791d8170ee1dc2864a0ab4ca0235ee17 100644 (file)
@@ -1911,8 +1911,15 @@ func regnum(v *ssa.Value) int16 {
 // localOffset returns the offset below the frame pointer where
 // a stack-allocated local has been allocated.  Panics if v
 // is not assigned to a local slot.
+// TODO: Make this panic again once it stops happening routinely.
 func localOffset(v *ssa.Value) int64 {
-       return v.Block.Func.RegAlloc[v.ID].(*ssa.LocalSlot).Idx
+       reg := v.Block.Func.RegAlloc[v.ID]
+       slot, ok := reg.(*ssa.LocalSlot)
+       if !ok {
+               v.Unimplementedf("localOffset of non-LocalSlot value: %s", v.LongString())
+               return 0
+       }
+       return slot.Idx
 }
 
 // ssaExport exports a bunch of compiler services for the ssa backend.