mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: clean up SSA-building code
Now that the write barrier insertion is moved to SSA, the SSA building code can be simplified. Updates #17583. Change-Id: I5cacc034b11aa90b0abe6f8dd97e4e3994e2bc25 Reviewed-on: https://go-review.googlesource.com/36840 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
9ebf3d5100
commit
1b85300602
5 changed files with 62 additions and 189 deletions
|
|
@ -19,7 +19,7 @@ func needwb(v *Value) bool {
|
|||
if !t.HasPointer() {
|
||||
return false
|
||||
}
|
||||
if IsStackAddr(v.Args[0]) {
|
||||
if isStackAddr(v.Args[0]) {
|
||||
return false // write on stack doesn't need write barrier
|
||||
}
|
||||
return true
|
||||
|
|
@ -207,6 +207,12 @@ func writebarrier(f *Func) {
|
|||
memElse = bElse.NewValue3I(pos, op, TypeMem, siz, ptr, val, memElse)
|
||||
}
|
||||
|
||||
if f.NoWB {
|
||||
f.Config.fe.Error(pos, "write barrier prohibited")
|
||||
}
|
||||
if !f.WBPos.IsKnown() {
|
||||
f.WBPos = pos
|
||||
}
|
||||
if f.Config.fe.Debug_wb() {
|
||||
f.Config.Warnl(pos, "write barrier")
|
||||
}
|
||||
|
|
@ -309,8 +315,8 @@ func round(o int64, r int64) int64 {
|
|||
return (o + r - 1) &^ (r - 1)
|
||||
}
|
||||
|
||||
// IsStackAddr returns whether v is known to be an address of a stack slot
|
||||
func IsStackAddr(v *Value) bool {
|
||||
// isStackAddr returns whether v is known to be an address of a stack slot
|
||||
func isStackAddr(v *Value) bool {
|
||||
for v.Op == OpOffPtr || v.Op == OpAddPtr || v.Op == OpPtrIndex || v.Op == OpCopy {
|
||||
v = v.Args[0]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue