1
0
mirror of https://github.com/golang/go synced 2024-11-26 01:57:56 -07:00

[dev.regabi] cmd/compile: disallow taking address of SSA'd values

Adds some extra validation that the frontend is setting flags like
Addrtaken correctly.

Change-Id: Iffde83e32ba1c4c917ab8cb3fe410a4f623cf635
Reviewed-on: https://go-review.googlesource.com/c/go/+/286434
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Matthew Dempsky 2021-01-25 14:14:10 -08:00
parent 6f5e79f470
commit 7eaaf28cae

View File

@ -434,6 +434,7 @@ func buildssa(fn *ir.Func, worker int) *ssa.Func {
// bitmask showing which of the open-coded defers in this function
// have been activated.
deferBitsTemp := typecheck.TempAt(src.NoXPos, s.curfn, types.Types[types.TUINT8])
deferBitsTemp.SetAddrtaken(true)
s.deferBitsTemp = deferBitsTemp
// For this value, AuxInt is initialized to zero by default
startDeferBits := s.entryNewValue0(ssa.OpConst8, types.Types[types.TUINT8])
@ -5086,6 +5087,10 @@ func (s *state) addr(n ir.Node) *ssa.Value {
defer s.popLine()
}
if s.canSSA(n) {
s.Fatalf("addr of canSSA expression: %+v", n)
}
t := types.NewPtr(n.Type())
linksymOffset := func(lsym *obj.LSym, offset int64) *ssa.Value {
v := s.entryNewValue1A(ssa.OpAddr, t, lsym, s.sb)