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>
// 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.