aboutsummaryrefslogtreecommitdiff
path: root/test/devirt.go
diff options
context:
space:
mode:
authorDavid Chase <drchase@google.com>2017-03-13 21:09:27 +0000
committerDavid Chase <drchase@google.com>2017-03-13 21:15:32 +0000
commitb59a405656bbd79aefe3620553bee771628f9209 (patch)
tree4ae95d47c49860604c6a9dad42cb6bc5eb0de9b9 /test/devirt.go
parent118b3fe7bbf855196db727daefbb403b84a4f67d (diff)
downloadgo-b59a405656bbd79aefe3620553bee771628f9209.tar.gz
go-b59a405656bbd79aefe3620553bee771628f9209.zip
Revert "cmd/compile: de-virtualize interface calls"
This reverts commit 4e0c7c3f61475116c4ae8d11ef796819d9c404f0. Reason for revert: The presence-of-optimization test program is fragile, breaks under noopt, and might break if the Go libraries are tweaked. It needs to be (re)written without reference to other packages. Change-Id: I3aaf1ab006a1a255f961a978e9c984341740e3c7 Reviewed-on: https://go-review.googlesource.com/38097 Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/devirt.go')
-rw-r--r--test/devirt.go64
1 files changed, 0 insertions, 64 deletions
diff --git a/test/devirt.go b/test/devirt.go
deleted file mode 100644
index a2211f185c..0000000000
--- a/test/devirt.go
+++ /dev/null
@@ -1,64 +0,0 @@
-// errorcheck -0 -d=ssa/opt/debug=3
-
-package main
-
-import (
- "crypto/sha1"
- "errors"
- "fmt"
- "sync"
-)
-
-func f0() {
- v := errors.New("error string")
- _ = v.Error() // ERROR "de-virtualizing call$"
-}
-
-func f1() {
- h := sha1.New()
- buf := make([]byte, 4)
- h.Write(buf) // ERROR "de-virtualizing call$"
- _ = h.Sum(nil) // ERROR "de-virtualizing call$"
-}
-
-func f2() {
- // trickier case: make sure we see this is *sync.rlocker
- // instead of *sync.RWMutex,
- // even though they are the same pointers
- var m sync.RWMutex
- r := m.RLocker()
-
- // deadlock if the type of 'r' is improperly interpreted
- // as *sync.RWMutex
- r.Lock() // ERROR "de-virtualizing call$"
- m.RLock()
- r.Unlock() // ERROR "de-virtualizing call$"
- m.RUnlock()
-}
-
-type multiword struct{ a, b, c int }
-
-func (m multiword) Error() string { return fmt.Sprintf("%d, %d, %d", m.a, m.b, m.c) }
-
-func f3() {
- // can't de-virtualize this one yet;
- // it passes through a call to iconvT2I
- var err error
- err = multiword{1, 2, 3}
- if err.Error() != "1, 2, 3" {
- panic("bad call")
- }
-
- // ... but we can do this one
- err = &multiword{1, 2, 3}
- if err.Error() != "1, 2, 3" { // ERROR "de-virtualizing call$"
- panic("bad call")
- }
-}
-
-func main() {
- f0()
- f1()
- f2()
- f3()
-}