Skip to content

Commit

Permalink
[dev.regabi] cmd/compile: disallow taking address of SSA'd values
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mdempsky committed Jan 25, 2021
1 parent 6f5e79f commit 7eaaf28
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cmd/compile/internal/ssagen/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7eaaf28

Please sign in to comment.