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: two stores live simultaneously #36005

Closed
cherrymui opened this issue Dec 5, 2019 · 3 comments
Closed

cmd/compile: ICE: two stores live simultaneously #36005

cherrymui opened this issue Dec 5, 2019 · 3 comments
Assignees

Comments

@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented Dec 5, 2019

What version of Go are you using (go version)?

tip (eeb319a)

Does this issue reproduce with the latest release?

Reproducible with go 1.13, not with go 1.12.

What operating system and processor architecture are you using (go env)?

Building for linux/arm64.

What did you do?

https://play.golang.org/p/bzTe3VotROh

package main

import "sync/atomic"

var x uint32

func main() {
	atomic.AddUint32(&x, 1)
	for {
	}
}

What did you expect to see?

Compile successfully.

What did you see instead?

ICE.

$ GOARCH=arm64 GOOS=linux go-tip build x.go
# command-line-arguments
./x.go:9:2: internal compiler error: 'main': two final stores - simultaneous live stores v9 = AtomicAdd32Variant <uint32,mem> v4 v5 v1 v13 = AtomicAdd32 <uint32,mem> v4 v5 v1

goroutine 24 [running]:
runtime/debug.Stack(0x1c0a560, 0xc000130008, 0x0)
	/Users/cherryyz/src/go-tip/src/runtime/debug/stack.go:24 +0x9d
cmd/compile/internal/gc.Fatalf(0xc0003bc200, 0x37, 0xc000444180, 0x3, 0x3)
	/Users/cherryyz/src/go-tip/src/cmd/compile/internal/gc/subr.go:193 +0x291
cmd/compile/internal/gc.(*ssafn).Fatalf(0xc00011bb00, 0x902100000002, 0x1a644a3, 0x31, 0xc0004056e0, 0x2, 0x2)
	/Users/cherryyz/src/go-tip/src/cmd/compile/internal/gc/ssa.go:6811 +0x1b0
cmd/compile/internal/ssa.(*Func).Fatalf(...)
	/Users/cherryyz/src/go-tip/src/cmd/compile/internal/ssa/func.go:625
cmd/compile/internal/ssa.(*Block).Fatalf(...)
	/Users/cherryyz/src/go-tip/src/cmd/compile/internal/ssa/block.go:315
cmd/compile/internal/ssa.dse(0xc00017e2c0)
	/Users/cherryyz/src/go-tip/src/cmd/compile/internal/ssa/deadstore.go:67 +0xaf1
cmd/compile/internal/ssa.Compile(0xc00017e2c0)
	/Users/cherryyz/src/go-tip/src/cmd/compile/internal/ssa/compile.go:92 +0x9a5
cmd/compile/internal/gc.buildssa(0xc00017e160, 0x3, 0x0)
	/Users/cherryyz/src/go-tip/src/cmd/compile/internal/gc/ssa.go:444 +0xcd8
cmd/compile/internal/gc.compileSSA(0xc00017e160, 0x3)
	/Users/cherryyz/src/go-tip/src/cmd/compile/internal/gc/pgen.go:298 +0x5d
cmd/compile/internal/gc.compileFunctions.func2(0xc000423560, 0xc0001367b0, 0x3)
	/Users/cherryyz/src/go-tip/src/cmd/compile/internal/gc/pgen.go:363 +0x49
created by cmd/compile/internal/gc.compileFunctions
	/Users/cherryyz/src/go-tip/src/cmd/compile/internal/gc/pgen.go:361 +0x128
@cherrymui cherrymui self-assigned this Dec 5, 2019
@cherrymui cherrymui changed the title cmd/compile: ICE on ARM64: two stores live simultaneously cmd/compile: ICE: two stores live simultaneously Dec 5, 2019
@cherrymui

This comment has been minimized.

Copy link
Contributor Author

@cherrymui cherrymui commented Dec 5, 2019

package p

func F(b bool) {
	if b {
		g()
	} else {
		h()
	}
	for {}
}

func g()
func h()

This ICE on all architectures.

@cherrymui

This comment has been minimized.

Copy link
Contributor Author

@cherrymui cherrymui commented Dec 5, 2019

Before fuse, it is the correct diamond-shaped control flow.

b1:-
  v1 (?) = InitMem <mem>
  v5 (3) = Arg <bool> {b} (b[bool])
If v5 → b3 b4 (+4)

b2: ← b3 b4
Plain → b7 (+9)

b3: ← b1-
  v7 (+5) = StaticCall <mem> {"".g} v1
Plain → b2 (5)

b4: ← b1-
  v9 (+7) = StaticCall <mem> {"".h} v1
Plain → b2 (7)

b7: ← b2 b7
Plain → b7 (+9)

Fuse moves both branches into the same block...

b1:
BlockInvalid (+4)

b2:-
  v1 (?) = InitMem <mem>
  v5 (3) = Arg <bool> {b} (b[bool])
  v7 (+5) = StaticCall <mem> {"".g} v1
  v9 (+7) = StaticCall <mem> {"".h} v1
Plain → b7 (+9)

b3:
BlockInvalid (5)

b4:
BlockInvalid (7)

b7: ← b2 b7
Plain → b7 (+9)
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Dec 6, 2019

Change https://golang.org/cl/210179 mentions this issue: cmd/compile: don't fuse branches with side effects

@gopherbot gopherbot closed this in 7673884 Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.