Currently, compiling this package:
package p
func F(p *int) { g(p) }
//go:norace
func g(p *int) { *p = 0 }
with "-S -race" shows that g is inlined into F, and the pointer assignment is instrumented with a race detector call, which seemingly defeats the intention of adding //go:norace.
Probably the easiest solution is that when instrumenting, we should treat //go:norace functions as non-inlinable.
Even better would be to avoid inlining //go:norace function calls only into instrumented functions (similar to how CL 102815 still allows inlining runtime calls within package runtime even during instrumented builds), but that would require tracking the //go:norace pragma across compilation units, which is a bit more involved.
/cc @cherrymui
Currently, compiling this package:
with "-S -race" shows that g is inlined into F, and the pointer assignment is instrumented with a race detector call, which seemingly defeats the intention of adding //go:norace.
Probably the easiest solution is that when instrumenting, we should treat //go:norace functions as non-inlinable.
Even better would be to avoid inlining //go:norace function calls only into instrumented functions (similar to how CL 102815 still allows inlining runtime calls within package runtime even during instrumented builds), but that would require tracking the //go:norace pragma across compilation units, which is a bit more involved.
/cc @cherrymui