Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: internal compiler error: bad live variable at entry (part 3) #32454

Closed
ALTree opened this issue Jun 5, 2019 · 2 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@ALTree
Copy link
Member

ALTree commented Jun 5, 2019

$ gotip version
go version devel +9ab9ca27bb Wed Jun 5 16:33:20 2019 +0000 linux/amd64

This is a follow-up to #29218. On the CL that fixed that one, @josharian wrote:

It is not clear that this fixes every variant of #29218,
but it is a reasonable standalone change.
And code like #29218 is rare and fundamentally buggy,
so we can handle new instances if/when they actually occur.

This is a variant of the reproducer on #29218 that still crashes the tip compiler. The program:

package p

type T struct {
	s string
	f float64
}

func f() {
	var f float64
	var st T
	for {
		switch &st.f {
		case &f:
			f = 1
		}
	}
}

The error is the same as in #29218:

$ gotip build crash.go 

# command-line-arguments
<autogenerated>:1: internal compiler error: bad live variable at entry of f: st (type T)

goroutine 37 [running]:
runtime/debug.Stack(0xfd83c0, 0xc000098008, 0x0)
	/home/alberto/go/src/runtime/debug/stack.go:24 +0x9d
cmd/compile/internal/gc.Fatalf(0xe498c8, 0x24, 0xc0004f9758, 0x2, 0x2)
	/home/alberto/go/src/cmd/compile/internal/gc/subr.go:188 +0x291
cmd/compile/internal/gc.(*Liveness).epilogue(0xc0002c8500)
	/home/alberto/go/src/cmd/compile/internal/gc/plive.go:1004 +0xc0e
cmd/compile/internal/gc.liveness(0xc0004d6120, 0xc0004ce420, 0xc0002c6150, 0x0, 0xe3a97a, 0xd)
	/home/alberto/go/src/cmd/compile/internal/gc/plive.go:1399 +0xc4
cmd/compile/internal/gc.genssa(0xc0004ce420, 0xc0002c6150)
	/home/alberto/go/src/cmd/compile/internal/gc/ssa.go:5286 +0x92
cmd/compile/internal/gc.compileSSA(0xc0002c4160, 0x3)
	/home/alberto/go/src/cmd/compile/internal/gc/pgen.go:308 +0x3c2
cmd/compile/internal/gc.compileFunctions.func2(0xc0004c34a0, 0xc0004a4230, 0x3)
	/home/alberto/go/src/cmd/compile/internal/gc/pgen.go:363 +0x49
created by cmd/compile/internal/gc.compileFunctions
	/home/alberto/go/src/cmd/compile/internal/gc/pgen.go:361 +0x128

cc @randall77

@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 5, 2019
@ALTree ALTree added this to the Go1.14 milestone Jun 5, 2019
@josharian
Copy link
Contributor

Continuing the tradition of fixing these bugs indirectly, I have a CL coming shortly that fixes this, but not for any deep reason, and which is independently justifiable. Thanks for continuing to file these, @ALTree; they're productive sources of optimizations. :)

@gopherbot
Copy link

Change https://golang.org/cl/180940 mentions this issue: cmd/compile: optimize more pointer comparisons

tomocy pushed a commit to tomocy/go that referenced this issue Sep 1, 2019
The existing pointer comparison optimizations
don't include pointer arithmetic. Add them.

These rules trigger a few times in std cmd, while compiling:

time.Duration.String
cmd/go/internal/tlog.NodeHash
crypto/tls.ticketKeyFromBytes (3 times)
crypto/elliptic.(*p256Point).p256ScalarMult (15 times!)
crypto/elliptic.initTable

These weird comparisons occur when using the copy builtin,
which does a pointer comparison between src and dst.

This also happens to fix golang#32454, by optimizing enough
early on that all values can be eliminated.

Fixes golang#32454

Change-Id: I799d45743350bddd15a295dc1e12f8d03c11d1c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/180940
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
t4n6a1ka pushed a commit to t4n6a1ka/go that referenced this issue Sep 5, 2019
The existing pointer comparison optimizations
don't include pointer arithmetic. Add them.

These rules trigger a few times in std cmd, while compiling:

time.Duration.String
cmd/go/internal/tlog.NodeHash
crypto/tls.ticketKeyFromBytes (3 times)
crypto/elliptic.(*p256Point).p256ScalarMult (15 times!)
crypto/elliptic.initTable

These weird comparisons occur when using the copy builtin,
which does a pointer comparison between src and dst.

This also happens to fix golang#32454, by optimizing enough
early on that all values can be eliminated.

Fixes golang#32454

Change-Id: I799d45743350bddd15a295dc1e12f8d03c11d1c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/180940
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
@golang golang locked and limited conversation to collaborators Aug 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants