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: ICE in phiopt pass #45323

Closed
randall77 opened this issue Apr 1, 2021 · 2 comments
Closed

cmd/compile: ICE in phiopt pass #45323

randall77 opened this issue Apr 1, 2021 · 2 comments
Labels
Milestone

Comments

@randall77
Copy link
Contributor

@randall77 randall77 commented Apr 1, 2021

package main

func g() bool

func f(y int) bool {
	b, ok := true, false
	if y > 1 {
		ok = g()
	}
	if !ok {
		ok = g()
		b = false
	}
	if !ok {
		return false
	}
	return b
}
> go tool compile test.go
/home/khr/gowork/test.go:7:9: internal compiler error: 'f': panic during phiopt while compiling f:

runtime error: index out of range [-1]

goroutine 7 [running]:
cmd/compile/internal/ssa.Compile.func1(0xc00041ce38, 0xc0003ea4e0)
	/home/khr/sandbox/ro/src/cmd/compile/internal/ssa/compile.go:48 +0x9f
panic(0xe06620, 0xc000026960)
	/home/khr/sandbox/ro/src/runtime/panic.go:1031 +0x25b
cmd/compile/internal/ssa.convertPhi(0xc0004b6d60, 0xc000480bd0, 0xffffffffffffffff)
	/home/khr/sandbox/ro/src/cmd/compile/internal/ssa/phiopt.go:318 +0x1aa
cmd/compile/internal/ssa.phiopt(0xc0003ea4e0)
	/home/khr/sandbox/ro/src/cmd/compile/internal/ssa/phiopt.go:216 +0x2bc
cmd/compile/internal/ssa.Compile(0xc0003ea4e0)
	/home/khr/sandbox/ro/src/cmd/compile/internal/ssa/compile.go:96 +0xc76
cmd/compile/internal/ssagen.buildssa(0xc000144420, 0x0, 0x0)
	/home/khr/sandbox/ro/src/cmd/compile/internal/ssagen/ssa.go:629 +0x22e5
cmd/compile/internal/ssagen.Compile(0xc000144420, 0x0)
	/home/khr/sandbox/ro/src/cmd/compile/internal/ssagen/pgen.go:151 +0x5f
cmd/compile/internal/gc.compileFunctions.func2.1(0xc0000323f0, 0xc000144420, 0xc00000e510, 0xc000023100)
	/home/khr/sandbox/ro/src/cmd/compile/internal/gc/compile.go:130 +0x65
created by cmd/compile/internal/gc.compileFunctions.func2
	/home/khr/sandbox/ro/src/cmd/compile/internal/gc/compile.go:128 +0x8e

Should be a simple fix.

@zhangfannie

@gopherbot
Copy link

@gopherbot gopherbot commented Apr 1, 2021

Change https://golang.org/cl/306431 mentions this issue: cmd/compile: fix bug in phiopt pass

Loading

@dmitshur dmitshur added this to the Go1.17 milestone Apr 1, 2021
@zhangfannie
Copy link
Contributor

@zhangfannie zhangfannie commented Apr 2, 2021

@randall77 I took a day off yesterday and I am sorry to reply late. Thanks for finding this issue and solving it.

Loading

@gopherbot gopherbot closed this in aebc0b4 Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants