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: tighten pass moves value incorrectly #19217

Closed
cherrymui opened this issue Feb 21, 2017 · 5 comments

Comments

Projects
None yet
3 participants
@cherrymui
Copy link
Contributor

commented Feb 21, 2017

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

go1.8

@funny-falcon reported in issue #19179 that the following code doesn't compile. It is a different bug than the original one in #19179 -- the problem happens in the tighten pass, instead of the writebarrier pass. I can reproduce it with Go 1.8. (But it compiles with Go 1.7)

package dbfile

import (
	"encoding/binary"
)

type DbBuilder struct {
	arr        []int
}

func (bld *DbBuilder) Finish() error {
	defer bld.Finish()

	var hash []byte
	for _, ixw := range bld.arr {
		for {
			if ixw != 0 {
				panic("ixw != 0")
			}
			ixw--
		insertOne:
			for {
				for i := 0; i < 1; i++ {
					if binary.LittleEndian.Uint16(hash[i:]) == 0 {
						break insertOne
					}
				}
			}
		}
	}

	return nil
}
@cherrymui

This comment has been minimized.

Copy link
Contributor Author

commented Feb 21, 2017

The problem is that
(before tighten)

b9:
  v148 = Phi <int> v39 v64
  ...

(some other blocks)

  v64 = Add64 <int> v100 v148
  ...

(some other blocks)
(have an edge going back to b9)

tighten pass moves v64 to the predecessor block of b9.
v64 corresponding to ixw-- in the code above.

@gopherbot

This comment has been minimized.

Copy link

commented Feb 23, 2017

CL https://golang.org/cl/37340 mentions this issue.

@gopherbot gopherbot closed this in abdb2c3 Feb 23, 2017

@cherrymui

This comment has been minimized.

Copy link
Contributor Author

commented Feb 27, 2017

Reopen for patching Go 1.8.

@cherrymui cherrymui reopened this Feb 27, 2017

@gopherbot

This comment has been minimized.

Copy link

commented Apr 5, 2017

CL https://golang.org/cl/39596 mentions this issue.

@aclements

This comment has been minimized.

Copy link
Member

commented Apr 5, 2017

Cherry-picked to release.

@aclements aclements closed this Apr 5, 2017

gopherbot pushed a commit that referenced this issue Apr 5, 2017

[release-branch.go1.8] cmd/compile: repaired loop-finder to handle tr…
…ickier nesting

The loop-A-encloses-loop-C code did not properly handle the
case where really C was already known to be enclosed by B,
and A was nearest-outer to B, not C.

Fixes #19217.

Change-Id: I755dd768e823cb707abdc5302fed39c11cdb34d4
Reviewed-on: https://go-review.googlesource.com/39596
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

@golang golang locked and limited conversation to collaborators Apr 5, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.