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
Closed

cmd/compile: tighten pass moves value incorrectly #19217

cherrymui opened this issue Feb 21, 2017 · 5 comments

Comments

@cherrymui
Copy link
Member

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
Copy link
Member Author

cherrymui 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
Copy link

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

@cherrymui
Copy link
Member Author

Reopen for patching Go 1.8.

@cherrymui cherrymui reopened this Feb 27, 2017
@gopherbot
Copy link

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

@aclements
Copy link
Member

Cherry-picked to release.

gopherbot pushed a commit that referenced this issue Apr 5, 2017
…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.
Projects
None yet
Development

No branches or pull requests

3 participants