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: val is in reg but not live (with ssa checks on) #31915

Closed
ALTree opened this issue May 8, 2019 · 5 comments
Closed
Milestone

Comments

@ALTree
Copy link
Member

@ALTree ALTree commented May 8, 2019

$ gotip version
go version devel +4cd6c3bac7 Wed May 8 16:00:05 2019 +0000 linux/amd64

When compiled with the ssa checks enabled (-d=ssa/check/on), the following program:

package p

//go:noinline
func f() {}

func g() {
	var a []int
	var b bool
	for {
		b = (b && b) != (b && b)
		for b && b == b || true {
			f()
			_ = a[0]
		}
		_ = &b
		a = []int{}
	}
}

crashes the tip compiler with this error:

$ gotip tool compile -d=ssa/check/on crash.go

crash.go:11:9: internal compiler error: 'g': val v46 is in reg but not live at end of b10

goroutine 1 [running]:
runtime/debug.Stack(0xfce340, 0xc00000e018, 0x0)
	/home/alberto/go/src/runtime/debug/stack.go:24 +0x9d
cmd/compile/internal/gc.Fatalf(0xc00001c6c0, 0x30, 0xc0003076e0, 0x3, 0x3)
	/home/alberto/go/src/cmd/compile/internal/gc/subr.go:188 +0x291
cmd/compile/internal/gc.(*ssafn).Fatalf(0xc000306cf0, 0xb09000000002, 0xe43d6b, 0x2a, 0xc000343420, 0x2, 0x2)
	/home/alberto/go/src/cmd/compile/internal/gc/ssa.go:6081 +0x1b0
cmd/compile/internal/ssa.(*Func).Fatalf(...)
	/home/alberto/go/src/cmd/compile/internal/ssa/func.go:616
cmd/compile/internal/ssa.(*regAllocState).regalloc(0xc000001800, 0xc0002ac840)
	/home/alberto/go/src/cmd/compile/internal/ssa/regalloc.go:1598 +0x3e14
cmd/compile/internal/ssa.regalloc(0xc0002ac840)
	/home/alberto/go/src/cmd/compile/internal/ssa/regalloc.go:146 +0x62
cmd/compile/internal/ssa.Compile(0xc0002ac840)
	/home/alberto/go/src/cmd/compile/internal/ssa/compile.go:90 +0x476
cmd/compile/internal/gc.buildssa(0xc0002ac2c0, 0x0, 0x0)
	/home/alberto/go/src/cmd/compile/internal/gc/ssa.go:288 +0xbe9
cmd/compile/internal/gc.compileSSA(0xc0002ac2c0, 0x0)
	/home/alberto/go/src/cmd/compile/internal/gc/pgen.go:297 +0x4d
cmd/compile/internal/gc.compile(0xc0002ac2c0)
	/home/alberto/go/src/cmd/compile/internal/gc/pgen.go:276 +0x33d
cmd/compile/internal/gc.funccompile(0xc0002ac2c0)
	/home/alberto/go/src/cmd/compile/internal/gc/pgen.go:221 +0xc1
cmd/compile/internal/gc.Main(0xe4ef50)
	/home/alberto/go/src/cmd/compile/internal/gc/main.go:676 +0x30e5
main.main()
	/home/alberto/go/src/cmd/compile/main.go:51 +0xac

without -d=ssa/check/on, there is no crash.

The 1.12 and 1.11 compilers are also affected. The 1.10 compiler seems to be okay.

cc @randall77 @cherrymui

@ALTree ALTree added this to the Go1.14 milestone May 8, 2019
@cherrymui

This comment has been minimized.

Copy link
Contributor

@cherrymui cherrymui commented May 10, 2019

The SSA dump starts with (b10 is the entry block)

b10:-
v46 (+10) = MOVLconst <flags> [0] : AX
v30 (+11) = MOVBQZX <bool> v46 : CX
v35 (+11) = TESTB <flags> v30 v30
NE v35 → b14 b8 (11)

v46 looks weird (even without SSA check). It is MOVLconst but the type is flags. MOVLconst instruction doesn't even touch flags though... It seems this comes straightly from lower. I haven't looked into how it is generated.

@josharian

This comment has been minimized.

Copy link
Contributor

@josharian josharian commented May 10, 2019

Here are all the AMD64.rules that get executed, in order, while compiling this code. I haven't figured out which of them is outputting incorrect type information.

rewrite AMD64.rules:527
rewrite AMD64.rules:427
rewrite AMD64.rules:494
rewrite AMD64.rules:247
rewrite AMD64.rules:422
rewrite AMD64.rules:74
rewrite AMD64.rules:74
rewrite AMD64.rules:223
rewrite AMD64.rules:494
rewrite AMD64.rules:247
rewrite AMD64.rules:494
rewrite AMD64.rules:235
rewrite AMD64.rules:527
rewrite AMD64.rules:218
rewrite AMD64.rules:430
rewrite AMD64.rules:568
rewrite AMD64.rules:1128
rewrite AMD64.rules:757
rewrite AMD64.rules:757
rewrite AMD64.rules:502
rewrite AMD64.rules:1138
rewrite AMD64.rules:586
rewrite AMD64.rules:1143
rewrite AMD64.rules:1438
rewrite AMD64.rules:1438
rewrite AMD64.rules:1146
rewrite AMD64.rules:916
rewrite AMD64.rules:1316
rewrite AMD64.rules:1362
rewrite AMD64.rules:1378
rewrite AMD64.rules:1064
rewrite AMD64.rules:1128
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented May 12, 2019

Change https://golang.org/cl/176718 mentions this issue: cmd/compile: debug rewrite

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented May 12, 2019

Change https://golang.org/cl/176719 mentions this issue: cmd/compile: correct the argument type in SETXXstore -> MOVBstore rules on AMD64

@gopherbot gopherbot closed this in 23f3ea8 May 13, 2019
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Jun 20, 2019

Change https://golang.org/cl/183239 mentions this issue: cmd/compile: debug rewrite, enhanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.