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
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@randall77
Copy link
Contributor

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

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

@dmitshur dmitshur added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 1, 2021
@dmitshur dmitshur added this to the Go1.17 milestone Apr 1, 2021
@zhangfannie
Copy link
Contributor

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

@golang golang locked and limited conversation to collaborators Apr 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants