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: spurious writebarriers emitted for global funcs #13901
Comments
Yes, you're right that it's safe to omit this write barrier, since we only care about heap -> heap pointer changes. We have various conditions for omitting write barriers if the slot is not in the heap, but I'm not aware of conditions for omitting write barriers if the pointer being written isn't a heap pointer. @randall77? |
Looks like it's a case of adding a case for PFUNC class nodes in this function https://golang.org/src/cmd/compile/internal/gc/walk.go#L2176 |
Yes, that sounds right. |
Yes, I see. Does this not fall under the "address of global" exception because we haven't split up the two words at this point? |
A PFUNC eventually expands to the address of a global (which is why it is ok), but it is represented differently at this point in the compiler. |
gc emits write barriers when a global function is assigned, even though it is unnecessary
reproducer:
Built with
go build -gcflags '-d wb' blah.go
, outputs./blah.go:9: write barrier
I don't think there is any correctness issues with emitting the WB and I doubt the performance suffers for it, but I did get a spurious warning when doing some runtime dev.
The text was updated successfully, but these errors were encountered: