aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2017-02-10 10:15:10 -0500
committerCherry Zhang <cherryyz@google.com>2017-03-16 14:24:40 +0000
commit1b85300602f8530e505ad5b8b033a15f5521d1a7 (patch)
tree07d92632d25ec9640d42e72e5884b49578b346c7 /src/cmd/compile/internal/ssa
parent9ebf3d5100a52b2c0ebcbf9754c02d1edf7a035f (diff)
downloadgo-1b85300602f8530e505ad5b8b033a15f5521d1a7.tar.gz
go-1b85300602f8530e505ad5b8b033a15f5521d1a7.zip
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>
Diffstat (limited to 'src/cmd/compile/internal/ssa')
-rw-r--r--src/cmd/compile/internal/ssa/config.go4
-rw-r--r--src/cmd/compile/internal/ssa/export_test.go1
-rw-r--r--src/cmd/compile/internal/ssa/func.go3
-rw-r--r--src/cmd/compile/internal/ssa/writebarrier.go12
4 files changed, 17 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/ssa/config.go b/src/cmd/compile/internal/ssa/config.go
index c447fc89c0..ce7adaf3d5 100644
--- a/src/cmd/compile/internal/ssa/config.go
+++ b/src/cmd/compile/internal/ssa/config.go
@@ -95,6 +95,9 @@ type Logger interface {
// Fatal reports a compiler error and exits.
Fatalf(pos src.XPos, msg string, args ...interface{})
+ // Error reports a compiler error but keep going.
+ Error(pos src.XPos, msg string, args ...interface{})
+
// Warnl writes compiler messages in the form expected by "errorcheck" tests
Warnl(pos src.XPos, fmt_ string, args ...interface{})
@@ -354,6 +357,7 @@ func (c *Config) NewFunc() *Func {
func (c *Config) Logf(msg string, args ...interface{}) { c.fe.Logf(msg, args...) }
func (c *Config) Log() bool { return c.fe.Log() }
func (c *Config) Fatalf(pos src.XPos, msg string, args ...interface{}) { c.fe.Fatalf(pos, msg, args...) }
+func (c *Config) Error(pos src.XPos, msg string, args ...interface{}) { c.fe.Error(pos, msg, args...) }
func (c *Config) Warnl(pos src.XPos, msg string, args ...interface{}) { c.fe.Warnl(pos, msg, args...) }
func (c *Config) Debug_checknil() bool { return c.fe.Debug_checknil() }
func (c *Config) Debug_wb() bool { return c.fe.Debug_wb() }
diff --git a/src/cmd/compile/internal/ssa/export_test.go b/src/cmd/compile/internal/ssa/export_test.go
index 699e0efc20..743bdfcd03 100644
--- a/src/cmd/compile/internal/ssa/export_test.go
+++ b/src/cmd/compile/internal/ssa/export_test.go
@@ -96,6 +96,7 @@ func (d DummyFrontend) Logf(msg string, args ...interface{}) { d.t.Logf(msg, arg
func (d DummyFrontend) Log() bool { return true }
func (d DummyFrontend) Fatalf(_ src.XPos, msg string, args ...interface{}) { d.t.Fatalf(msg, args...) }
+func (d DummyFrontend) Error(_ src.XPos, msg string, args ...interface{}) { d.t.Errorf(msg, args...) }
func (d DummyFrontend) Warnl(_ src.XPos, msg string, args ...interface{}) { d.t.Logf(msg, args...) }
func (d DummyFrontend) Debug_checknil() bool { return false }
func (d DummyFrontend) Debug_wb() bool { return false }
diff --git a/src/cmd/compile/internal/ssa/func.go b/src/cmd/compile/internal/ssa/func.go
index 75b5b44a96..fc7db290bf 100644
--- a/src/cmd/compile/internal/ssa/func.go
+++ b/src/cmd/compile/internal/ssa/func.go
@@ -27,6 +27,9 @@ type Func struct {
scheduled bool // Values in Blocks are in final order
NoSplit bool // true if function is marked as nosplit. Used by schedule check pass.
+ NoWB bool // write barrier is not allowed
+ WBPos src.XPos // line number of first write barrier
+
// when register allocation is done, maps value ids to locations
RegAlloc []Location
diff --git a/src/cmd/compile/internal/ssa/writebarrier.go b/src/cmd/compile/internal/ssa/writebarrier.go
index ad53089d80..3e43d2f8d2 100644
--- a/src/cmd/compile/internal/ssa/writebarrier.go
+++ b/src/cmd/compile/internal/ssa/writebarrier.go
@@ -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]
}