cmd/compile: eliminate write barrier for self-referencing pointer #15238
Go code often does something like:
I don't think we need a write barrier when we write the slice pointer into b.buf, because the pointer always points from an object into (part of) itself.
But see the discussion in #14855 . Writing a pointer to the heap without a write barrier is tricky in the presence of races. Make sure the arguments in that issue don't apply here (I don't think they do, writing a self-pointer is like writing nil).
How much do you think this would actually win? Rick and I just spent half an hour debating whether it was actually safe to ignore write barriers for writes of nil in the presence of concurrent stack rescanning (which we don't do yet, but are considering). We eventually decided it was, but things like that make me weary of subtle write barrier optimizations.