mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00: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:
parent
6f5e79f470
commit
7eaaf28cae
1 changed files with 5 additions and 0 deletions
|
|
@ -434,6 +434,7 @@ func buildssa(fn *ir.Func, worker int) *ssa.Func {
|
||||||
// bitmask showing which of the open-coded defers in this function
|
// bitmask showing which of the open-coded defers in this function
|
||||||
// have been activated.
|
// have been activated.
|
||||||
deferBitsTemp := typecheck.TempAt(src.NoXPos, s.curfn, types.Types[types.TUINT8])
|
deferBitsTemp := typecheck.TempAt(src.NoXPos, s.curfn, types.Types[types.TUINT8])
|
||||||
|
deferBitsTemp.SetAddrtaken(true)
|
||||||
s.deferBitsTemp = deferBitsTemp
|
s.deferBitsTemp = deferBitsTemp
|
||||||
// For this value, AuxInt is initialized to zero by default
|
// For this value, AuxInt is initialized to zero by default
|
||||||
startDeferBits := s.entryNewValue0(ssa.OpConst8, types.Types[types.TUINT8])
|
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()
|
defer s.popLine()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.canSSA(n) {
|
||||||
|
s.Fatalf("addr of canSSA expression: %+v", n)
|
||||||
|
}
|
||||||
|
|
||||||
t := types.NewPtr(n.Type())
|
t := types.NewPtr(n.Type())
|
||||||
linksymOffset := func(lsym *obj.LSym, offset int64) *ssa.Value {
|
linksymOffset := func(lsym *obj.LSym, offset int64) *ssa.Value {
|
||||||
v := s.entryNewValue1A(ssa.OpAddr, t, lsym, s.sb)
|
v := s.entryNewValue1A(ssa.OpAddr, t, lsym, s.sb)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue