]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: disallow taking address of SSA'd values
authorMatthew Dempsky <mdempsky@google.com>
Mon, 25 Jan 2021 22:14:10 +0000 (14:14 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 25 Jan 2021 22:46:58 +0000 (22:46 +0000)
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>
src/cmd/compile/internal/ssagen/ssa.go

index ecf32940828613138df4f1404ed0ac361a70760d..e49a9716fead539da2563f388bb0913ddbad52bc 100644 (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)